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

View File

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

View File

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

View File

@ -15,11 +15,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject) 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_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject, const Handle(AIS_InteractiveObject)& theObject,
const gp_Ax1& theAxis, 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) void AIS_AnimationAxisRotation::update(const AIS_AnimationProgress& theProgress)
{ {
if (myObject.IsNull()) if (myObject.IsNull())
@ -45,7 +42,8 @@ void AIS_AnimationAxisRotation::update (const AIS_AnimationProgress& theProgress
} }
gp_Trsf aTrsf; 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); aTrsf.SetRotation(myRotAxis, aCurrentAngle);
updateTrsf(aTrsf); updateTrsf(aTrsf);
} }

View File

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

View File

@ -18,10 +18,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation) IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
//============================================================================= //=================================================================================================
//function : AIS_AnimationCamera
//purpose :
//=============================================================================
AIS_AnimationCamera::AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName, AIS_AnimationCamera::AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
const Handle(V3d_View)& theView) const Handle(V3d_View)& theView)
: AIS_Animation(theAnimationName), : 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) void AIS_AnimationCamera::update(const AIS_AnimationProgress& theProgress)
{ {
if (myView.IsNull() if (myView.IsNull() || myCamStart.IsNull() || myCamEnd.IsNull())
|| myCamStart.IsNull()
|| myCamEnd.IsNull())
{ {
return; return;
} }

View File

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

View File

@ -16,10 +16,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
//============================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=============================================================================
AIS_AnimationObject::AIS_AnimationObject(const TCollection_AsciiString& theAnimationName, AIS_AnimationObject::AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext, const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject, 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) void AIS_AnimationObject::update(const AIS_AnimationProgress& theProgress)
{ {
if (myObject.IsNull()) if (myObject.IsNull())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,45 +25,26 @@
class TopoDS_Shape; class TopoDS_Shape;
class SelectMgr_EntityOwner; class SelectMgr_EntityOwner;
class AIS_C0RegularityFilter; class AIS_C0RegularityFilter;
DEFINE_STANDARD_HANDLE(AIS_C0RegularityFilter, SelectMgr_Filter) DEFINE_STANDARD_HANDLE(AIS_C0RegularityFilter, SelectMgr_Filter)
class AIS_C0RegularityFilter : public SelectMgr_Filter class AIS_C0RegularityFilter : public SelectMgr_Filter
{ {
public: public:
Standard_EXPORT AIS_C0RegularityFilter(const TopoDS_Shape& aShape); 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 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;
DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter, SelectMgr_Filter) DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter, SelectMgr_Filter)
protected: protected:
private: private:
TopTools_MapOfShape myMapOfEdges; TopTools_MapOfShape myMapOfEdges;
}; };
#endif // _AIS_C0RegularityFilter_HeaderFile #endif // _AIS_C0RegularityFilter_HeaderFile

View File

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

View File

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

View File

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

View File

@ -27,7 +27,6 @@ class AIS_Circle : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
public: public:
//! Initializes this algorithm for constructing AIS circle //! Initializes this algorithm for constructing AIS circle
//! datums initializes the circle aCircle //! datums initializes the circle aCircle
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle); Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle);
@ -36,13 +35,19 @@ public:
//! Initializes the circle theCircle, the arc //! Initializes the circle theCircle, the arc
//! starting point theUStart, the arc ending point theUEnd, //! starting point theUStart, the arc ending point theUEnd,
//! and the type of sensitivity theIsFilledCircleSens. //! 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. //! Returns index 6 by default.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; }
//! Indicates that the type of Interactive Object is a datum. //! 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. //! Returns the circle component defined in SetCircle.
const Handle(Geom_Circle)& Circle() const { return myComponent; } 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 //! 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. //! 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: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& theprs, const Handle(Prs3d_Presentation)& theprs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
@ -111,13 +118,11 @@ private:
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect); void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private: private:
Handle(Geom_Circle) myComponent; Handle(Geom_Circle) myComponent;
Standard_Real myUStart; Standard_Real myUStart;
Standard_Real myUEnd; Standard_Real myUEnd;
Standard_Boolean myCircleIsArc; Standard_Boolean myCircleIsArc;
Standard_Boolean myIsFilledCircleSens; Standard_Boolean myIsFilledCircleSens;
}; };
DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,20 +33,17 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
//======================================================================= //=================================================================================================
//function : AIS_ConnectedInteractive
//purpose : AIS_ConnectedInteractive::AIS_ConnectedInteractive(
//======================================================================= const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): : AIS_InteractiveObject(aTypeOfPresentation3d)
AIS_InteractiveObject(aTypeOfPresentation3d)
{ {
// //
} }
//======================================================================= //=================================================================================================
//function : connect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theAnotherObj, void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theLocation) const Handle(TopLoc_Datum3D)& theLocation)
{ {
@ -56,7 +53,8 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
return; return;
} }
Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj); Handle(AIS_ConnectedInteractive) aConnected =
Handle(AIS_ConnectedInteractive)::DownCast(theAnotherObj);
if (!aConnected.IsNull()) if (!aConnected.IsNull())
{ {
myReference = aConnected->myReference; myReference = aConnected->myReference;
@ -67,7 +65,8 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
} }
else 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()) if (!myReference.IsNull())
@ -76,17 +75,15 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
&& myReference->GetContext()->DisplayStatus(myReference) != AIS_DS_None) && myReference->GetContext()->DisplayStatus(myReference) != AIS_DS_None)
{ {
myReference.Nullify(); 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(); myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
} }
setLocalTransformation(theLocation); setLocalTransformation(theLocation);
} }
//======================================================================= //=================================================================================================
//function : Disconnect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Disconnect() void AIS_ConnectedInteractive::Disconnect()
{ {
@ -99,10 +96,9 @@ void AIS_ConnectedInteractive::Disconnect()
} }
} }
} }
//=======================================================================
//function : Compute //=================================================================================================
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, void AIS_ConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) 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, void AIS_ConnectedInteractive::computeHLR(const Handle(Graphic3d_Camera)& theProjector,
const Handle(TopLoc_Datum3D)& theTransformation, const Handle(TopLoc_Datum3D)& theTransformation,
const Handle(Prs3d_Presentation)& thePresentation) const Handle(Prs3d_Presentation)& thePresentation)
{ {
const bool hasTrsf = !theTransformation.IsNull() const bool hasTrsf = !theTransformation.IsNull() && theTransformation->Form() != gp_Identity;
&& theTransformation->Form() != gp_Identity;
updateShape(!hasTrsf); updateShape(!hasTrsf);
if (myShape.IsNull()) 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) void AIS_ConnectedInteractive::updateShape(const Standard_Boolean isWithLocation)
{ {
Handle(AIS_Shape) anAisShape = Handle(AIS_Shape)::DownCast(myReference); 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, void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
@ -218,7 +207,10 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
myReference->RecomputePrimitives(theMode); 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()) 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) const Standard_Integer theMode)
{ {
typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList; typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList> typedef NCollection_DataMap<TopoDS_Shape, SensitiveList> Shapes2EntitiesMap;
Shapes2EntitiesMap;
if (!myReference->HasSelection(theMode)) 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 // Fill in the map of subshapes and corresponding sensitive entities associated with aMode
Shapes2EntitiesMap aShapes2EntitiesMap; 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 (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(); const TopoDS_Shape& aSubShape = anOwner->Shape();
if (!aShapes2EntitiesMap.IsBound(aSubShape)) if (!aShapes2EntitiesMap.IsBound(aSubShape))
@ -276,7 +270,11 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
for (Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next()) for (Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
{ {
const SensitiveList& aSEList = aMapIt.Value(); 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()); anOwner->SetLocation(Transformation());
for (SensitiveList::Iterator aListIt(aSEList); aListIt.More(); aListIt.Next()) 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) DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
public: public:
//! Disconnects the previous view and sets highlight //! Disconnects the previous view and sets highlight
//! mode to 0. This highlights the wireframe presentation //! mode to 0. This highlights the wireframe presentation
//! aTypeOfPresentation3d. //! aTypeOfPresentation3d.
//! Top_AllView deactivates hidden line removal. //! 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 //! 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 //! Returns 0
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
//! Establishes the connection between the Connected //! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference. //! 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 //! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference. //! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation. //! Locates instance in aLocation.
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj, void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); } const Handle(TopLoc_Datum3D)& theLocation)
{
//! Establishes the connection between the Connected connect(theAnotherObj, theLocation);
//! 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); }
//! Returns true if there is a connection established //! Returns true if there is a connection established
//! between the presentation and its source reference. //! between the presentation and its source reference.
@ -88,12 +99,10 @@ public:
//! Return true if reference presentation accepts specified display mode. //! Return true if reference presentation accepts specified display mode.
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{ {
return myReference.IsNull() return myReference.IsNull() || myReference->AcceptDisplayMode(theMode);
|| myReference->AcceptDisplayMode (theMode);
} }
protected: protected:
//! Calculates the view aPresentation and its updates. //! Calculates the view aPresentation and its updates.
//! The latter are managed by aPresentationManager. //! The latter are managed by aPresentationManager.
//! The display mode aMode is 0 by default. //! The display mode aMode is 0 by default.
@ -110,17 +119,20 @@ protected:
//! Computes the presentation according to a point of view. //! Computes the presentation according to a point of view.
Standard_EXPORT virtual void computeHLR(const Handle(Graphic3d_Camera)& theProjector, Standard_EXPORT virtual void computeHLR(const Handle(Graphic3d_Camera)& theProjector,
const Handle(TopLoc_Datum3D)& theTrsf, const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE; const Handle(Prs3d_Presentation)& thePrs)
Standard_OVERRIDE;
//! Generates sensitive entities by copying //! Generates sensitive entities by copying
//! them from myReference selection, creates and sets an entity //! them from myReference selection, creates and sets an entity
//! owner for this entities and adds them to theSelection //! 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 //! Generates sensitive entities by copying
//! them from myReference sub shapes selection, creates and sets an entity //! them from myReference sub shapes selection, creates and sets an entity
//! owner for this entities and adds them to theSelection //! 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); Standard_EXPORT void updateShape(const Standard_Boolean WithLocation = Standard_True);
@ -128,10 +140,8 @@ protected:
const Handle(TopLoc_Datum3D)& theLocation); const Handle(TopLoc_Datum3D)& theLocation);
protected: protected:
Handle(AIS_InteractiveObject) myReference; Handle(AIS_InteractiveObject) myReference;
TopoDS_Shape myShape; TopoDS_Shape myShape;
}; };
DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject) 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 // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#ifndef AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile #ifndef AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile
#define AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile #define AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile

View File

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

View File

@ -18,6 +18,7 @@
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
#include <TopTools_ShapeMapHasher.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 #endif // _AIS_DataMapOfShapeDrawer_HeaderFile

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,52 +28,41 @@
class Quantity_Color; class Quantity_Color;
class Graphic3d_MaterialAspect; class Graphic3d_MaterialAspect;
class AIS_GraphicTool class AIS_GraphicTool
{ {
public: public:
DEFINE_STANDARD_ALLOC 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,
Standard_EXPORT static void GetLineAtt (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes, Quantity_NameOfColor& aCol, Standard_Real& aWidth, Aspect_TypeOfLine& aTyp); Quantity_NameOfColor& aCol,
Standard_Real& aWidth,
Aspect_TypeOfLine& aTyp);
Standard_EXPORT static Quantity_NameOfColor GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer); 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); Standard_EXPORT static Graphic3d_MaterialAspect GetMaterial(const Handle(Prs3d_Drawer)& aDrawer);
protected: protected:
private: private:
}; };
#endif // _AIS_GraphicTool_HeaderFile #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) 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), : SelectMgr_SelectableObject(aTypeOfPresentation3d),
myCTXPtr(NULL) myCTXPtr(NULL)
{ {
// //
} }
//======================================================================= //=================================================================================================
//function : Redisplay
//purpose :
//=======================================================================
void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes) void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes)
{ {
if (myCTXPtr == NULL) if (myCTXPtr == NULL)
@ -52,10 +49,8 @@ void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
myCTXPtr->Redisplay(this, Standard_False, AllModes); myCTXPtr->Redisplay(this, Standard_False, AllModes);
} }
//======================================================================= //=================================================================================================
//function : ProcessDragging
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)&, Standard_Boolean AIS_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)&,
const Handle(V3d_View)&, const Handle(V3d_View)&,
const Handle(SelectMgr_EntityOwner)&, const Handle(SelectMgr_EntityOwner)&,
@ -66,19 +61,15 @@ Standard_Boolean AIS_InteractiveObject::ProcessDragging (const Handle(AIS_Intera
return Standard_False; return Standard_False;
} }
//======================================================================= //=================================================================================================
//function :
//purpose :
//=======================================================================
Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
{ {
return myCTXPtr; return myCTXPtr;
} }
//======================================================================= //=================================================================================================
//function : SetContext
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetContext(const Handle(AIS_InteractiveContext)& theCtx) void AIS_InteractiveObject::SetContext(const Handle(AIS_InteractiveContext)& theCtx)
{ {
if (myCTXPtr == theCtx.get()) 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) void AIS_InteractiveObject::SetDisplayStatus(PrsMgr_DisplayStatus theStatus)
{ {
myDisplayStatus = theStatus; myDisplayStatus = theStatus;
} }
//======================================================================= //=================================================================================================
//function : HasPresentation
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasPresentation() const Standard_Boolean AIS_InteractiveObject::HasPresentation() const
{ {
return HasInteractiveContext() return HasInteractiveContext()
&& myCTXPtr->MainPrsMgr()->HasPresentation(this, myDrawer->DisplayMode()); && myCTXPtr->MainPrsMgr()->HasPresentation(this, myDrawer->DisplayMode());
} }
//======================================================================= //=================================================================================================
//function : Presentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
{ {
if (!HasInteractiveContext()) if (!HasInteractiveContext())
@ -123,14 +108,13 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
return Handle(Prs3d_Presentation)(); 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; return aPrs;
} }
//======================================================================= //=================================================================================================
//function : SetAspect
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect) 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 void AIS_InteractiveObject::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{ {
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream) 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. //! Defines a class of objects with display and selection services.
//! Entities which are visualized and selected are Interactive Objects. //! 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, //! You can make use of classes of standard Interactive Objects for which all necessary methods have
//! or you can implement your own classes of Interactive Objects. //! already been programmed, or you can implement your own classes of Interactive Objects. Key
//! Key interface methods to be implemented by every Interactive Object: //! interface methods to be implemented by every Interactive Object:
//! * Presentable Object (PrsMgr_PresentableObject) //! * 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; //! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index; //! - Compute() computing presentation for the given display mode index;
//! * Selectable Object (SelectMgr_SelectableObject) //! * 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. //! - ComputeSelection() computing selectable entities for the given selection mode index.
class AIS_InteractiveObject : public SelectMgr_SelectableObject class AIS_InteractiveObject : public SelectMgr_SelectableObject
{ {
friend class AIS_InteractiveContext; friend class AIS_InteractiveContext;
DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject) DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
public: public:
//! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default. //! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default.
virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; } virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; }
@ -79,7 +81,8 @@ public:
Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& aCtx); Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& aCtx);
//! Returns true if the object has an owner attributed to it. //! 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(); } Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
//! Returns the owner of the Interactive Object. //! Returns the owner of the Interactive Object.
@ -97,10 +100,13 @@ public:
//! an Interactive Object. This can be a shape for a set of //! an Interactive Object. This can be a shape for a set of
//! sub-shapes or a sub-shape for sub-shapes which it //! sub-shapes or a sub-shape for sub-shapes which it
//! is composed of. The owner takes the form of a transient. //! 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. //! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of
//! This method removes the owner from the graphic entity. //! a Transient. This method removes the owner from the graphic entity.
void ClearOwner() { myOwner.Nullify(); } void ClearOwner() { myOwner.Nullify(); }
//! Drag object in the viewer. //! Drag object in the viewer.
@ -111,7 +117,8 @@ public:
//! @param[in] theDragTo drag end point //! @param[in] theDragTo drag end point
//! @param[in] theAction drag action //! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start) //! @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(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom, const Graphic3d_Vec2i& theDragFrom,
@ -119,7 +126,6 @@ public:
const AIS_DragAction theAction); const AIS_DragAction theAction);
public: public:
//! Returns the context pointer to the interactive context. //! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const; Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
@ -134,23 +140,23 @@ public:
Standard_EXPORT void SetAspect(const Handle(Prs3d_BasicAspect)& anAspect); Standard_EXPORT void SetAspect(const Handle(Prs3d_BasicAspect)& anAspect);
//! Dumps the content of me into the stream //! 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,
protected: Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
//! The TypeOfPresention3d means that the interactive object //! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependent on the view of Display. //! 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. //! Set presentation display status.
Standard_EXPORT void SetDisplayStatus(PrsMgr_DisplayStatus theStatus); Standard_EXPORT void SetDisplayStatus(PrsMgr_DisplayStatus theStatus);
protected: protected:
// clang-format off // clang-format off
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext() AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
// clang-format on // clang-format on
Handle(Standard_Transient) myOwner; //!< application-specific owner object Handle(Standard_Transient) myOwner; //!< application-specific owner object
}; };
DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) 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_Shape, //!< presentation of topological shape
AIS_KindOfInteractive_Object, //!< presentation of group of topological shapes AIS_KindOfInteractive_Object, //!< presentation of group of topological shapes
AIS_KindOfInteractive_Relation, //!< presentation of relation (dimensions and constraints) 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 AIS_KindOfInteractive_LightSource, //!< presentation of light source
// old aliases // old aliases

View File

@ -55,10 +55,8 @@ Standard_Boolean AIS_LightSourceOwner::HandleMouseClick (const Graphic3d_Vec2i&
bool) bool)
{ {
AIS_LightSource* aLightSource = dynamic_cast<AIS_LightSource*>(mySelectable); AIS_LightSource* aLightSource = dynamic_cast<AIS_LightSource*>(mySelectable);
if (aLightSource != NULL if (aLightSource != NULL && aLightSource->ToSwitchOnClick()
&& aLightSource->ToSwitchOnClick() && theKey == Aspect_VKeyMouse_LeftButton && theFlags == Aspect_VKeyFlags_NONE)
&& theKey == Aspect_VKeyMouse_LeftButton
&& theFlags == Aspect_VKeyFlags_NONE)
{ {
aLightSource->Light()->SetEnabled(!aLightSource->Light()->IsEnabled()); aLightSource->Light()->SetEnabled(!aLightSource->Light()->IsEnabled());
aLightSource->updateLightAspects(); aLightSource->updateLightAspects();
@ -67,10 +65,8 @@ Standard_Boolean AIS_LightSourceOwner::HandleMouseClick (const Graphic3d_Vec2i&
return false; return false;
} }
//======================================================================= //=================================================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
void AIS_LightSourceOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM, void AIS_LightSourceOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -81,10 +77,12 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
return; 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); Handle(Prs3d_Presentation) aPrs = aLightSource->GetHilightPresentation(thePM);
const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1 const Graphic3d_ZLayerId aZLayer =
theStyle->ZLayer() != -1
? theStyle->ZLayer() ? theStyle->ZLayer()
: (thePM->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : aLightSource->ZLayer()); : (thePM->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : aLightSource->ZLayer());
aPrs->Clear(); aPrs->Clear();
@ -100,7 +98,8 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
} }
aPoints->AddVertex(aDetPnt); aPoints->AddVertex(aDetPnt);
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup(); 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->SetGroupPrimitivesAspect(aPointAspect->Aspect());
aGroup->AddPrimitiveArray(aPoints); aGroup->AddPrimitiveArray(aPoints);
@ -115,7 +114,9 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
} }
for (Standard_Integer aStep = 0; aStep < aNbPnts; ++aStep) 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(); 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) 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); aPolylines->AddBound(aNbPnts);
for (Standard_Integer anIdx = 0; anIdx < aNbPnts; ++anIdx) for (Standard_Integer anIdx = 0; anIdx < aNbPnts; ++anIdx)
@ -144,14 +146,13 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
} }
else else
{ {
base_type::HilightWithColor (thePM, theStyle, theMode);; base_type::HilightWithColor(thePM, theStyle, theMode);
;
} }
} }
//======================================================================= //=================================================================================================
//function : IsForcedHilight
//purpose :
//=======================================================================
Standard_Boolean AIS_LightSourceOwner::IsForcedHilight() const Standard_Boolean AIS_LightSourceOwner::IsForcedHilight() const
{ {
Handle(AIS_LightSource) aLightSource = Handle(AIS_LightSource)::DownCast(mySelectable); 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()->ChangeFrontMaterial() = aMat;
myDrawer->ArrowAspect()->Aspect()->SetMarkerType(Aspect_TOM_EMPTY); myDrawer->ArrowAspect()->Aspect()->SetMarkerType(Aspect_TOM_EMPTY);
myDrawer->ArrowAspect()->Aspect()->SetMarkerScale(2.0f); 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); theLight->Type() != Graphic3d_TypeOfLightSource_Ambient ? 3.0f : 1.0f);
myDrawer->SetupOwnShadingAspect(); myDrawer->SetupOwnShadingAspect();
@ -226,8 +229,7 @@ AIS_LightSource::AIS_LightSource (const Handle(Graphic3d_CLight)& theLight)
myDynHilightDrawer->SetDisplayMode(1); myDynHilightDrawer->SetDisplayMode(1);
myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1); myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1);
if (!myTransformPersistence.IsNull() if (!myTransformPersistence.IsNull() && myTransformPersistence->IsTrihedronOr2d())
&& myTransformPersistence->IsTrihedronOr2d())
{ {
myDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost); myDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost);
myDynHilightDrawer->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, Standard_Boolean AIS_LightSource::ProcessDragging(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView, const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(SelectMgr_EntityOwner)& theOwner,
@ -254,17 +254,14 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
switch (theAction) switch (theAction)
{ {
case AIS_DragAction_Start: case AIS_DragAction_Start: {
{
myLocTrsfStart = LocalTransformation(); myLocTrsfStart = LocalTransformation();
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Confirmed: case AIS_DragAction_Confirmed: {
{
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Update: case AIS_DragAction_Update: {
{
mySensSphere->ResetLastDetectedPoint(); mySensSphere->ResetLastDetectedPoint();
SetLocalTransformation(myLocTrsfStart); SetLocalTransformation(myLocTrsfStart);
theCtx->MainSelector()->Pick(theDragFrom.x(), theDragFrom.y(), theView); 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()) && aStartPosition.Distance(aCurrPosition) > Precision::Confusion())
{ {
gp_Quaternion aQRot; 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; gp_Trsf aTrsf;
aTrsf.SetRotation(aQRot); aTrsf.SetRotation(aQRot);
SetLocalTransformation(myLocTrsfStart * aTrsf); SetLocalTransformation(myLocTrsfStart * aTrsf);
@ -286,12 +284,10 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
} }
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Abort: case AIS_DragAction_Abort: {
{
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Stop: case AIS_DragAction_Stop: {
{
GetHilightPresentation(theCtx->MainPrsMgr())->Clear(); GetHilightPresentation(theCtx->MainPrsMgr())->Clear();
break; break;
} }
@ -314,7 +310,8 @@ void AIS_LightSource::updateLightAspects()
myDisabledMarkerAspect->SetColor(aColor); myDisabledMarkerAspect->SetColor(aColor);
myDisabledMarkerAspect->SetMarkerScale(myDrawer->PointAspect()->Aspect()->MarkerScale()); 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)); myDisabledMarkerAspect->SetMarkerImage(MarkerImage(false));
myDrawer->ShadingAspect()->SetColor(aColor); myDrawer->ShadingAspect()->SetColor(aColor);
@ -325,11 +322,11 @@ void AIS_LightSource::updateLightAspects()
{ {
const Standard_Real anAngleTol = 2.0 * M_PI / 180.0; const Standard_Real anAngleTol = 2.0 * M_PI / 180.0;
Aspect_TypeOfMarker aDirMark = Aspect_TOM_EMPTY; Aspect_TypeOfMarker aDirMark = Aspect_TOM_EMPTY;
if (myLightSource->IsEnabled() if (myLightSource->IsEnabled() && myLightSource->IsHeadlight()
&& myLightSource->IsHeadlight()
&& myLightSource->Direction().IsParallel(gp::DZ(), anAngleTol)) && 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); myDrawer->ArrowAspect()->Aspect()->SetMarkerType(aDirMark);
} }
@ -345,13 +342,14 @@ void AIS_LightSource::updateLightTransformPersistence()
Handle(Graphic3d_TransformPers) aTrsfPers = myTransformPersistence; Handle(Graphic3d_TransformPers) aTrsfPers = myTransformPersistence;
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TypeOfLightSource_Ambient: case Graphic3d_TypeOfLightSource_Ambient: {
{
if (!myIsZoomable) if (!myIsZoomable)
{ {
if (aTrsfPers.IsNull() || !aTrsfPers->IsTrihedronOr2d()) 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 else
@ -360,9 +358,9 @@ void AIS_LightSource::updateLightTransformPersistence()
} }
break; break;
} }
case Graphic3d_TypeOfLightSource_Directional: case Graphic3d_TypeOfLightSource_Directional: {
{ Graphic3d_TransModeFlags aMode =
Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers; myLightSource->IsHeadlight() ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers;
if (myIsZoomable) if (myIsZoomable)
{ {
aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_CameraPers : Graphic3d_TMF_None; aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_CameraPers : Graphic3d_TMF_None;
@ -377,7 +375,8 @@ void AIS_LightSource::updateLightTransformPersistence()
} }
else 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; break;
} }
case Graphic3d_TypeOfLightSource_Positional: case Graphic3d_TypeOfLightSource_Positional:
case Graphic3d_TypeOfLightSource_Spot: case Graphic3d_TypeOfLightSource_Spot: {
{ Graphic3d_TransModeFlags aMode =
Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight() myLightSource->IsHeadlight()
? Graphic3d_TMF_CameraPers ? Graphic3d_TMF_CameraPers
: (!myIsZoomable ? Graphic3d_TMF_ZoomPers : Graphic3d_TMF_None); : (!myIsZoomable ? Graphic3d_TMF_ZoomPers : Graphic3d_TMF_None);
if (aMode != Graphic3d_TMF_None) if (aMode != Graphic3d_TMF_None)
@ -431,8 +430,7 @@ void AIS_LightSource::updateLightLocalTransformation()
myLocalTransformation.Nullify(); myLocalTransformation.Nullify();
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TypeOfLightSource_Ambient: case Graphic3d_TypeOfLightSource_Ambient: {
{
if (myIsZoomable) if (myIsZoomable)
{ {
gp_Trsf aTrsf; gp_Trsf aTrsf;
@ -441,8 +439,7 @@ void AIS_LightSource::updateLightLocalTransformation()
} }
break; break;
} }
case Graphic3d_TypeOfLightSource_Directional: case Graphic3d_TypeOfLightSource_Directional: {
{
const gp_Pnt aLightPos = (myIsZoomable && !myLightSource->IsHeadlight()) const gp_Pnt aLightPos = (myIsZoomable && !myLightSource->IsHeadlight())
? myLightSource->DisplayPosition() ? myLightSource->DisplayPosition()
: gp::Origin(); : gp::Origin();
@ -452,8 +449,7 @@ void AIS_LightSource::updateLightLocalTransformation()
myLocalTransformation = new TopLoc_Datum3D(aTrsf); myLocalTransformation = new TopLoc_Datum3D(aTrsf);
break; break;
} }
case Graphic3d_TypeOfLightSource_Positional: case Graphic3d_TypeOfLightSource_Positional: {
{
if (myIsZoomable) if (myIsZoomable)
{ {
gp_Trsf aTrsf; gp_Trsf aTrsf;
@ -462,10 +458,10 @@ void AIS_LightSource::updateLightLocalTransformation()
} }
break; break;
} }
case Graphic3d_TypeOfLightSource_Spot: case Graphic3d_TypeOfLightSource_Spot: {
{
gp_Trsf aTrsf; 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()); aTrsf.SetTransformation(anAx2, gp_Ax3());
myLocalTransformation = new TopLoc_Datum3D(aTrsf); myLocalTransformation = new TopLoc_Datum3D(aTrsf);
break; break;
@ -483,12 +479,10 @@ void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theT
const gp_Trsf aTrsf = !theTrsf.IsNull() ? theTrsf->Transformation() : gp_Trsf(); const gp_Trsf aTrsf = !theTrsf.IsNull() ? theTrsf->Transformation() : gp_Trsf();
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TypeOfLightSource_Ambient: case Graphic3d_TypeOfLightSource_Ambient: {
{
break; break;
} }
case Graphic3d_TypeOfLightSource_Directional: case Graphic3d_TypeOfLightSource_Directional: {
{
gp_Dir aNewDir = (-gp::DZ()).Transformed(aTrsf); gp_Dir aNewDir = (-gp::DZ()).Transformed(aTrsf);
myLightSource->SetDirection(aNewDir); myLightSource->SetDirection(aNewDir);
if (myIsZoomable) if (myIsZoomable)
@ -498,14 +492,12 @@ void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theT
} }
break; break;
} }
case Graphic3d_TypeOfLightSource_Positional: case Graphic3d_TypeOfLightSource_Positional: {
{
gp_Pnt aNewPos = gp::Origin().Transformed(aTrsf); gp_Pnt aNewPos = gp::Origin().Transformed(aTrsf);
myLightSource->SetPosition(aNewPos); myLightSource->SetPosition(aNewPos);
break; break;
} }
case Graphic3d_TypeOfLightSource_Spot: case Graphic3d_TypeOfLightSource_Spot: {
{
gp_Pnt aNewPos = gp::Origin().Transformed(aTrsf); gp_Pnt aNewPos = gp::Origin().Transformed(aTrsf);
myLightSource->SetPosition(aNewPos); myLightSource->SetPosition(aNewPos);
@ -530,8 +522,7 @@ void AIS_LightSource::Compute (const Handle(PrsMgr_PresentationManager)& ,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
thePrs->SetInfiniteState(myInfiniteState); thePrs->SetInfiniteState(myInfiniteState);
if (theMode != 0 if (theMode != 0 && theMode != 1)
&& theMode != 1)
{ {
return; return;
} }
@ -545,17 +536,24 @@ void AIS_LightSource::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (myLightSource->Type()) switch (myLightSource->Type())
{ {
case Graphic3d_TypeOfLightSource_Ambient: computeAmbient (thePrs, theMode); break; case Graphic3d_TypeOfLightSource_Ambient:
case Graphic3d_TypeOfLightSource_Directional: computeDirectional(thePrs, theMode); break; computeAmbient(thePrs, theMode);
case Graphic3d_TypeOfLightSource_Positional: computePositional (thePrs, theMode); break; break;
case Graphic3d_TypeOfLightSource_Spot: computeSpot (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) if (myToDisplayName)
{ {
TCollection_AsciiString aPrefix = !myTransformPersistence.IsNull() TCollection_AsciiString aPrefix =
&& myTransformPersistence->IsTrihedronOr2d() !myTransformPersistence.IsNull() && myTransformPersistence->IsTrihedronOr2d() ? "\n" : " ";
? "\n" : " ";
TCollection_AsciiString aName = aPrefix + myLightSource->Name(); TCollection_AsciiString aName = aPrefix + myLightSource->Name();
Prs3d_Text::Draw(thePrs->NewGroup(), myDrawer->TextAspect(), aName, gp::Origin()); 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(); const gp_XYZ aLightPos = gp::Origin().XYZ();
if (theMode == 0) 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(); Handle(Graphic3d_Group) aSphereGroup = thePrs->NewGroup();
aSphereGroup->SetClosed(true); aSphereGroup->SetClosed(true);
aSphereGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); aSphereGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
aSphereGroup->AddPrimitiveArray(aSphereArray); aSphereGroup->AddPrimitiveArray(aSphereArray);
} }
if (theMode == 0 if (theMode == 0 || theMode == 1)
|| theMode == 1)
{ {
const Standard_Real aLen = mySize * 0.25; const Standard_Real aLen = mySize * 0.25;
const Standard_Integer aNbArrows = 6; const Standard_Integer aNbArrows = 6;
const gp_Dir aDirList[6] = {-gp::DX(), gp::DX(), -gp::DY(), gp::DY(), -gp::DZ(), gp::DZ()}; 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); const Prs3d_ToolCylinder aCylTool(mySize * 0.1,
Handle(Graphic3d_ArrayOfTriangles) aTrisArray = new Graphic3d_ArrayOfTriangles (aNbArrows * aCylTool.VerticesNb(), 0.0,
mySize * 0.2,
myNbSplitsArrow,
myNbSplitsArrow);
Handle(Graphic3d_ArrayOfTriangles) aTrisArray =
new Graphic3d_ArrayOfTriangles(aNbArrows * aCylTool.VerticesNb(),
aNbArrows * aCylTool.TrianglesNb() * 3, aNbArrows * aCylTool.TrianglesNb() * 3,
Graphic3d_ArrayFlags_VertexNormal); Graphic3d_ArrayFlags_VertexNormal);
Handle(Graphic3d_ArrayOfSegments) aLineArray = new Graphic3d_ArrayOfSegments(aNbArrows * 2); 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); Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints(1);
aPoints->AddVertex(aLightPos); aPoints->AddVertex(aLightPos);
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); 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); aGroup->AddPrimitiveArray(aPoints);
} }
} }
@ -646,9 +650,18 @@ void AIS_LightSource::computeDirectional (const Handle(Prs3d_Presentation)& theP
const gp_XYZ aLightPos = -aStep * aLightDir.XYZ(); const gp_XYZ aLightPos = -aStep * aLightDir.XYZ();
Standard_Integer aNbArrows = 1; Standard_Integer aNbArrows = 1;
if (myNbArrows >= 9) { aNbArrows = 9; } if (myNbArrows >= 9)
else if (myNbArrows >= 5) { aNbArrows = 5; } {
else if (myNbArrows >= 3) { aNbArrows = 3; } aNbArrows = 9;
}
else if (myNbArrows >= 5)
{
aNbArrows = 5;
}
else if (myNbArrows >= 3)
{
aNbArrows = 3;
}
TColgp_Array1OfPnt aPoints(1, aNbArrows); TColgp_Array1OfPnt aPoints(1, aNbArrows);
{ {
const gp_Ax2 anAxes(gp::Origin(), aLightDir); 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; const gp_XYZ aDXY = aDX + aDY;
switch (aNbArrows) switch (aNbArrows)
{ {
case 9: case 9: {
{
aPoints.SetValue(6, aLightPos + aDY); aPoints.SetValue(6, aLightPos + aDY);
aPoints.SetValue(7, aLightPos + aDX); aPoints.SetValue(7, aLightPos + aDX);
aPoints.SetValue(8, aLightPos - aDY); aPoints.SetValue(8, aLightPos - aDY);
aPoints.SetValue(9, aLightPos - aDX); aPoints.SetValue(9, aLightPos - aDX);
} }
Standard_FALLTHROUGH Standard_FALLTHROUGH
case 5: case 5: {
{
aPoints.SetValue(4, aLightPos - aDY + aDX); aPoints.SetValue(4, aLightPos - aDY + aDX);
aPoints.SetValue(5, aLightPos + aDY - aDX); aPoints.SetValue(5, aLightPos + aDY - aDX);
} }
Standard_FALLTHROUGH Standard_FALLTHROUGH
case 3: case 3: {
{
aPoints.SetValue(2, aLightPos + aDXY); aPoints.SetValue(2, aLightPos + aDXY);
aPoints.SetValue(3, aLightPos - aDXY); aPoints.SetValue(3, aLightPos - aDXY);
} }
Standard_FALLTHROUGH Standard_FALLTHROUGH
case 1: case 1: {
{
aPoints.SetValue(1, aLightPos); aPoints.SetValue(1, aLightPos);
break; 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; Handle(Graphic3d_ArrayOfTriangles) aTrisArray;
if (theMode == 0) if (theMode == 0)
{ {
@ -759,12 +772,12 @@ void AIS_LightSource::computePositional (const Handle(Prs3d_Presentation)& thePr
{ {
// light source position is set to local transformation // light source position is set to local transformation
const gp_XYZ aLightPos = gp::Origin().XYZ(); const gp_XYZ aLightPos = gp::Origin().XYZ();
const Standard_Real aRadius = (myIsZoomable && myLightSource->HasRange()) ? myLightSource->Range() : 0.0; const Standard_Real aRadius =
if (theMode == 0 (myIsZoomable && myLightSource->HasRange()) ? myLightSource->Range() : 0.0;
&& aRadius > 0.0 if (theMode == 0 && aRadius > 0.0 && myToDisplayRange)
&& 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(); Handle(Graphic3d_Group) aRangeGroup = thePrs->NewGroup();
aRangeGroup->SetClosed(true); aRangeGroup->SetClosed(true);
aRangeGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); 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 // light source position and direction are set to local transformation
const gp_Dir aLightDir = -gp::DZ(); const gp_Dir aLightDir = -gp::DZ();
const gp_XYZ aLightPos = gp::Origin().XYZ(); 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); Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints(1);
aPoints->AddVertex(aLightPos); aPoints->AddVertex(aLightPos);
@ -815,16 +829,20 @@ void AIS_LightSource::computeSpot (const Handle(Prs3d_Presentation)& thePrs,
aDirGroup->AddPrimitiveArray(aDirArray); aDirGroup->AddPrimitiveArray(aDirArray);
} }
if (theMode == 0 if (theMode == 0 && myToDisplayRange)
&& myToDisplayRange)
{ {
const Standard_ShortReal aHalfAngle = myLightSource->Angle() / 2.0f; const Standard_ShortReal aHalfAngle = myLightSource->Angle() / 2.0f;
const Standard_Real aRadius = aDistance * Tan(aHalfAngle); const Standard_Real aRadius = aDistance * Tan(aHalfAngle);
gp_Ax3 aSystem(aLightPos + aLightDir.XYZ() * aDistance, -aLightDir); gp_Ax3 aSystem(aLightPos + aLightDir.XYZ() * aDistance, -aLightDir);
gp_Trsf aTrsfCone; gp_Trsf aTrsfCone;
aTrsfCone.SetTransformation(aSystem, gp_Ax3()); aTrsfCone.SetTransformation(aSystem, gp_Ax3());
Handle(Graphic3d_ArrayOfTriangles) aSpotRangeArray = Prs3d_ToolCylinder::Create (aRadius, 0.0, aDistance, Handle(Graphic3d_ArrayOfTriangles) aSpotRangeArray =
myNbSplitsQuadric, myNbSplitsQuadric, aTrsfCone); Prs3d_ToolCylinder::Create(aRadius,
0.0,
aDistance,
myNbSplitsQuadric,
myNbSplitsQuadric,
aTrsfCone);
Handle(Graphic3d_Group) aRangeGroup = thePrs->NewGroup(); Handle(Graphic3d_Group) aRangeGroup = thePrs->NewGroup();
aRangeGroup->SetClosed(true); aRangeGroup->SetClosed(true);
@ -853,10 +871,10 @@ void AIS_LightSource::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
theSel->Add(mySensSphere); 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); aSensPosition->SetSensitivityFactor(12);
if (!myTransformPersistence.IsNull() if (!myTransformPersistence.IsNull() && myTransformPersistence->IsTrihedronOr2d())
&& myTransformPersistence->IsTrihedronOr2d())
{ {
aSensPosition->SetSensitivityFactor(Max(12, Standard_Integer(mySize * 0.5))); 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; //! - Positional light is represented by a sphere or marker;
//! - Spot light is represented by a cone; //! - Spot light is represented by a cone;
//! - Directional light is represented by a set of arrows at the corner of view. //! - 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 class AIS_LightSource : public AIS_InteractiveObject
{ {
friend class AIS_LightSourceOwner; friend class AIS_LightSourceOwner;
DEFINE_STANDARD_RTTIEXT(AIS_LightSource, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_LightSource, AIS_InteractiveObject)
public: public:
//! Initializes the light source by copying Graphic3d_CLight settings. //! Initializes the light source by copying Graphic3d_CLight settings.
Standard_EXPORT AIS_LightSource(const Handle(Graphic3d_CLight)& theLightSource); Standard_EXPORT AIS_LightSource(const Handle(Graphic3d_CLight)& theLightSource);
@ -50,7 +50,6 @@ public:
} }
public: //! @name Light properties public: //! @name Light properties
//! Returns TRUE if the light source name should be displayed; TRUE by default. //! Returns TRUE if the light source name should be displayed; TRUE by default.
Standard_Boolean ToDisplayName() const { return myToDisplayName; } 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. //! Returns TRUE to display light source range as sphere (positional light) or cone (spot light);
//! Has no effect for non-zoomable presentation. //! TRUE by default. Has no effect for non-zoomable presentation.
Standard_Boolean ToDisplayRange() const { return myToDisplayRange; } Standard_Boolean ToDisplayRange() const { return myToDisplayRange; }
//! Show/hide light source range shaded presentation. //! Show/hide light source range shaded presentation.
@ -149,15 +148,20 @@ public: //! @name Light properties
//! Returns light source icon. //! Returns light source icon.
//! @param[in] theIsEnabled marker index for enabled/disabled light source states //! @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. //! Returns light source icon.
//! @param[in] theIsEnabled marker index for enabled/disabled light source states //! @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. //! Sets custom icon to light source.
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage, void SetMarkerImage(const Handle(Graphic3d_MarkerImage)& theImage, bool theIsEnabled)
bool theIsEnabled)
{ {
myMarkerImages[theIsEnabled ? 1 : 0] = theImage; myMarkerImages[theIsEnabled ? 1 : 0] = theImage;
myMarkerTypes[theIsEnabled ? 1 : 0] = !theImage.IsNull() myMarkerTypes[theIsEnabled ? 1 : 0] = !theImage.IsNull()
@ -166,8 +170,7 @@ public: //! @name Light properties
} }
//! Sets standard icon to light source. //! Sets standard icon to light source.
void SetMarkerType (Aspect_TypeOfMarker theType, void SetMarkerType(Aspect_TypeOfMarker theType, bool theIsEnabled)
bool theIsEnabled)
{ {
myMarkerTypes[theIsEnabled ? 1 : 0] = theType; myMarkerTypes[theIsEnabled ? 1 : 0] = theType;
} }
@ -185,15 +188,17 @@ public: //! @name Light properties
void SetNbSplitsArrow(Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; } void SetNbSplitsArrow(Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; }
//! Returns kind of the object. //! 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: protected:
//! Return true if specified display mode is supported: 0 for main presentation and 1 for
//! Return true if specified display mode is supported: 0 for main presentation and 1 for highlight. //! highlight.
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{ {
return theMode == 0 return theMode == 0 || theMode == 1;
|| theMode == 1;
} }
//! Computes selection sensitive zones(triangulation) for light source presentation. //! Computes selection sensitive zones(triangulation) for light source presentation.
@ -213,7 +218,8 @@ protected:
//! @param[in] theDragTo drag end point //! @param[in] theDragTo drag end point
//! @param[in] theAction drag action //! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start) //! @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(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom, const Graphic3d_Vec2i& theDragFrom,
@ -221,7 +227,8 @@ protected:
const AIS_DragAction theAction) Standard_OVERRIDE; const AIS_DragAction theAction) Standard_OVERRIDE;
//! Sets new local transformation, which is propagated to Graphic3d_CLight instance. //! 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. //! Updates local transformation basing on a type of light source.
Standard_EXPORT virtual void updateLightLocalTransformation(); Standard_EXPORT virtual void updateLightLocalTransformation();
@ -240,7 +247,8 @@ protected:
Standard_EXPORT virtual void computeDirectional(const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void computeDirectional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode); 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, Standard_EXPORT virtual void computePositional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode); const Standard_Integer theMode);
@ -249,7 +257,6 @@ protected:
const Standard_Integer theMode); const Standard_Integer theMode);
protected: protected:
Handle(Graphic3d_CLight) myLightSource; //!< displayed light source Handle(Graphic3d_CLight) myLightSource; //!< displayed light source
// clang-format off // clang-format off
@ -273,7 +280,6 @@ protected:
Standard_Boolean myToDisplayName; //!< flag to show/hide name Standard_Boolean myToDisplayName; //!< flag to show/hide name
Standard_Boolean myToDisplayRange; //!< flag to show/hide range of positional/spot light 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 Standard_Boolean myToSwitchOnClick; //!< flag to handle mouse click to turn light on/off
}; };
//! Owner of AIS_LightSource presentation. //! Owner of AIS_LightSource presentation.
@ -281,7 +287,6 @@ class AIS_LightSourceOwner : public SelectMgr_EntityOwner
{ {
DEFINE_STANDARD_RTTIEXT(AIS_LightSourceOwner, SelectMgr_EntityOwner) DEFINE_STANDARD_RTTIEXT(AIS_LightSourceOwner, SelectMgr_EntityOwner)
public: public:
//! Main constructor. //! Main constructor.
Standard_EXPORT AIS_LightSourceOwner(const Handle(AIS_LightSource)& theObject, Standard_EXPORT AIS_LightSourceOwner(const Handle(AIS_LightSource)& theObject,
Standard_Integer thePriority = 5); Standard_Integer thePriority = 5);
@ -290,18 +295,19 @@ public:
Standard_EXPORT virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint, Standard_EXPORT virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton, Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers, 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. //! Highlights selectable object's presentation with display mode in presentation manager with
//! Also a check for auto-highlight is performed - if selectable object manages highlighting on its own, //! given highlight style. Also a check for auto-highlight is performed - if selectable object
//! execution will be passed to SelectMgr_SelectableObject::HilightOwnerWithColor method. //! manages highlighting on its own, execution will be passed to
//! SelectMgr_SelectableObject::HilightOwnerWithColor method.
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Always update dynamic highlighting. //! Always update dynamic highlighting.
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
}; };
#endif // _AIS_LightSource_HeaderFile #endif // _AIS_LightSource_HeaderFile

View File

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

View File

@ -29,19 +29,22 @@ class AIS_Line : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject)
public: public:
//! Initializes the line aLine. //! Initializes the line aLine.
Standard_EXPORT AIS_Line(const Handle(Geom_Line)& aLine); Standard_EXPORT AIS_Line(const Handle(Geom_Line)& aLine);
//! Initializes a starting point aStartPoint //! Initializes a starting point aStartPoint
//! and a finishing point aEndPoint for the line. //! 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. //! Returns the signature 5.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 5; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 5; }
//! Returns the type Datum. //! 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. //! Constructs an infinite line.
const Handle(Geom_Line)& Line() const { return myComponent; } const Handle(Geom_Line)& Line() const { return myComponent; }
@ -83,7 +86,6 @@ public:
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
@ -102,12 +104,10 @@ private:
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect); void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private: private:
Handle(Geom_Line) myComponent; Handle(Geom_Line) myComponent;
Handle(Geom_Point) myStartPoint; Handle(Geom_Point) myStartPoint;
Handle(Geom_Point) myEndPoint; Handle(Geom_Point) myEndPoint;
Standard_Boolean myLineIsSegment; Standard_Boolean myLineIsSegment;
}; };
DEFINE_STANDARD_HANDLE(AIS_Line, AIS_InteractiveObject) 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 // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#ifndef AIS_ListIteratorOfListOfInteractive_HeaderFile #ifndef AIS_ListIteratorOfListOfInteractive_HeaderFile
#define AIS_ListIteratorOfListOfInteractive_HeaderFile #define AIS_ListIteratorOfListOfInteractive_HeaderFile

View File

@ -21,7 +21,7 @@
#include <NCollection_List.hxx> #include <NCollection_List.hxx>
typedef NCollection_List<Handle(AIS_InteractiveObject)> AIS_ListOfInteractive; 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 #endif

View File

@ -43,14 +43,16 @@ IMPLEMENT_HSEQUENCE(AIS_ManipulatorObjectSequence)
namespace namespace
{ {
//! Return Ax1 for specified direction of Ax2. //! Return Ax1 for specified direction of Ax2.
static gp_Ax1 getAx1FromAx2Dir (const gp_Ax2& theAx2, static gp_Ax1 getAx1FromAx2Dir(const gp_Ax2& theAx2, int theIndex)
int theIndex)
{ {
switch (theIndex) switch (theIndex)
{ {
case 0: return gp_Ax1 (theAx2.Location(), theAx2.XDirection()); case 0:
case 1: return gp_Ax1 (theAx2.Location(), theAx2.YDirection()); return gp_Ax1(theAx2.Location(), theAx2.XDirection());
case 2: return theAx2.Axis(); case 1:
return gp_Ax1(theAx2.Location(), theAx2.YDirection());
case 2:
return theAx2.Axis();
} }
throw Standard_ProgramError("AIS_Manipulator - Invalid axis index"); throw Standard_ProgramError("AIS_Manipulator - Invalid axis index");
} }
@ -60,7 +62,11 @@ namespace
{ {
public: public:
//! Main constructor. //! 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. //! Checks if picking ray can be used for detection.
Standard_Boolean isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const Standard_Boolean isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const
@ -73,6 +79,7 @@ namespace
const gp_Dir aRay = theMgr.GetViewRayDirection(); const gp_Dir aRay = theMgr.GetViewRayDirection();
return !aRay.IsNormal(myPlaneNormal, myAngleTol); return !aRay.IsNormal(myPlaneNormal, myAngleTol);
} }
private: private:
gp_Dir myPlaneNormal; gp_Dir myPlaneNormal;
Standard_Real myAngleTol; Standard_Real myAngleTol;
@ -83,17 +90,17 @@ namespace
{ {
public: public:
//! Main constructor. //! Main constructor.
ManipSensCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId, ManipSensCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId, const gp_Circ& theCircle)
const gp_Circ& theCircle)
: Select3D_SensitiveCircle(theOwnerId, theCircle, Standard_False), : Select3D_SensitiveCircle(theOwnerId, theCircle, Standard_False),
ManipSensRotation (theCircle.Position().Direction()) {} ManipSensRotation(theCircle.Position().Direction())
{
}
//! Checks whether the circle overlaps current selecting volume //! Checks whether the circle overlaps current selecting volume
virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr, virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
{ {
return isValidRay (theMgr) return isValidRay(theMgr) && Select3D_SensitiveCircle::Matches(theMgr, thePickResult);
&& Select3D_SensitiveCircle::Matches (theMgr, thePickResult);
} }
}; };
@ -105,25 +112,25 @@ namespace
const Handle(Poly_Triangulation)& theTrg, const Handle(Poly_Triangulation)& theTrg,
const gp_Dir& thePlaneNormal) const gp_Dir& thePlaneNormal)
: Select3D_SensitiveTriangulation(theOwnerId, theTrg, TopLoc_Location(), Standard_True), : Select3D_SensitiveTriangulation(theOwnerId, theTrg, TopLoc_Location(), Standard_True),
ManipSensRotation (thePlaneNormal) {} ManipSensRotation(thePlaneNormal)
{
}
//! Checks whether the circle overlaps current selecting volume //! Checks whether the circle overlaps current selecting volume
virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr, virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
{ {
return isValidRay (theMgr) return isValidRay(theMgr) && Select3D_SensitiveTriangulation::Matches(theMgr, thePickResult);
&& Select3D_SensitiveTriangulation::Matches (theMgr, thePickResult);
} }
}; };
} } // namespace
//=================================================================================================
//=======================================================================
//function : init
//purpose :
//=======================================================================
void AIS_Manipulator::init() 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[0] = Axis(gp::OX(), Quantity_NOC_RED);
myAxes[1] = Axis(gp::OY(), Quantity_NOC_GREEN); myAxes[1] = Axis(gp::OY(), Quantity_NOC_GREEN);
myAxes[2] = Axis(gp::OZ(), Quantity_NOC_BLUE1); myAxes[2] = Axis(gp::OZ(), Quantity_NOC_BLUE1);
@ -165,11 +172,10 @@ void AIS_Manipulator::init()
SetZLayer(Graphic3d_ZLayerId_Topmost); 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(Prs3d_Presentation) aDummyPrs;
Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast(theOwner); Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast(theOwner);
@ -180,21 +186,25 @@ Handle(Prs3d_Presentation) AIS_Manipulator::getHighlightPresentation (const Hand
switch (anOwner->Mode()) switch (anOwner->Mode())
{ {
case AIS_MM_Translation : return myAxes[anOwner->Index()].TranslatorHighlightPrs(); case AIS_MM_Translation:
case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs(); return myAxes[anOwner->Index()].TranslatorHighlightPrs();
case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs(); case AIS_MM_Rotation:
case AIS_MM_TranslationPlane: return myAxes[anOwner->Index()].DraggerHighlightPrs(); return myAxes[anOwner->Index()].RotatorHighlightPrs();
case AIS_MM_None : break; 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; 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; Handle(Graphic3d_Group) aDummyGroup;
@ -205,20 +215,23 @@ Handle(Graphic3d_Group) AIS_Manipulator::getGroup (const Standard_Integer theInd
switch (theMode) switch (theMode)
{ {
case AIS_MM_Translation : return myAxes[theIndex].TranslatorGroup(); case AIS_MM_Translation:
case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup(); return myAxes[theIndex].TranslatorGroup();
case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup(); case AIS_MM_Rotation:
case AIS_MM_TranslationPlane: return myAxes[theIndex].DraggerGroup(); return myAxes[theIndex].RotatorGroup();
case AIS_MM_None : break; case AIS_MM_Scaling:
return myAxes[theIndex].ScalerGroup();
case AIS_MM_TranslationPlane:
return myAxes[theIndex].DraggerGroup();
case AIS_MM_None:
break;
} }
return aDummyGroup; return aDummyGroup;
} }
//======================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_Manipulator::AIS_Manipulator() AIS_Manipulator::AIS_Manipulator()
: myPosition(gp::XOY()), : myPosition(gp::XOY()),
myCurrentIndex(-1), myCurrentIndex(-1),
@ -236,10 +249,8 @@ AIS_Manipulator::AIS_Manipulator()
init(); init();
} }
//======================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_Manipulator::AIS_Manipulator(const gp_Ax2& thePosition) AIS_Manipulator::AIS_Manipulator(const gp_Ax2& thePosition)
: myPosition(thePosition), : myPosition(thePosition),
myCurrentIndex(-1), myCurrentIndex(-1),
@ -257,13 +268,15 @@ AIS_Manipulator::AIS_Manipulator (const gp_Ax2& thePosition)
init(); init();
} }
//======================================================================= //=================================================================================================
//function : SetPart
//purpose : void AIS_Manipulator::SetPart(const Standard_Integer theAxisIndex,
//======================================================================= const AIS_ManipulatorMode theMode,
void AIS_Manipulator::SetPart (const Standard_Integer theAxisIndex, const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled) 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) switch (theMode)
{ {
case AIS_MM_Translation: 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) 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) void AIS_Manipulator::EnableMode(const AIS_ManipulatorMode theMode)
{ {
if (!IsAttached()) if (!IsAttached())
@ -319,10 +329,8 @@ void AIS_Manipulator::EnableMode (const AIS_ManipulatorMode theMode)
aContext->Activate(this, theMode); aContext->Activate(this, theMode);
} }
//======================================================================= //=================================================================================================
//function : attachToBox
//purpose :
//=======================================================================
void AIS_Manipulator::attachToBox(const Bnd_Box& theBox) void AIS_Manipulator::attachToBox(const Bnd_Box& theBox)
{ {
if (theBox.IsVoid()) if (theBox.IsVoid())
@ -334,14 +342,13 @@ void AIS_Manipulator::attachToBox (const Bnd_Box& theBox)
theBox.Get(anXmin, anYmin, aZmin, anXmax, anYmax, aZmax); theBox.Get(anXmin, anYmin, aZmin, anXmax, anYmax, aZmax);
gp_Ax2 aPosition = gp::XOY(); 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); SetPosition(aPosition);
} }
//======================================================================= //=================================================================================================
//function : adjustSize
//purpose :
//=======================================================================
void AIS_Manipulator::adjustSize(const Bnd_Box& theBox) void AIS_Manipulator::adjustSize(const Bnd_Box& theBox)
{ {
Standard_Real aXmin = 0., aYmin = 0., aZmin = 0., aXmax = 0., aYmax = 0., aZmax = 0.0; 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)); 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))) if (theObject->IsKind(STANDARD_TYPE(AIS_Manipulator)))
{ {
@ -369,11 +375,10 @@ void AIS_Manipulator::Attach (const Handle(AIS_InteractiveObject)& theObject, co
Attach(aSeq, theOptions); 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) if (theObjects->Size() < 1)
{ {
@ -420,10 +425,8 @@ void AIS_Manipulator::Attach (const Handle(AIS_ManipulatorObjectSequence)& theOb
} }
} }
//======================================================================= //=================================================================================================
//function : Detach
//purpose :
//=======================================================================
void AIS_Manipulator::Detach() void AIS_Manipulator::Detach()
{ {
DeactivateCurrentMode(); DeactivateCurrentMode();
@ -443,24 +446,22 @@ void AIS_Manipulator::Detach()
SetOwner(NULL); SetOwner(NULL);
} }
//======================================================================= //=================================================================================================
//function : Objects
//purpose :
//=======================================================================
Handle(AIS_ManipulatorObjectSequence) AIS_Manipulator::Objects() const Handle(AIS_ManipulatorObjectSequence) AIS_Manipulator::Objects() const
{ {
return Handle(AIS_ManipulatorObjectSequence)::DownCast(GetOwner()); return Handle(AIS_ManipulatorObjectSequence)::DownCast(GetOwner());
} }
//======================================================================= //=================================================================================================
//function : Object
//purpose :
//=======================================================================
Handle(AIS_InteractiveObject) AIS_Manipulator::Object(const Standard_Integer theIndex) const 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()) if (anOwner.IsNull() || anOwner->IsEmpty())
{ {
@ -470,28 +471,27 @@ Handle(AIS_InteractiveObject) AIS_Manipulator::Object (const Standard_Integer th
return anOwner->Value(theIndex); return anOwner->Value(theIndex);
} }
//======================================================================= //=================================================================================================
//function : Object
//purpose :
//=======================================================================
Handle(AIS_InteractiveObject) AIS_Manipulator::Object() const Handle(AIS_InteractiveObject) AIS_Manipulator::Object() const
{ {
return Object(1); return Object(1);
} }
//======================================================================= //=================================================================================================
//function : ObjectTransformation
//purpose : Standard_Boolean AIS_Manipulator::ObjectTransformation(const Standard_Integer theMaxX,
//======================================================================= const Standard_Integer theMaxY,
Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer theMaxX, const Standard_Integer theMaxY, const Handle(V3d_View)& theView,
const Handle(V3d_View)& theView, gp_Trsf& theTrsf) gp_Trsf& theTrsf)
{ {
// Initialize start reference data // Initialize start reference data
if (!myHasStartedTransformation) if (!myHasStartedTransformation)
{ {
myStartTrsfs.Clear(); myStartTrsfs.Clear();
Handle(AIS_ManipulatorObjectSequence) anObjects = Objects(); 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()); myStartTrsfs.Append(anObjIter.Value()->LocalTransformation());
} }
@ -500,18 +500,23 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
// Get 3d point with projection vector // Get 3d point with projection vector
Graphic3d_Vec3d anInputPoint, aProj; Graphic3d_Vec3d anInputPoint, aProj;
theView->ConvertWithProj (theMaxX, theMaxY, anInputPoint.x(), anInputPoint.y(), anInputPoint.z(), aProj.x(), aProj.y(), aProj.z()); theView->ConvertWithProj(theMaxX,
const gp_Lin anInputLine (gp_Pnt (anInputPoint.x(), anInputPoint.y(), anInputPoint.z()), gp_Dir (aProj.x(), aProj.y(), aProj.z())); 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) switch (myCurrentMode)
{ {
case AIS_MM_Translation: case AIS_MM_Translation:
case AIS_MM_Scaling: case AIS_MM_Scaling: {
{
const gp_Lin aLine(myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction()); const gp_Lin aLine(myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction());
Extrema_ExtElC anExtrema(anInputLine, aLine, Precision::Angular()); Extrema_ExtElC anExtrema(anInputLine, aLine, Precision::Angular());
if (!anExtrema.IsDone() if (!anExtrema.IsDone() || anExtrema.IsParallel() || anExtrema.NbExt() != 1)
|| anExtrema.IsParallel()
|| anExtrema.NbExt() != 1)
{ {
// translation cannot be done co-directed with camera // translation cannot be done co-directed with camera
return Standard_False; return Standard_False;
@ -551,14 +556,14 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
} }
return Standard_True; return Standard_True;
} }
case AIS_MM_Rotation: case AIS_MM_Rotation: {
{
const gp_Pnt aPosLoc = myStartPosition.Location(); const gp_Pnt aPosLoc = myStartPosition.Location();
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex); const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex);
IntAna_IntConicQuad aIntersector (anInputLine, gp_Pln (aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection()); IntAna_IntConicQuad aIntersector(anInputLine,
if (!aIntersector.IsDone() gp_Pln(aPosLoc, aCurrAxis.Direction()),
|| aIntersector.IsParallel() Precision::Angular(),
|| aIntersector.NbPoints() < 1) Precision::Intersection());
if (!aIntersector.IsDone() || aIntersector.IsParallel() || aIntersector.NbPoints() < 1)
{ {
return Standard_False; return Standard_False;
} }
@ -569,7 +574,8 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
myStartPick = aNewPosition; myStartPick = aNewPosition;
myHasStartedTransformation = Standard_True; myHasStartedTransformation = Standard_True;
gp_Dir aStartAxis = gce_MakeDir(aPosLoc, myStartPick); 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; return Standard_True;
} }
@ -578,7 +584,8 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
return Standard_False; 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() ? getAx1FromAx2Dir(myStartPosition, (myCurrentIndex + 1) % 3).Direction()
: gce_MakeDir(aPosLoc, myStartPick); : gce_MakeDir(aPosLoc, myStartPick);
@ -603,11 +610,13 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
myPrevState = anAngle; myPrevState = anAngle;
return Standard_True; return Standard_True;
} }
case AIS_MM_TranslationPlane: case AIS_MM_TranslationPlane: {
{
const gp_Pnt aPosLoc = myStartPosition.Location(); const gp_Pnt aPosLoc = myStartPosition.Location();
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex); 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) if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
{ {
return Standard_False; return Standard_False;
@ -631,18 +640,15 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
theTrsf *= aNewTrsf; theTrsf *= aNewTrsf;
return Standard_True; return Standard_True;
} }
case AIS_MM_None: case AIS_MM_None: {
{
return Standard_False; return Standard_False;
} }
} }
return Standard_False; return Standard_False;
} }
//======================================================================= //=================================================================================================
//function : ProcessDragging
//purpose :
//=======================================================================
Standard_Boolean AIS_Manipulator::ProcessDragging(const Handle(AIS_InteractiveContext)& aCtx, Standard_Boolean AIS_Manipulator::ProcessDragging(const Handle(AIS_InteractiveContext)& aCtx,
const Handle(V3d_View)& theView, const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)&, const Handle(SelectMgr_EntityOwner)&,
@ -652,8 +658,7 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
{ {
switch (theAction) switch (theAction)
{ {
case AIS_DragAction_Start: case AIS_DragAction_Start: {
{
if (HasActiveMode()) if (HasActiveMode())
{ {
StartTransform(theDragFrom.x(), theDragFrom.y(), theView); StartTransform(theDragFrom.x(), theDragFrom.y(), theView);
@ -661,22 +666,18 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
} }
break; break;
} }
case AIS_DragAction_Confirmed: case AIS_DragAction_Confirmed: {
{
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Update: case AIS_DragAction_Update: {
{
Transform(theDragTo.x(), theDragTo.y(), theView); Transform(theDragTo.x(), theDragTo.y(), theView);
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Abort: case AIS_DragAction_Abort: {
{
StopTransform(false); StopTransform(false);
return Standard_True; return Standard_True;
} }
case AIS_DragAction_Stop: case AIS_DragAction_Stop: {
{
// at the end of transformation redisplay for updating sensitive areas // at the end of transformation redisplay for updating sensitive areas
StopTransform(true); StopTransform(true);
if (aCtx->IsDisplayed(this)) if (aCtx->IsDisplayed(this))
@ -690,11 +691,11 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
return Standard_False; return Standard_False;
} }
//======================================================================= //=================================================================================================
//function : StartTransform
//purpose : void AIS_Manipulator::StartTransform(const Standard_Integer theX,
//======================================================================= const Standard_Integer theY,
void AIS_Manipulator::StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView) const Handle(V3d_View)& theView)
{ {
if (myHasStartedTransformation) if (myHasStartedTransformation)
{ {
@ -705,10 +706,8 @@ void AIS_Manipulator::StartTransform (const Standard_Integer theX, const Standar
ObjectTransformation(theX, theY, theView, aTrsf); ObjectTransformation(theX, theY, theView, aTrsf);
} }
//======================================================================= //=================================================================================================
//function : StopTransform
//purpose :
//=======================================================================
void AIS_Manipulator::StopTransform(const Standard_Boolean theToApply) void AIS_Manipulator::StopTransform(const Standard_Boolean theToApply)
{ {
if (!IsAttached() || !myHasStartedTransformation) if (!IsAttached() || !myHasStartedTransformation)
@ -732,10 +731,8 @@ void AIS_Manipulator::StopTransform (const Standard_Boolean theToApply)
SetPosition(myStartPosition); SetPosition(myStartPosition);
} }
//======================================================================= //=================================================================================================
//function : Transform
//purpose :
//=======================================================================
void AIS_Manipulator::Transform(const gp_Trsf& theTrsf) void AIS_Manipulator::Transform(const gp_Trsf& theTrsf)
{ {
if (!IsAttached() || !myHasStartedTransformation) if (!IsAttached() || !myHasStartedTransformation)
@ -752,11 +749,11 @@ void AIS_Manipulator::Transform (const gp_Trsf& theTrsf)
const Handle(AIS_InteractiveObject)& anObj = anObjIter.ChangeValue(); const Handle(AIS_InteractiveObject)& anObj = anObjIter.ChangeValue();
const gp_Trsf& anOldTrsf = aTrsfIter.Value(); const gp_Trsf& anOldTrsf = aTrsfIter.Value();
const Handle(TopLoc_Datum3D)& aParentTrsf = anObj->CombinedParentTransformation(); const Handle(TopLoc_Datum3D)& aParentTrsf = anObj->CombinedParentTransformation();
if (!aParentTrsf.IsNull() if (!aParentTrsf.IsNull() && aParentTrsf->Form() != gp_Identity)
&& aParentTrsf->Form() != gp_Identity)
{ {
// recompute local transformation relative to parent transformation // 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); anObj->SetLocalTransformation(aNewLocalTrsf);
} }
else 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) const Handle(V3d_View)& theView)
{ {
gp_Trsf aTrsf; gp_Trsf aTrsf;
@ -793,10 +789,8 @@ gp_Trsf AIS_Manipulator::Transform (const Standard_Integer thePX, const Standard
return aTrsf; return aTrsf;
} }
//======================================================================= //=================================================================================================
//function : SetPosition
//purpose :
//=======================================================================
void AIS_Manipulator::SetPosition(const gp_Ax2& thePosition) void AIS_Manipulator::SetPosition(const gp_Ax2& thePosition)
{ {
if (!myPosition.Location().IsEqual(thePosition.Location(), Precision::Confusion()) if (!myPosition.Location().IsEqual(thePosition.Location(), Precision::Confusion())
@ -846,7 +840,8 @@ void AIS_Manipulator::updateTransformation()
|| TransformPersistence()->Mode() != Graphic3d_TMF_AxialZoomPers || TransformPersistence()->Mode() != Graphic3d_TMF_AxialZoomPers
|| !TransformPersistence()->AnchorPoint().IsEqual(myPosition.Location(), 0.0)) || !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 else
@ -854,15 +849,14 @@ void AIS_Manipulator::updateTransformation()
if (TransformPersistence().IsNull() if (TransformPersistence().IsNull()
|| TransformPersistence()->Mode() != Graphic3d_TMF_AxialScalePers) || 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) void AIS_Manipulator::SetSize(const Standard_ShortReal theSideLength)
{ {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
@ -873,10 +867,8 @@ void AIS_Manipulator::SetSize (const Standard_ShortReal theSideLength)
SetToUpdate(); SetToUpdate();
} }
//======================================================================= //=================================================================================================
//function : SetGap
//purpose :
//=======================================================================
void AIS_Manipulator::SetGap(const Standard_ShortReal theValue) void AIS_Manipulator::SetGap(const Standard_ShortReal theValue)
{ {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
@ -887,10 +879,8 @@ void AIS_Manipulator::SetGap (const Standard_ShortReal theValue)
SetToUpdate(); SetToUpdate();
} }
//======================================================================= //=================================================================================================
//function : DeactivateCurrentMode
//purpose :
//=======================================================================
void AIS_Manipulator::DeactivateCurrentMode() void AIS_Manipulator::DeactivateCurrentMode()
{ {
if (!myIsActivationOnDetection) if (!myIsActivationOnDetection)
@ -924,10 +914,8 @@ void AIS_Manipulator::DeactivateCurrentMode()
} }
} }
//======================================================================= //=================================================================================================
//function : SetZoomPersistence
//purpose :
//=======================================================================
void AIS_Manipulator::SetZoomPersistence(const Standard_Boolean theToEnable) void AIS_Manipulator::SetZoomPersistence(const Standard_Boolean theToEnable)
{ {
if (myIsZoomPersistentMode != theToEnable) if (myIsZoomPersistentMode != theToEnable)
@ -945,10 +933,8 @@ void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
updateTransformation(); updateTransformation();
} }
//======================================================================= //=================================================================================================
//function : SetTransformPersistence
//purpose :
//=======================================================================
void AIS_Manipulator::SetTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers) void AIS_Manipulator::SetTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
{ {
Standard_ASSERT_RETURN(!myIsZoomPersistentMode, Standard_ASSERT_RETURN(!myIsZoomPersistentMode,
@ -958,10 +944,8 @@ void AIS_Manipulator::SetTransformPersistence (const Handle(Graphic3d_TransformP
setTransformPersistence(theTrsfPers); setTransformPersistence(theTrsfPers);
} }
//======================================================================= //=================================================================================================
//function : setTransformPersistence
//purpose :
//=======================================================================
void AIS_Manipulator::setTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers) void AIS_Manipulator::setTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
{ {
AIS_InteractiveObject::SetTransformPersistence(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*/) void AIS_Manipulator::setLocalTransformation(const Handle(TopLoc_Datum3D)& /*theTrsf*/)
{ {
Standard_ASSERT_INVOKE("AIS_Manipulator::setLocalTransformation: " Standard_ASSERT_INVOKE("AIS_Manipulator::setLocalTransformation: "
"Custom transformation is not supported by this class"); "Custom transformation is not supported by this class");
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Manipulator::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, void AIS_Manipulator::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -1014,7 +994,8 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager)& thePrsM
// Display axes // Display axes
aGroup = thePrs->NewGroup(); 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()); anAspectAx->SetColor(myAxes[anIt].Color());
aGroup->SetGroupPrimitivesAspect(anAspectAx->Aspect()); aGroup->SetGroupPrimitivesAspect(anAspectAx->Aspect());
myAxes[anIt].Compute(thePrsMgr, thePrs, anAspectAx); myAxes[anIt].Compute(thePrsMgr, thePrs, anAspectAx);
@ -1024,10 +1005,8 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager)& thePrsM
updateTransformation(); updateTransformation();
} }
//======================================================================= //=================================================================================================
//function : HilightSelected
//purpose :
//=======================================================================
void AIS_Manipulator::HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM, void AIS_Manipulator::HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theSeq) const SelectMgr_SequenceOfOwner& theSeq)
{ {
@ -1067,19 +1046,15 @@ void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager)&
myCurrentMode = anOwner->Mode(); myCurrentMode = anOwner->Mode();
} }
//======================================================================= //=================================================================================================
//function : ClearSelected
//purpose :
//=======================================================================
void AIS_Manipulator::ClearSelected() void AIS_Manipulator::ClearSelected()
{ {
DeactivateCurrentMode(); DeactivateCurrentMode();
} }
//======================================================================= //=================================================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
void AIS_Manipulator::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePM, void AIS_Manipulator::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) const Handle(SelectMgr_EntityOwner)& theOwner)
@ -1105,8 +1080,8 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
aPresentation->Highlight(theStyle); aPresentation->Highlight(theStyle);
} }
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups()); for (Graphic3d_SequenceOfGroup::Iterator aGroupIter(aPresentation->Groups()); aGroupIter.More();
aGroupIter.More(); aGroupIter.Next()) aGroupIter.Next())
{ {
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue(); Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
if (!aGrp.IsNull()) 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, void AIS_Manipulator::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
@ -1155,8 +1128,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
switch (aMode) switch (aMode)
{ {
case AIS_MM_Translation: case AIS_MM_Translation: {
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{ {
if (!myAxes[anIt].HasTranslation()) 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); anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Translation, 9);
// define sensitivity by line // 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); aLine->SetSensitivityFactor(aHighSensitivity);
theSelection->Add(aLine); theSelection->Add(aLine);
// enlarge sensitivity by triangulation // enlarge sensitivity by triangulation
Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray(anOwner); Handle(Select3D_SensitivePrimitiveArray) aTri =
aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location()); new Select3D_SensitivePrimitiveArray(anOwner);
aTri->InitTriangulation(anAxis.TriangleArray()->Attributes(),
anAxis.TriangleArray()->Indices(),
TopLoc_Location());
theSelection->Add(aTri); theSelection->Add(aTri);
} }
break; break;
} }
case AIS_MM_Rotation: case AIS_MM_Rotation: {
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{ {
if (!myAxes[anIt].HasRotation()) 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); anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Rotation, 9);
// define sensitivity by circle // 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); Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle(anOwner, aGeomCircle);
aCircle->SetSensitivityFactor(aLowSensitivity); aCircle->SetSensitivityFactor(aLowSensitivity);
theSelection->Add(aCircle); theSelection->Add(aCircle);
// enlarge sensitivity by triangulation // 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); theSelection->Add(aTri);
} }
break; break;
} }
case AIS_MM_Scaling: case AIS_MM_Scaling: {
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{ {
if (!myAxes[anIt].HasScaling()) 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); anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Scaling, 9);
// define sensitivity by point // 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); aPnt->SetSensitivityFactor(aHighSensitivity);
theSelection->Add(aPnt); theSelection->Add(aPnt);
// enlarge sensitivity by triangulation // 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); theSelection->Add(aTri);
} }
break; break;
} }
case AIS_MM_TranslationPlane: case AIS_MM_TranslationPlane: {
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{ {
if (!myAxes[anIt].HasDragging()) 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); anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
// define sensitivity by two crossed lines // define sensitivity by two crossed lines
Standard_Real aSensitivityOffset = ZoomPersistence() ? aHighSensitivity * (0.5 + M_SQRT2) : 0.0; Standard_Real aSensitivityOffset =
gp_Pnt aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition().Translated (myAxes[((anIt + 2) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset); ZoomPersistence() ? aHighSensitivity * (0.5 + M_SQRT2) : 0.0;
gp_Pnt aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition().Translated (myAxes[((anIt + 1) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset); 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 aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
gp_XYZ anOrig = aMidP.Normalized().Multiplied(aSensitivityOffset); gp_XYZ anOrig = aMidP.Normalized().Multiplied(aSensitivityOffset);
Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2); Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
aLine1->SetSensitivityFactor(aLowSensitivity); aLine1->SetSensitivityFactor(aLowSensitivity);
theSelection->Add(aLine1); 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); aLine2->SetSensitivityFactor(aLowSensitivity);
theSelection->Add(aLine2); theSelection->Add(aLine2);
// enlarge sensitivity by triangulation // 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); theSelection->Add(aTri);
} }
break; break;
} }
default: default: {
{
anOwner = new SelectMgr_EntityOwner(this, 5); anOwner = new SelectMgr_EntityOwner(this, 5);
break; break;
} }
@ -1316,14 +1305,18 @@ void AIS_Manipulator::Cube::Init (const gp_Ax1& thePosition, const Standard_Shor
myTriangulation = new Poly_Triangulation(aPoints, aPolyTriangles); myTriangulation = new Poly_Triangulation(aPoints, aPolyTriangles);
gp_Ax2 aPln(thePosition.Location(), thePosition.Direction()); 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 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 aV4 = aBottomLeft.XYZ() + aPln.XDirection().XYZ() * theSize;
gp_Pnt aTopRight = thePosition.Location().XYZ() + thePosition.Direction().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 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_Pnt aV7 = aTopRight.XYZ() - aPln.XDirection().XYZ() * theSize;
gp_Dir aRight((gp_Vec(aTopRight, aV7) ^ gp_Vec(aTopRight, aV2)).XYZ()); 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 : // purpose :
//======================================================================= //=======================================================================
void AIS_Manipulator::Cube::addTriangle(const Standard_Integer theIndex, 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) const gp_Dir& theNormal)
{ {
myTriangulation->SetNode(theIndex * 3 + 1, theP1); myTriangulation->SetNode(theIndex * 3 + 1, theP1);
myTriangulation->SetNode(theIndex * 3 + 2, theP2); myTriangulation->SetNode(theIndex * 3 + 2, theP2);
myTriangulation->SetNode(theIndex * 3 + 3, theP3); 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(theP1, theNormal);
myArray->AddVertex(theP2, theNormal); myArray->AddVertex(theP2, theNormal);
myArray->AddVertex(theP3, 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 anArrowLength = 0.25 * myLength;
const Standard_Real aCylinderLength = myLength - anArrowLength; 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()), myTriangleArray = Prs3d_Arrow::DrawShaded(gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
myAxisRadius, myAxisRadius,
@ -1489,7 +1486,10 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
if (myHasRotation) if (myHasRotation)
{ {
myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f; 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 = thePrs->NewGroup();
myRotatorGroup->SetGroupPrimitivesAspect(theAspect->Aspect()); myRotatorGroup->SetGroupPrimitivesAspect(theAspect->Aspect());
myRotatorGroup->AddPrimitiveArray(myCircle.Array()); myRotatorGroup->AddPrimitiveArray(myCircle.Array());
@ -1519,7 +1519,10 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
else else
aXDirection = gp::DX(); 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(); myDraggerGroup = thePrs->NewGroup();
Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d(); 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 class AIS_Manipulator : public AIS_InteractiveObject
{ {
public: public:
//! Constructs a manipulator object with default placement and all parts to be displayed. //! Constructs a manipulator object with default placement and all parts to be displayed.
Standard_EXPORT AIS_Manipulator(); 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); Standard_EXPORT AIS_Manipulator(const gp_Ax2& thePosition);
//! Disable or enable visual parts for translation, rotation or scaling for some axis. //! Disable or enable visual parts for translation, rotation or scaling for some axis.
//! By default all parts are enabled (will be displayed). //! 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. //! @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. //! Disable or enable visual parts for translation, rotation or scaling for ALL axes.
//! By default all parts are enabled (will be displayed). //! 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. //! @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: //! Behavior settings to be applied when performing transformation:
//! - FollowTranslation - whether the manipulator will be moved together with an object. //! - FollowTranslation - whether the manipulator will be moved together with an object.
//! - FollowRotation - whether the manipulator will be rotated 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()
OptionsForAttach& SetAdjustPosition (const Standard_Boolean theApply) { AdjustPosition = theApply; return *this; } : AdjustPosition(Standard_True),
OptionsForAttach& SetAdjustSize (const Standard_Boolean theApply) { AdjustSize = theApply; return *this; } AdjustSize(Standard_False),
OptionsForAttach& SetEnableModes (const Standard_Boolean theApply) { EnableModes = theApply; return *this; } 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 AdjustPosition;
Standard_Boolean AdjustSize; Standard_Boolean AdjustSize;
@ -128,13 +154,17 @@ public:
}; };
//! Attaches himself to the input interactive object and become displayed in the same context. //! 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. //! It is placed in the center of object bounding box, and its size is adjusted to the object
Standard_EXPORT void Attach (const Handle(AIS_InteractiveObject)& theObject, const OptionsForAttach& theOptions = OptionsForAttach()); //! 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. //! Attaches himself to the input interactive object group and become displayed in the same
//! It become attached to the first object, baut manage manipulation of the whole group. //! 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. //! It is placed in the center of object bounding box, and its size is adjusted to the object
Standard_EXPORT void Attach (const Handle(AIS_ManipulatorObjectSequence)& theObject, const OptionsForAttach& theOptions = OptionsForAttach()); //! bounding box.
Standard_EXPORT void Attach(const Handle(AIS_ManipulatorObjectSequence)& theObject,
const OptionsForAttach& theOptions = OptionsForAttach());
//! Enable manipualtion mode. //! Enable manipualtion mode.
//! @warning It activates selection mode in the current context. //! @warning It activates selection mode in the current context.
@ -150,10 +180,7 @@ public:
} }
//! @return true if manual mode activation is enabled. //! @return true if manual mode activation is enabled.
Standard_Boolean IsModeActivationOnDetection() const Standard_Boolean IsModeActivationOnDetection() const { return myIsActivationOnDetection; }
{
return myIsActivationOnDetection;
}
public: public:
//! Drag object in the viewer. //! Drag object in the viewer.
@ -164,7 +191,8 @@ public:
//! @param[in] theDragTo drag end point //! @param[in] theDragTo drag end point
//! @param[in] theAction drag action //! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start) //! @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(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom, const Graphic3d_Vec2i& theDragFrom,
@ -173,9 +201,12 @@ public:
//! Init start (reference) transformation. //! Init start (reference) transformation.
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform //! @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, //! and is used only for custom transform set. If Transform(const Standard_Integer, const
//! initial data is set automatically, and it is reset on DeactivateCurrentMode call if it is not reset yet. //! Standard_Integer) is used, initial data is set automatically, and it is reset on
Standard_EXPORT void StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView); //! 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. //! Apply to the owning objects the input transformation.
//! @remark The transformation is set using SetLocalTransformation for owning objects. //! @remark The transformation is set using SetLocalTransformation for owning objects.
@ -195,18 +226,21 @@ public:
//! Apply transformation made from mouse moving from start position //! Apply transformation made from mouse moving from start position
//! (save on the first Transform() call and reset on DeactivateCurrentMode() call.) //! (save on the first Transform() call and reset on DeactivateCurrentMode() call.)
//! to the in/out mouse position (theX, theY) //! 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); const Handle(V3d_View)& theView);
//! Computes transformation of parent object according to the active mode and input motion vector. //! 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 //! You can use this method to get object transformation according to current mode or use own
//! to implement any other transformation for modes. //! algorithm to implement any other transformation for modes.
//! @return transformation of parent object. //! @return transformation of parent object.
Standard_EXPORT Standard_Boolean ObjectTransformation (const Standard_Integer theX, const Standard_Integer theY, Standard_EXPORT Standard_Boolean ObjectTransformation(const Standard_Integer theX,
const Handle(V3d_View)& theView, gp_Trsf& theTrsf); 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. //! Make inactive the current selected manipulator part and reset current axis index and current
//! After its call HasActiveMode() returns false. //! mode. After its call HasActiveMode() returns false.
//! @sa HasActiveMode() //! @sa HasActiveMode()
Standard_EXPORT void DeactivateCurrentMode(); Standard_EXPORT void DeactivateCurrentMode();
@ -226,22 +260,26 @@ public:
//! @return true if manipulator is attached to some interactive object (has owning object). //! @return true if manipulator is attached to some interactive object (has owning object).
Standard_Boolean IsAttached() const { return HasOwner(); } 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 HasActiveMode() const { return IsAttached() && myCurrentMode != AIS_MM_None; }
Standard_Boolean HasActiveTransformation() { return myHasStartedTransformation; } 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 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"); "AIS_Manipulator::StartTransformation(): theIndex is out of bounds");
return !myStartTrsfs.IsEmpty() ? myStartTrsfs(theIndex) : gp_Trsf(); return !myStartTrsfs.IsEmpty() ? myStartTrsfs(theIndex) : gp_Trsf();
} }
public: //! @name Configuration of graphical transformations public: //! @name Configuration of graphical transformations
//! Enable or disable zoom persistence mode for the manipulator. With //! Enable or disable zoom persistence mode for the manipulator. With
//! this mode turned on the presentation will keep fixed screen size. //! this mode turned on the presentation will keep fixed screen size.
//! @warning when turned on this option overrides transform persistence //! @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. //! Returns state of zoom persistence mode, whether it turned on or off.
Standard_Boolean ZoomPersistence() const { return myIsZoomPersistentMode; } 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 //! @warning this interactive object does not support custom transformation persistence when
//! using \sa ZoomPersistence mode. In this mode the transformation persistence flags for //! using \sa ZoomPersistence mode. In this mode the transformation persistence flags for
//! presentations are overridden by this class. //! presentations are overridden by this class.
//! @warning Invokes debug assertion to catch incompatible usage of the method with \sa ZoomPersistence mode, //! @warning Invokes debug assertion to catch incompatible usage of the method with \sa
//! silently does nothing in release mode. //! ZoomPersistence mode, silently does nothing in release mode.
//! @warning revise use of AdjustSize argument of of \sa AttachToObjects method //! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
//! when enabling zoom persistence. //! 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 public: //! @name Setters for parameters
AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; } AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; }
Standard_Integer ActiveAxisIndex() const { return myCurrentIndex; } Standard_Integer ActiveAxisIndex() const { return myCurrentIndex; }
@ -284,16 +323,36 @@ public: //! @name Setters for parameters
Standard_EXPORT void SetGap(const Standard_ShortReal theValue); Standard_EXPORT void SetGap(const Standard_ShortReal theValue);
public: public:
//! Behavior settings to be applied when performing transformation: //! Behavior settings to be applied when performing transformation:
//! - FollowTranslation - whether the manipulator will be moved together with an object. //! - FollowTranslation - whether the manipulator will be moved together with an object.
//! - FollowRotation - whether the manipulator will be rotated 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()
BehaviorOnTransform& SetFollowTranslation (const Standard_Boolean theApply) { FollowTranslation = theApply; return *this; } : FollowTranslation(Standard_True),
BehaviorOnTransform& SetFollowRotation (const Standard_Boolean theApply) { FollowRotation = theApply; return *this; } FollowRotation(Standard_True),
BehaviorOnTransform& SetFollowDragging (const Standard_Boolean theApply) { FollowDragging = theApply; return *this; } 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 FollowTranslation;
Standard_Boolean FollowRotation; Standard_Boolean FollowRotation;
@ -302,7 +361,10 @@ public:
//! Sets behavior settings for transformation action carried on the manipulator, //! Sets behavior settings for transformation action carried on the manipulator,
//! whether it translates, rotates together with the transformed object or not. //! 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. //! @return behavior settings for transformation action of the manipulator.
BehaviorOnTransform& ChangeTransformBehavior() { return myBehaviorOnTransform; } BehaviorOnTransform& ChangeTransformBehavior() { return myBehaviorOnTransform; }
@ -311,9 +373,9 @@ public:
const BehaviorOnTransform& TransformBehavior() const { return myBehaviorOnTransform; } const BehaviorOnTransform& TransformBehavior() const { return myBehaviorOnTransform; }
public: //! @name Presentation computation public: //! @name Presentation computation
//! Fills presentation. //! 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, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode = 0) Standard_OVERRIDE; 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, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE; 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
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE //! methods.
{ virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
return Standard_False;
}
//! Method which clear all selected owners belonging //! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw ). //! to this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
//! Method which draws selected owners ( for fast presentation draw ). //! 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 //! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw ). //! 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(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
protected: protected:
Standard_EXPORT void init(); Standard_EXPORT void init();
Standard_EXPORT void updateTransformation(); 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); Standard_EXPORT void attachToBox(const Bnd_Box& theBox);
@ -364,28 +428,25 @@ protected:
//! without need for recomputing presentation. //! without need for recomputing presentation.
//! @warning Invokes debug assertion in debug to catch incompatible usage of the //! @warning Invokes debug assertion in debug to catch incompatible usage of the
//! method, silently does nothing in release mode. //! 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 using AIS_InteractiveObject::SetLocalTransformation; // hide visibility
protected: //! @name Auxiliary classes to fill presentation with proper primitives protected: //! @name Auxiliary classes to fill presentation with proper primitives
class Quadric class Quadric
{ {
public: public:
virtual ~Quadric() virtual ~Quadric()
{ {
myTriangulation.Nullify(); myTriangulation.Nullify();
myArray.Nullify(); myArray.Nullify();
} }
const Handle(Poly_Triangulation)& Triangulation() const { return myTriangulation; } const Handle(Poly_Triangulation)& Triangulation() const { return myTriangulation; }
const Handle(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; } const Handle(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; }
protected: protected:
Handle(Poly_Triangulation) myTriangulation; Handle(Poly_Triangulation) myTriangulation;
Handle(Graphic3d_ArrayOfTriangles) myArray; Handle(Graphic3d_ArrayOfTriangles) myArray;
}; };
@ -393,12 +454,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Disk : public Quadric class Disk : public Quadric
{ {
public: public:
Disk() Disk()
: Quadric(), : Quadric(),
myInnerRad(0.0f), myInnerRad(0.0f),
myOuterRad(1.0f) myOuterRad(1.0f)
{ } {
}
~Disk() {} ~Disk() {}
@ -409,7 +470,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Standard_Integer theStacksNb = 20); const Standard_Integer theStacksNb = 20);
protected: protected:
gp_Ax1 myPosition; gp_Ax1 myPosition;
Standard_ShortReal myInnerRad; Standard_ShortReal myInnerRad;
Standard_ShortReal myOuterRad; Standard_ShortReal myOuterRad;
@ -421,7 +481,8 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Sphere() Sphere()
: Quadric(), : Quadric(),
myRadius(1.0f) myRadius(1.0f)
{} {
}
void Init(const Standard_ShortReal theRadius, void Init(const Standard_ShortReal theRadius,
const gp_Pnt& thePosition, const gp_Pnt& thePosition,
@ -429,7 +490,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Standard_Integer theStacksNb = 20); const Standard_Integer theStacksNb = 20);
protected: protected:
gp_Pnt myPosition; gp_Pnt myPosition;
Standard_ShortReal myRadius; Standard_ShortReal myRadius;
}; };
@ -437,8 +497,8 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Cube class Cube
{ {
public: public:
Cube() {} Cube() {}
~Cube() {} ~Cube() {}
void Init(const gp_Ax1& thePosition, const Standard_ShortReal myBoxSize); 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; } const Handle(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; }
private: private:
void addTriangle(const Standard_Integer theIndex,
void 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); const gp_Dir& theNormal);
protected: protected:
Handle(Poly_Triangulation) myTriangulation; Handle(Poly_Triangulation) myTriangulation;
Handle(Graphic3d_ArrayOfTriangles) myArray; Handle(Graphic3d_ArrayOfTriangles) myArray;
}; };
@ -461,11 +522,11 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Sector : public Quadric class Sector : public Quadric
{ {
public: public:
Sector() Sector()
: Quadric(), : Quadric(),
myRadius(0.0f) myRadius(0.0f)
{ } {
}
~Sector() {} ~Sector() {}
@ -476,7 +537,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Standard_Integer theStacksNb = 5); const Standard_Integer theStacksNb = 5);
protected: protected:
gp_Ax1 myPosition; gp_Ax1 myPosition;
Standard_ShortReal myRadius; Standard_ShortReal myRadius;
}; };
@ -489,7 +549,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Axis class Axis
{ {
public: public:
Axis(const gp_Ax1& theAxis = gp_Ax1(), Axis(const gp_Ax1& theAxis = gp_Ax1(),
const Quantity_Color& theColor = Quantity_Color(), const Quantity_Color& theColor = Quantity_Color(),
const Standard_ShortReal theLength = 10.0f); 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; } 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; } 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; } 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) 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; } Standard_Integer FacettesNumber() const { return myFacettesNumber; }
public: public:
const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; } const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
const Sector& DraggerSector() const { return mySector; } const Sector& DraggerSector() const { return mySector; }
const Disk& RotatorDisk() const { return myCircle; } const Disk& RotatorDisk() const { return myCircle; }
float RotatorDiskRadius() const { return myCircleRadius; } float RotatorDiskRadius() const { return myCircleRadius; }
const Cube& ScalerCube() const { return myCube; } const Cube& ScalerCube() const { return myCube; }
const gp_Pnt& ScalerCubePosition() const { return myCubePos; } const gp_Pnt& ScalerCubePosition() const { return myCubePos; }
protected: protected:
gp_Ax1 myReferenceAxis; //!< Returns reference axis assignment. gp_Ax1 myReferenceAxis; //!< Returns reference axis assignment.
gp_Ax1 myPosition; //!< Position of the axis including local transformation. gp_Ax1 myPosition; //!< Position of the axis including local transformation.
Quantity_Color myColor; Quantity_Color myColor;
@ -650,7 +722,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_Boolean myHasDragging; Standard_Boolean myHasDragging;
protected: protected:
Standard_Integer myFacettesNumber; Standard_Integer myFacettesNumber;
gp_Pnt myArrowTipPos; gp_Pnt myArrowTipPos;
@ -671,11 +742,9 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Handle(Prs3d_Presentation) myHighlightDragger; Handle(Prs3d_Presentation) myHighlightDragger;
Handle(Graphic3d_ArrayOfTriangles) myTriangleArray; Handle(Graphic3d_ArrayOfTriangles) myTriangleArray;
}; };
protected: protected:
Axis myAxes[3]; //!< Tree axes of the manipulator. Axis myAxes[3]; //!< Tree axes of the manipulator.
Sphere myCenter; //!< Visual part displaying the center sphere of the manipulator. Sphere myCenter; //!< Visual part displaying the center sphere of the manipulator.
// clang-format off // 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. //! Aspect used to color sector part when it's selected.
Handle(Prs3d_ShadingAspect) myDraggerHighlight; Handle(Prs3d_ShadingAspect) myDraggerHighlight;
public:
public:
DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)
}; };
#endif // _AIS_Manipulator_HeaderFile #endif // _AIS_Manipulator_HeaderFile

View File

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

View File

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

View File

@ -39,10 +39,8 @@ static Handle(Graphic3d_ArrayOfTriangles) createRectangleArray (const Graphic3d_
return aRectTris; return aRectTris;
} }
//================================================================ //=================================================================================================
// Function : AIS_MediaPlayer
// Purpose :
//================================================================
AIS_MediaPlayer::AIS_MediaPlayer() AIS_MediaPlayer::AIS_MediaPlayer()
: myFramePair(new Graphic3d_MediaTextureSet()), : myFramePair(new Graphic3d_MediaTextureSet()),
myFrameSize(1, 1), myFrameSize(1, 1),
@ -53,16 +51,20 @@ AIS_MediaPlayer::AIS_MediaPlayer()
SetInfiniteState(true); SetInfiniteState(true);
Graphic3d_MaterialAspect aMat; 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->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
myFrameAspect->SetTextureMapOn(true); myFrameAspect->SetTextureMapOn(true);
myFrameAspect->SetTextureSet(myFramePair); myFrameAspect->SetTextureSet(myFramePair);
} }
//================================================================ //=================================================================================================
// Function : ~AIS_MediaPlayer
// Purpose :
//================================================================
AIS_MediaPlayer::~AIS_MediaPlayer() AIS_MediaPlayer::~AIS_MediaPlayer()
{ {
// stop threads // stop threads
@ -73,11 +75,9 @@ AIS_MediaPlayer::~AIS_MediaPlayer()
// function : OpenInput // function : OpenInput
// purpose : // purpose :
// ======================================================================= // =======================================================================
void AIS_MediaPlayer::OpenInput (const TCollection_AsciiString& thePath, void AIS_MediaPlayer::OpenInput(const TCollection_AsciiString& thePath, Standard_Boolean theToWait)
Standard_Boolean theToWait)
{ {
if (myFramePair->PlayerContext().IsNull() if (myFramePair->PlayerContext().IsNull() && thePath.IsEmpty())
&& thePath.IsEmpty())
{ {
return; return;
} }
@ -138,8 +138,7 @@ bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i aFrameSize = myFramePair->FrameSize(); const Graphic3d_Vec2i aFrameSize = myFramePair->FrameSize();
Graphic3d_Vec2i aNewPos = theLeftCorner; Graphic3d_Vec2i aNewPos = theLeftCorner;
Graphic3d_Vec2i aNewSize = myFrameSize; Graphic3d_Vec2i aNewSize = myFrameSize;
if (aFrameSize.x() > 0 if (aFrameSize.x() > 0 && aFrameSize.y() > 0)
&& aFrameSize.y() > 0)
{ {
const double anAspect = double(theMaxSize.x()) / double(theMaxSize.y()); const double anAspect = double(theMaxSize.x()) / double(theMaxSize.y());
const double aFitAspect = double(aFrameSize.x()) / double(aFrameSize.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; aNewPos = theLeftCorner + theMaxSize / 2 - aNewSize / 2;
} }
else if (myFrameSize.x() < 2 else if (myFrameSize.x() < 2 || myFrameSize.y() < 2)
|| myFrameSize.y() < 2)
{ {
aNewSize = theMaxSize; aNewSize = theMaxSize;
} }
if (myFrameSize == aNewSize if (myFrameSize == aNewSize && myFrameBottomLeft == aNewPos)
&& myFrameBottomLeft == aNewPos)
{ {
return false; return false;
} }
@ -220,7 +217,10 @@ void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& ,
// main frame // 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(); Handle(Graphic3d_Group) aMainGroup = thePrs->NewGroup();
aMainGroup->SetGroupPrimitivesAspect(myFrameAspect); aMainGroup->SetGroupPrimitivesAspect(myFrameAspect);
aMainGroup->AddPrimitiveArray(aTris); aMainGroup->AddPrimitiveArray(aTris);
@ -239,7 +239,9 @@ void AIS_MediaPlayer::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
return; 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(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this, 5);
Handle(Select3D_SensitivePrimitiveArray) aSens = new Select3D_SensitivePrimitiveArray(anOwner); 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) DEFINE_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
public: public:
//! Empty constructor. //! Empty constructor.
Standard_EXPORT AIS_MediaPlayer(); Standard_EXPORT AIS_MediaPlayer();
@ -33,7 +32,8 @@ public:
Standard_EXPORT virtual ~AIS_MediaPlayer(); Standard_EXPORT virtual ~AIS_MediaPlayer();
//! Setup callback to be called on queue progress (e.g. when new frame should be displayed). //! 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); myFramePair->SetCallback(theCallbackFunction, theCallbackUserPtr);
} }
@ -64,9 +64,11 @@ public:
//! @name AIS_InteractiveObject interface //! @name AIS_InteractiveObject interface
protected: protected:
//! Accept only display mode 0. //! 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. //! Compute presentation.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
@ -78,19 +80,16 @@ protected:
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
protected: protected:
//! Update frame size. //! Update frame size.
Standard_EXPORT bool updateSize(const Graphic3d_Vec2i& theLeftCorner, Standard_EXPORT bool updateSize(const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize); const Graphic3d_Vec2i& theMaxSize);
protected: protected:
Handle(Graphic3d_MediaTextureSet) myFramePair; Handle(Graphic3d_MediaTextureSet) myFramePair;
Handle(Graphic3d_AspectFillArea3d) myFrameAspect; Handle(Graphic3d_AspectFillArea3d) myFrameAspect;
Graphic3d_Vec2i myFrameBottomLeft; Graphic3d_Vec2i myFrameBottomLeft;
Graphic3d_Vec2i myFrameSize; Graphic3d_Vec2i myFrameSize;
bool myToClosePlayer; bool myToClosePlayer;
}; };
#endif // _AIS_MediaPlayer_HeaderFile #endif // _AIS_MediaPlayer_HeaderFile

View File

@ -23,21 +23,25 @@ enum AIS_MouseGesture
AIS_MouseGesture_NONE, //!< no active gesture AIS_MouseGesture_NONE, //!< no active gesture
// //
AIS_MouseGesture_SelectRectangle, //!< rectangular selection; 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; 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; AIS_MouseGesture_Zoom, //!< view zoom gesture;
//! move mouse left to zoom-out, and to the right to zoom-in //! move mouse left to zoom-out, and to the right to zoom-in
AIS_MouseGesture_ZoomVertical, //!< view zoom gesture; AIS_MouseGesture_ZoomVertical, //!< view zoom gesture;
//! move mouse up to zoom-out, and to the down to zoom-in //! move mouse up to zoom-out, and to the down to zoom-in
AIS_MouseGesture_ZoomWindow, //!< view zoom by window gesture; 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_Pan, //!< view panning gesture
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
AIS_MouseGesture_RotateView, //!< view rotation gesture AIS_MouseGesture_RotateView, //!< view rotation gesture
AIS_MouseGesture_Drag, //!< object dragging; 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. //! Map defining mouse gestures.

View File

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

View File

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

View File

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

View File

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

View File

@ -47,12 +47,12 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_PlaneTrihedron, AIS_InteractiveObject) 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) AIS_PlaneTrihedron::AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane)
: myPlane(aPlane) : myPlane(aPlane)
{ {
@ -73,31 +73,22 @@ AIS_PlaneTrihedron::AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane)
myYLabel = TCollection_AsciiString("Y"); myYLabel = TCollection_AsciiString("Y");
} }
//======================================================================= //=================================================================================================
//function : Component
//purpose :
//=======================================================================
Handle(Geom_Plane) AIS_PlaneTrihedron::Component() Handle(Geom_Plane) AIS_PlaneTrihedron::Component()
{ {
return myPlane; return myPlane;
} }
//=================================================================================================
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
void AIS_PlaneTrihedron::SetComponent(const Handle(Geom_Plane)& aPlane) void AIS_PlaneTrihedron::SetComponent(const Handle(Geom_Plane)& aPlane)
{ {
myPlane = aPlane; myPlane = aPlane;
} }
//======================================================================= //=================================================================================================
//function : XAxis
//purpose :
//=======================================================================
Handle(AIS_Line) AIS_PlaneTrihedron::XAxis() const Handle(AIS_Line) AIS_PlaneTrihedron::XAxis() const
{ {
Handle(Geom_Line) aGLine = new Geom_Line(myPlane->Pln().XAxis()); Handle(Geom_Line) aGLine = new Geom_Line(myPlane->Pln().XAxis());
@ -106,10 +97,8 @@ Handle(AIS_Line) AIS_PlaneTrihedron::XAxis() const
return aLine; return aLine;
} }
//======================================================================= //=================================================================================================
//function : YAxis
//purpose :
//=======================================================================
Handle(AIS_Line) AIS_PlaneTrihedron::YAxis() const Handle(AIS_Line) AIS_PlaneTrihedron::YAxis() const
{ {
Handle(Geom_Line) aGLine = new Geom_Line(myPlane->Pln().YAxis()); Handle(Geom_Line) aGLine = new Geom_Line(myPlane->Pln().YAxis());
@ -118,10 +107,8 @@ Handle(AIS_Line) AIS_PlaneTrihedron::YAxis() const
return aLine; return aLine;
} }
//======================================================================= //=================================================================================================
//function : Position
//purpose :
//=======================================================================
Handle(AIS_Point) AIS_PlaneTrihedron::Position() const Handle(AIS_Point) AIS_PlaneTrihedron::Position() const
{ {
gp_Pnt aPnt = myPlane->Pln().Location(); gp_Pnt aPnt = myPlane->Pln().Location();
@ -130,19 +117,19 @@ Handle(AIS_Point) AIS_PlaneTrihedron::Position() const
return aPt; return aPt;
} }
void AIS_PlaneTrihedron::SetLength(const Standard_Real theLength) { void AIS_PlaneTrihedron::SetLength(const Standard_Real theLength)
{
myDrawer->DatumAspect()->SetAxisLength(theLength, theLength, theLength); myDrawer->DatumAspect()->SetAxisLength(theLength, theLength, theLength);
SetToUpdate(); SetToUpdate();
} }
Standard_Real AIS_PlaneTrihedron::GetLength() const { Standard_Real AIS_PlaneTrihedron::GetLength() const
{
return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis); return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_PlaneTrihedron::Compute(const Handle(PrsMgr_PresentationManager)&, void AIS_PlaneTrihedron::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer) const Standard_Integer)
@ -163,7 +150,11 @@ void AIS_PlaneTrihedron::Compute (const Handle(PrsMgr_PresentationManager)& ,
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis), myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
myDrawer->ArrowAspect(), myDrawer->ArrowAspect(),
myDrawer->TextAspect(), myDrawer->TextAspect(),
xDir, value, myXLabel.ToCString(), first, last); xDir,
value,
myXLabel.ToCString(),
first,
last);
// drawing axis in Y direction // drawing axis in Y direction
value = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_YAxis); 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->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
myDrawer->ArrowAspect(), myDrawer->ArrowAspect(),
myDrawer->TextAspect(), myDrawer->TextAspect(),
yDir, value, myYLabel.ToCString(), first, last); yDir,
value,
myYLabel.ToCString(),
first,
last);
thePrs->SetInfiniteState(Standard_True); thePrs->SetInfiniteState(Standard_True);
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) 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); TColgp_Array1OfPnt PP(1, 4), PO(1, 4);
// ExtremityPoints(PP); // ExtremityPoints(PP);
ExtremityPoints(PP, myPlane, myDrawer); ExtremityPoints(PP, myPlane, myDrawer);
switch (aMode) { switch (aMode)
case 0: {
{ // triedre complet case 0: { // triedre complet
Prior = 5; Prior = 5;
// gp_Ax2 theax = gp_Ax2(myPlane->Position().Ax2()); // gp_Ax2 theax = gp_Ax2(myPlane->Position().Ax2());
// gp_Pnt p1 = theax.Location(); // gp_Pnt p1 = theax.Location();
@ -206,8 +198,7 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
break; break;
} }
case 1: case 1: { // origine
{ //origine
Prior = 8; Prior = 8;
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity
eown = new SelectMgr_EntityOwner(anObj, Prior); eown = new SelectMgr_EntityOwner(anObj, Prior);
@ -215,19 +206,17 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
break; break;
} }
case 2: case 2: { // axes ... priorite 7
{ //axes ... priorite 7
Prior = 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 const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity
eown = new SelectMgr_EntityOwner(anObj, Prior); eown = new SelectMgr_EntityOwner(anObj, Prior);
aSelection->Add(new Select3D_SensitiveSegment(eown, PP(1), PP(i + 1))); aSelection->Add(new Select3D_SensitiveSegment(eown, PP(1), PP(i + 1)));
} }
break; break;
} }
case -1: case -1: {
{
Prior = 5; Prior = 5;
aSelection->Clear(); aSelection->Clear();
break; break;
@ -249,7 +238,9 @@ void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol)
// purpose : to avoid warning // purpose : to avoid warning
//======================================================================= //=======================================================================
// void AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const // 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->Ax2());
gp_Ax2 theax(myPlane->Position().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 = theax.YDirection();
vec *= len; vec *= len;
PP(3) = PP(1).Translated(vec); 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) DEFINE_STANDARD_RTTIEXT(AIS_PlaneTrihedron, AIS_InteractiveObject)
public: public:
//! Initializes the plane aPlane. The plane trihedron is //! Initializes the plane aPlane. The plane trihedron is
//! constructed from this and an axis. //! constructed from this and an axis.
Standard_EXPORT AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane); Standard_EXPORT AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane);
@ -72,12 +71,16 @@ public:
Standard_EXPORT Standard_Real GetLength() const; Standard_EXPORT Standard_Real GetLength() const;
//! Returns true if the display mode selected, aMode, is valid. //! 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; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 4; }
//! Returns datum as the type of Interactive Object. //! 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. //! Allows you to provide settings for the color aColor.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE; Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -87,23 +90,19 @@ public:
void SetYLabel(const TCollection_AsciiString& theLabel) { myYLabel = theLabel; } void SetYLabel(const TCollection_AsciiString& theLabel) { myYLabel = theLabel; }
protected: protected:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
private: private:
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
private: private:
Handle(Geom_Plane) myPlane; Handle(Geom_Plane) myPlane;
Handle(AIS_InteractiveObject) myShapes[3]; Handle(AIS_InteractiveObject) myShapes[3];
TCollection_AsciiString myXLabel; TCollection_AsciiString myXLabel;
TCollection_AsciiString myYLabel; TCollection_AsciiString myYLabel;
}; };
DEFINE_STANDARD_HANDLE(AIS_PlaneTrihedron, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_PlaneTrihedron, AIS_InteractiveObject)

View File

@ -32,12 +32,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Point, AIS_InteractiveObject) 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), myHasTOM(Standard_False),
myTOM(Aspect_TOM_PLUS) myTOM(Aspect_TOM_PLUS)
{ {
@ -48,35 +46,28 @@ myTOM(Aspect_TOM_PLUS)
myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
myDynHilightDrawer = new Prs3d_Drawer(); myDynHilightDrawer = new Prs3d_Drawer();
myDynHilightDrawer->SetDisplayMode(-99); 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->SetColor(Quantity_NOC_CYAN1);
myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top); myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top);
} }
//======================================================================= //=================================================================================================
//function : Component
//purpose :
//=======================================================================
Handle(Geom_Point) AIS_Point::Component() Handle(Geom_Point) AIS_Point::Component()
{ {
return myComponent; return myComponent;
} }
//======================================================================= //=================================================================================================
//function : SetComponent
//purpose :
//=======================================================================
void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent) void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
{ {
myComponent = aComponent; myComponent = aComponent;
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager)&, void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) 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, void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/) const Standard_Integer /*aMode*/)
{ {
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 10); Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 10);
Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown, Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown, myComponent->Pnt());
myComponent->Pnt());
aSelection->Add(sp); aSelection->Add(sp);
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Point::SetColor(const Quantity_Color& theCol) void AIS_Point::SetColor(const Quantity_Color& theCol)
{ {
hasOwnColor = Standard_True; hasOwnColor = Standard_True;
@ -120,31 +106,23 @@ void AIS_Point::SetColor (const Quantity_Color& theCol)
UpdatePointValues(); UpdatePointValues();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Point::UnsetColor() void AIS_Point::UnsetColor()
{ {
hasOwnColor = Standard_False; hasOwnColor = Standard_False;
UpdatePointValues(); UpdatePointValues();
} }
//=================================================================================================
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
TopoDS_Vertex AIS_Point::Vertex() const TopoDS_Vertex AIS_Point::Vertex() const
{ {
gp_Pnt P = myComponent->Pnt(); gp_Pnt P = myComponent->Pnt();
return BRepBuilderAPI_MakeVertex(P); return BRepBuilderAPI_MakeVertex(P);
} }
//======================================================================= //=================================================================================================
//function : SetMarker
//purpose :
//=======================================================================
void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM) void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
{ {
@ -153,31 +131,23 @@ void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
UpdatePointValues(); UpdatePointValues();
} }
//======================================================================= //=================================================================================================
//function : UnsetMarker
//purpose :
//=======================================================================
void AIS_Point::UnsetMarker() void AIS_Point::UnsetMarker()
{ {
myHasTOM = Standard_False; myHasTOM = Standard_False;
UpdatePointValues(); UpdatePointValues();
} }
//======================================================================= //=================================================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_Point::AcceptDisplayMode(const Standard_Integer theMode) const Standard_Boolean AIS_Point::AcceptDisplayMode(const Standard_Integer theMode) const
{ {
return theMode == 0 return theMode == 0 || theMode == -99;
|| theMode == -99;
} }
//======================================================================= //=================================================================================================
//function : replaceWithNewPointAspect
//purpose :
//=======================================================================
void AIS_Point::replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect) void AIS_Point::replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect)
{ {
if (!myDrawer->HasLink()) 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) 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) if (anAspectNew != anAspectOld)
{ {
myDrawer->SetPointAspect(theAspect); myDrawer->SetPointAspect(theAspect);
@ -197,16 +168,11 @@ void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theA
} }
} }
//======================================================================= //=================================================================================================
//function : UpdatePointValues
//purpose :
//=======================================================================
void AIS_Point::UpdatePointValues() void AIS_Point::UpdatePointValues()
{ {
if (!hasOwnColor if (!hasOwnColor && myOwnWidth == 0.0f && !myHasTOM)
&& myOwnWidth == 0.0f
&& !myHasTOM)
{ {
replaceWithNewPointAspect(Handle(Prs3d_PointAspect)()); replaceWithNewPointAspect(Handle(Prs3d_PointAspect)());
return; return;
@ -222,9 +188,12 @@ void AIS_Point::UpdatePointValues()
aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale(); aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
} }
if(hasOwnColor) aCol = myDrawer->Color(); if (hasOwnColor)
if(myOwnWidth != 0.0f) aScale = myOwnWidth; aCol = myDrawer->Color();
if(myHasTOM) aTOM = myTOM; if (myOwnWidth != 0.0f)
aScale = myOwnWidth;
if (myHasTOM)
aTOM = myTOM;
if (myDrawer->HasOwnPointAspect()) if (myDrawer->HasOwnPointAspect())
{ {
@ -239,4 +208,3 @@ void AIS_Point::UpdatePointValues()
replaceWithNewPointAspect(new Prs3d_PointAspect(aTOM, aCol, aScale)); 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) DEFINE_STANDARD_RTTIEXT(AIS_Point, AIS_InteractiveObject)
public: public:
//! Initializes the point aComponent from which the point //! Initializes the point aComponent from which the point
//! datum will be built. //! datum will be built.
Standard_EXPORT AIS_Point(const Handle(Geom_Point)& aComponent); Standard_EXPORT AIS_Point(const Handle(Geom_Point)& aComponent);
@ -37,7 +36,10 @@ public:
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 1; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 1; }
//! Indicates that a point is a datum. //! 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. //! Returns the component specified in SetComponent.
Standard_EXPORT Handle(Geom_Point) Component(); Standard_EXPORT Handle(Geom_Point) Component();
@ -46,7 +48,8 @@ public:
Standard_EXPORT void SetComponent(const Handle(Geom_Point)& aComponent); Standard_EXPORT void SetComponent(const Handle(Geom_Point)& aComponent);
//! Returns true if the display mode selected is valid for point datums. //! 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. //! Allows you to provide settings for the Color.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE; Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -70,14 +73,13 @@ public:
Standard_EXPORT TopoDS_Vertex Vertex() const; Standard_EXPORT TopoDS_Vertex Vertex() const;
protected: protected:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
private: private:
Standard_EXPORT void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE; const Standard_Integer aMode) Standard_OVERRIDE;
Standard_EXPORT void UpdatePointValues(); Standard_EXPORT void UpdatePointValues();
@ -85,11 +87,9 @@ private:
void replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect); void replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect);
private: private:
Handle(Geom_Point) myComponent; Handle(Geom_Point) myComponent;
Standard_Boolean myHasTOM; Standard_Boolean myHasTOM;
Aspect_TypeOfMarker myTOM; Aspect_TypeOfMarker myTOM;
}; };
DEFINE_STANDARD_HANDLE(AIS_Point, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_Point, AIS_InteractiveObject)

View File

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

View File

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

View File

@ -26,14 +26,12 @@
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
#include <V3d_View.hxx> #include <V3d_View.hxx>
#define MEMORY_BLOCK_SIZE 512 * 7 #define MEMORY_BLOCK_SIZE 512 * 7
IMPLEMENT_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
//=======================================================================
//function : Constructor //=================================================================================================
//purpose :
//=======================================================================
AIS_RubberBand::AIS_RubberBand() AIS_RubberBand::AIS_RubberBand()
: myIsPolygonClosed(Standard_True) : myIsPolygonClosed(Standard_True)
{ {
@ -50,10 +48,8 @@ AIS_RubberBand::AIS_RubberBand()
SetZLayer(Graphic3d_ZLayerId_TopOSD); SetZLayer(Graphic3d_ZLayerId_TopOSD);
} }
//======================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor, AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType, const Aspect_TypeOfLine theLineType,
const Standard_Real theWidth, const Standard_Real theWidth,
@ -73,10 +69,8 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
SetZLayer(Graphic3d_ZLayerId_TopOSD); SetZLayer(Graphic3d_ZLayerId_TopOSD);
} }
//======================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor, AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType, const Aspect_TypeOfLine theLineType,
const Quantity_Color theFillColor, const Quantity_Color theFillColor,
@ -98,10 +92,8 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
SetZLayer(Graphic3d_ZLayerId_TopOSD); SetZLayer(Graphic3d_ZLayerId_TopOSD);
} }
//======================================================================= //=================================================================================================
//function : Destructor
//purpose :
//=======================================================================
AIS_RubberBand::~AIS_RubberBand() AIS_RubberBand::~AIS_RubberBand()
{ {
myPoints.Clear(); myPoints.Clear();
@ -109,12 +101,12 @@ AIS_RubberBand::~AIS_RubberBand()
myBorders.Nullify(); myBorders.Nullify();
} }
//======================================================================= //=================================================================================================
//function : SetRectangle
//purpose : void AIS_RubberBand::SetRectangle(const Standard_Integer theMinX,
//======================================================================= const Standard_Integer theMinY,
void AIS_RubberBand::SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY, const Standard_Integer theMaxX,
const Standard_Integer theMaxX, const Standard_Integer theMaxY) const Standard_Integer theMaxY)
{ {
myPoints.Clear(); myPoints.Clear();
myPoints.Append(Graphic3d_Vec2i(theMinX, theMinY)); 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)); myPoints.Append(Graphic3d_Vec2i(theMaxX, theMinY));
} }
//======================================================================= //=================================================================================================
//function : AddPoint
//purpose :
//=======================================================================
void AIS_RubberBand::AddPoint(const Graphic3d_Vec2i& thePoint) void AIS_RubberBand::AddPoint(const Graphic3d_Vec2i& thePoint)
{ {
myPoints.Append(thePoint); myPoints.Append(thePoint);
} }
//======================================================================= //=================================================================================================
//function : AddPoint
//purpose :
//=======================================================================
void AIS_RubberBand::RemoveLastPoint() void AIS_RubberBand::RemoveLastPoint()
{ {
myPoints.Remove(myPoints.Length()); myPoints.Remove(myPoints.Length());
} }
//======================================================================= //=================================================================================================
//function : GetPoints
//purpose :
//=======================================================================
const NCollection_Sequence<Graphic3d_Vec2i>& AIS_RubberBand::Points() const const NCollection_Sequence<Graphic3d_Vec2i>& AIS_RubberBand::Points() const
{ {
return myPoints; return myPoints;
} }
//======================================================================= //=================================================================================================
//function : LineColor
//purpose :
//=======================================================================
Quantity_Color AIS_RubberBand::LineColor() const Quantity_Color AIS_RubberBand::LineColor() const
{ {
return myDrawer->LineAspect()->Aspect()->Color(); return myDrawer->LineAspect()->Aspect()->Color();
} }
//======================================================================= //=================================================================================================
//function : SetLineColor
//purpose :
//=======================================================================
void AIS_RubberBand::SetLineColor(const Quantity_Color& theColor) void AIS_RubberBand::SetLineColor(const Quantity_Color& theColor)
{ {
myDrawer->LineAspect()->SetColor(theColor); myDrawer->LineAspect()->SetColor(theColor);
} }
//======================================================================= //=================================================================================================
//function : FillColor
//purpose :
//=======================================================================
Quantity_Color AIS_RubberBand::FillColor() const Quantity_Color AIS_RubberBand::FillColor() const
{ {
return myDrawer->ShadingAspect()->Color(); return myDrawer->ShadingAspect()->Color();
} }
//======================================================================= //=================================================================================================
//function : SetFillColor
//purpose :
//=======================================================================
void AIS_RubberBand::SetFillColor(const Quantity_Color& theColor) void AIS_RubberBand::SetFillColor(const Quantity_Color& theColor)
{ {
myDrawer->ShadingAspect()->SetColor(theColor); myDrawer->ShadingAspect()->SetColor(theColor);
} }
//======================================================================= //=================================================================================================
//function : SetLineWidth
//purpose :
//=======================================================================
void AIS_RubberBand::SetLineWidth(const Standard_Real theWidth) const void AIS_RubberBand::SetLineWidth(const Standard_Real theWidth) const
{ {
myDrawer->LineAspect()->SetWidth(theWidth); myDrawer->LineAspect()->SetWidth(theWidth);
} }
//======================================================================= //=================================================================================================
//function : SetLineWidth
//purpose :
//=======================================================================
Standard_Real AIS_RubberBand::LineWidth() const Standard_Real AIS_RubberBand::LineWidth() const
{ {
return myDrawer->LineAspect()->Aspect()->Width(); return myDrawer->LineAspect()->Aspect()->Width();
} }
//======================================================================= //=================================================================================================
//function : SetLineType
//purpose :
//=======================================================================
void AIS_RubberBand::SetLineType(const Aspect_TypeOfLine theType) void AIS_RubberBand::SetLineType(const Aspect_TypeOfLine theType)
{ {
myDrawer->LineAspect()->SetTypeOfLine(theType); myDrawer->LineAspect()->SetTypeOfLine(theType);
} }
//======================================================================= //=================================================================================================
//function : LineType
//purpose :
//=======================================================================
Aspect_TypeOfLine AIS_RubberBand::LineType() const Aspect_TypeOfLine AIS_RubberBand::LineType() const
{ {
return myDrawer->LineAspect()->Aspect()->Type(); return myDrawer->LineAspect()->Aspect()->Type();
} }
//======================================================================= //=================================================================================================
//function : SetFillTransparency
//purpose :
//=======================================================================
void AIS_RubberBand::SetFillTransparency(const Standard_Real theValue) const void AIS_RubberBand::SetFillTransparency(const Standard_Real theValue) const
{ {
myDrawer->ShadingAspect()->SetTransparency(theValue); myDrawer->ShadingAspect()->SetTransparency(theValue);
} }
//======================================================================= //=================================================================================================
//function : SetFillTransparency
//purpose :
//=======================================================================
Standard_Real AIS_RubberBand::FillTransparency() const Standard_Real AIS_RubberBand::FillTransparency() const
{ {
return myDrawer->ShadingAspect()->Transparency(); return myDrawer->ShadingAspect()->Transparency();
} }
//======================================================================= //=================================================================================================
//function : SetFilling
//purpose :
//=======================================================================
void AIS_RubberBand::SetFilling(const Standard_Boolean theIsFilling) 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) void AIS_RubberBand::SetFilling(const Quantity_Color theColor, const Standard_Real theTransparency)
{ {
SetFilling(Standard_True); SetFilling(Standard_True);
@ -260,49 +223,41 @@ void AIS_RubberBand::SetFilling (const Quantity_Color theColor, const Standard_R
SetFillColor(theColor); SetFillColor(theColor);
} }
//======================================================================= //=================================================================================================
//function : IsFilling
//purpose :
//=======================================================================
Standard_Boolean AIS_RubberBand::IsFilling() const Standard_Boolean AIS_RubberBand::IsFilling() const
{ {
Aspect_InteriorStyle aStyle = myDrawer->ShadingAspect()->Aspect()->InteriorStyle(); Aspect_InteriorStyle aStyle = myDrawer->ShadingAspect()->Aspect()->InteriorStyle();
return aStyle != Aspect_IS_EMPTY; return aStyle != Aspect_IS_EMPTY;
} }
//======================================================================= //=================================================================================================
//function : IsPolygonClosed
//purpose :
//=======================================================================
Standard_Boolean AIS_RubberBand::IsPolygonClosed() const Standard_Boolean AIS_RubberBand::IsPolygonClosed() const
{ {
return myIsPolygonClosed; return myIsPolygonClosed;
} }
//======================================================================= //=================================================================================================
//function : SetPolygonClosed
//purpose :
//=======================================================================
void AIS_RubberBand::SetPolygonClosed(Standard_Boolean theIsPolygonClosed) void AIS_RubberBand::SetPolygonClosed(Standard_Boolean theIsPolygonClosed)
{ {
myIsPolygonClosed = theIsPolygonClosed; myIsPolygonClosed = theIsPolygonClosed;
} }
//======================================================================= //=================================================================================================
//function : fillTriangles
//purpose :
//=======================================================================
Standard_Boolean AIS_RubberBand::fillTriangles() Standard_Boolean AIS_RubberBand::fillTriangles()
{ {
Handle(NCollection_IncAllocator) anAllocator = new NCollection_IncAllocator(MEMORY_BLOCK_SIZE); 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 aPtsLower = myPoints.Lower();
Standard_Integer aPtsUpper = myPoints.Upper(); Standard_Integer aPtsUpper = myPoints.Upper();
IMeshData::VectorOfInteger anIndexes(myPoints.Length(), anAllocator); IMeshData::VectorOfInteger anIndexes(myPoints.Length(), anAllocator);
for (Standard_Integer aPtIdx = aPtsLower; aPtIdx <= aPtsUpper; ++aPtIdx) for (Standard_Integer aPtIdx = aPtsLower; aPtIdx <= aPtsUpper; ++aPtIdx)
{ {
gp_XY aP ((Standard_Real)myPoints.Value (aPtIdx).x(), gp_XY aP((Standard_Real)myPoints.Value(aPtIdx).x(), (Standard_Real)myPoints.Value(aPtIdx).y());
(Standard_Real)myPoints.Value (aPtIdx).y());
BRepMesh_Vertex aVertex(aP, aPtIdx, BRepMesh_Frontier); BRepMesh_Vertex aVertex(aP, aPtIdx, BRepMesh_Frontier);
anIndexes.Append(aMeshStructure->AddNode(aVertex)); 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 aPtIdx = isClockwiseOrdered ? aIdx : (aIdx + 1) % anIndexes.Length();
Standard_Integer aNextPtIdx = isClockwiseOrdered ? (aIdx + 1) % anIndexes.Length() : aIdx; Standard_Integer aNextPtIdx = isClockwiseOrdered ? (aIdx + 1) % anIndexes.Length() : aIdx;
BRepMesh_Edge anEdge (anIndexes.Value (aPtIdx), BRepMesh_Edge anEdge(anIndexes.Value(aPtIdx), anIndexes.Value(aNextPtIdx), BRepMesh_Frontier);
anIndexes.Value (aNextPtIdx),
BRepMesh_Frontier);
aMeshStructure->AddLink(anEdge); aMeshStructure->AddLink(anEdge);
} }
@ -331,7 +284,6 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
if (aTriangles.Extent() < 1) if (aTriangles.Extent() < 1)
return Standard_False; return Standard_False;
Standard_Boolean toFill = Standard_False; Standard_Boolean toFill = Standard_False;
if (myTriangles.IsNull() || myTriangles->VertexNumber() != aTriangles.Extent() * 3) if (myTriangles.IsNull() || myTriangles->VertexNumber() != aTriangles.Extent() * 3)
{ {
@ -364,15 +316,18 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
gp_Dir aNorm = gp::DZ(); gp_Dir aNorm = gp::DZ();
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{ {
myTriangles->AddVertex (aPts[anIt].X(), aPts[anIt].Y(), 0.0, myTriangles
aNorm.X(), aNorm.Y(), aNorm.Z()); ->AddVertex(aPts[anIt].X(), aPts[anIt].Y(), 0.0, aNorm.X(), aNorm.Y(), aNorm.Z());
} }
} }
else else
{ {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) 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; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_RubberBand::Compute(const Handle(PrsMgr_PresentationManager)&, void AIS_RubberBand::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -405,34 +358,40 @@ void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager)& ,
} }
// Draw frame // 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)); myBorders = new Graphic3d_ArrayOfPolylines(myPoints.Length() + (myIsPolygonClosed ? 1 : 0));
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++) for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
{ {
myBorders->AddVertex((Standard_Real)myPoints.Value(anIt).x(), 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) if (myIsPolygonClosed)
{ {
myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(), 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 else
{ {
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++) for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
{ {
myBorders->SetVertice (anIt, (Standard_ShortReal)myPoints.Value (anIt).x(), myBorders->SetVertice(anIt,
(Standard_ShortReal)myPoints.Value (anIt).y(), 0.0f); (Standard_ShortReal)myPoints.Value(anIt).x(),
(Standard_ShortReal)myPoints.Value(anIt).y(),
0.0f);
} }
if (myIsPolygonClosed) if (myIsPolygonClosed)
{ {
myBorders->SetVertice(myPoints.Length() + 1, (Standard_ShortReal)myPoints.Value(1).x(), myBorders->SetVertice(myPoints.Length() + 1,
(Standard_ShortReal)myPoints.Value(1).y(), 0.0f); (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 class AIS_RubberBand : public AIS_InteractiveObject
{ {
public: public:
DEFINE_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
//! Constructs rubber band with default configuration: empty filling and white solid lines. //! 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] theLineColor color of rubber band lines
//! @param[in] theType type of rubber band lines //! @param[in] theType type of rubber band lines
//! @param[in] theFillColor color of rubber band filling //! @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. //! @param[in] theLineWidth width of rubber band line. By default it is 1.
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer. //! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
Standard_EXPORT AIS_RubberBand(const Quantity_Color& theLineColor, Standard_EXPORT AIS_RubberBand(const Quantity_Color& theLineColor,
@ -67,8 +67,10 @@ public:
Standard_EXPORT virtual ~AIS_RubberBand(); Standard_EXPORT virtual ~AIS_RubberBand();
//! Sets rectangle bounds. //! Sets rectangle bounds.
Standard_EXPORT void SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY, Standard_EXPORT void SetRectangle(const Standard_Integer theMinX,
const Standard_Integer theMaxX, const Standard_Integer theMaxY); 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. //! Adds last point to the list of points. They are used to build polygon for rubber band.
//! @sa RemoveLastPoint(), GetPoints() //! @sa RemoveLastPoint(), GetPoints()
@ -121,7 +123,8 @@ public:
//! Enable filling of rubber band with defined parameters. //! Enable filling of rubber band with defined parameters.
//! @param[in] theColor color of filling //! @param[in] theColor color of filling
//! @param[in] theTransparency transparency of the filling. 0 is for opaque 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. //! @return true if filling of rubber band is enabled.
Standard_EXPORT Standard_Boolean IsFilling() const; Standard_EXPORT Standard_Boolean IsFilling() const;
@ -134,7 +137,6 @@ public:
Standard_EXPORT void SetPolygonClosed(Standard_Boolean theIsPolygonClosed); Standard_EXPORT void SetPolygonClosed(Standard_Boolean theIsPolygonClosed);
protected: protected:
//! Returns true if the interactive object accepts the display mode. //! Returns true if the interactive object accepts the display mode.
Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{ {
@ -156,7 +158,6 @@ protected:
Standard_EXPORT Standard_Boolean fillTriangles(); Standard_EXPORT Standard_Boolean fillTriangles();
protected: protected:
NCollection_Sequence<Graphic3d_Vec2i> myPoints; //!< Array of screen points NCollection_Sequence<Graphic3d_Vec2i> myPoints; //!< Array of screen points
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling

View File

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

View File

@ -25,20 +25,16 @@ namespace
static const Standard_Integer THE_MaxSizeOfResult = 100000; static const Standard_Integer THE_MaxSizeOfResult = 100000;
} }
//======================================================================= //=================================================================================================
//function : AIS_Selection
//purpose :
//=======================================================================
AIS_Selection::AIS_Selection() AIS_Selection::AIS_Selection()
{ {
// for maximum performance on medium selections (< 100000 objects) // for maximum performance on medium selections (< 100000 objects)
myResultMap.ReSize(THE_MaxSizeOfResult); myResultMap.ReSize(THE_MaxSizeOfResult);
} }
//======================================================================= //=================================================================================================
//function : Clear
//purpose :
//=======================================================================
void AIS_Selection::Clear() void AIS_Selection::Clear()
{ {
for (AIS_NListOfEntityOwner::Iterator aSelIter(Objects()); aSelIter.More(); aSelIter.Next()) for (AIS_NListOfEntityOwner::Iterator aSelIter(Objects()); aSelIter.More(); aSelIter.Next())
@ -51,23 +47,20 @@ void AIS_Selection::Clear()
myIterator = AIS_NListOfEntityOwner::Iterator(); myIterator = AIS_NListOfEntityOwner::Iterator();
} }
//======================================================================= //=================================================================================================
//function : Select
//purpose :
//=======================================================================
AIS_SelectStatus AIS_Selection::Select(const Handle(SelectMgr_EntityOwner)& theOwner, AIS_SelectStatus AIS_Selection::Select(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Filter)& theFilter, const Handle(SelectMgr_Filter)& theFilter,
const AIS_SelectionScheme theSelScheme, const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theIsDetected) const Standard_Boolean theIsDetected)
{ {
if (theOwner.IsNull() if (theOwner.IsNull() || !theOwner->HasSelectable())
|| !theOwner->HasSelectable())
{ {
return AIS_SS_NotDone; return AIS_SS_NotDone;
} }
const Standard_Boolean isDetected = theIsDetected const Standard_Boolean isDetected =
&& (theFilter.IsNull() || theFilter->IsOk (theOwner)); theIsDetected && (theFilter.IsNull() || theFilter->IsOk(theOwner));
const Standard_Boolean wasSelected = theOwner->IsSelected(); const Standard_Boolean wasSelected = theOwner->IsSelected();
const Standard_Boolean toSelect = theOwner->Select(theSelScheme, isDetected); 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. // 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 // 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()) if (theOwner->IsForcedHilight())
{ {
return AIS_SS_Added; return AIS_SS_Added;
@ -127,15 +121,11 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
return AIS_SS_Removed; return AIS_SS_Removed;
} }
//======================================================================= //=================================================================================================
//function : AddSelect
//purpose :
//=======================================================================
AIS_SelectStatus AIS_Selection::AddSelect(const Handle(SelectMgr_EntityOwner)& theObject) AIS_SelectStatus AIS_Selection::AddSelect(const Handle(SelectMgr_EntityOwner)& theObject)
{ {
if (theObject.IsNull() if (theObject.IsNull() || !theObject->HasSelectable() || myResultMap.IsBound(theObject))
|| !theObject->HasSelectable()
|| myResultMap.IsBound (theObject))
{ {
return AIS_SS_NotDone; return AIS_SS_NotDone;
} }
@ -147,10 +137,8 @@ AIS_SelectStatus AIS_Selection::AddSelect (const Handle(SelectMgr_EntityOwner)&
return AIS_SS_Added; return AIS_SS_Added;
} }
//======================================================================= //=================================================================================================
//function : SelectOwners
//purpose :
//=======================================================================
void AIS_Selection::SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners, void AIS_Selection::SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners,
const AIS_SelectionScheme theSelScheme, const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theToAllowSelOverlap, const Standard_Boolean theToAllowSelOverlap,
@ -158,12 +146,12 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
{ {
(void)theToAllowSelOverlap; (void)theToAllowSelOverlap;
if (theSelScheme == AIS_SelectionScheme_ReplaceExtra if (theSelScheme == AIS_SelectionScheme_ReplaceExtra && thePickedOwners.Size() == myresult.Size())
&& thePickedOwners.Size() == myresult.Size())
{ {
// If picked owners is equivalent to the selected then just clear selected. // If picked owners is equivalent to the selected then just clear selected.
Standard_Boolean isTheSame = Standard_True; 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())) if (!myResultMap.IsBound(aPickedIter.Value()))
{ {
@ -185,23 +173,20 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
Clear(); 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(); const Handle(SelectMgr_EntityOwner)& anOwner = aPickedIter.Value();
Select(anOwner, theFilter, theSelScheme, true); Select(anOwner, theFilter, theSelScheme, true);
} }
} }
//======================================================================= //=================================================================================================
//function : appendOwner
//purpose :
//=======================================================================
AIS_SelectStatus AIS_Selection::appendOwner(const Handle(SelectMgr_EntityOwner)& theOwner, AIS_SelectStatus AIS_Selection::appendOwner(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Filter)& theFilter) const Handle(SelectMgr_Filter)& theFilter)
{ {
if (theOwner.IsNull() if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk(theOwner))
|| !theOwner->HasSelectable()
|| !theFilter->IsOk (theOwner))
{ {
return AIS_SS_NotDone; return AIS_SS_NotDone;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,10 +34,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
//======================================================================= //=================================================================================================
//function : AIS_TextLabel
//purpose :
//=======================================================================
AIS_TextLabel::AIS_TextLabel() AIS_TextLabel::AIS_TextLabel()
: myText("?"), : myText("?"),
myHasOrientation3D(Standard_False), myHasOrientation3D(Standard_False),
@ -48,10 +46,8 @@ AIS_TextLabel::AIS_TextLabel()
myDrawer->SetDisplayMode(0); myDrawer->SetDisplayMode(0);
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_TextLabel::SetColor(const Quantity_Color& theColor) void AIS_TextLabel::SetColor(const Quantity_Color& theColor)
{ {
hasOwnColor = Standard_True; hasOwnColor = Standard_True;
@ -60,10 +56,8 @@ void AIS_TextLabel::SetColor (const Quantity_Color& theColor)
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : SetTransparency
//purpose :
//=======================================================================
void AIS_TextLabel::SetTransparency(const Standard_Real theValue) void AIS_TextLabel::SetTransparency(const Standard_Real theValue)
{ {
Quantity_ColorRGBA aTextColor(myDrawer->TextAspect()->Aspect()->Color()); Quantity_ColorRGBA aTextColor(myDrawer->TextAspect()->Aspect()->Color());
@ -78,28 +72,22 @@ void AIS_TextLabel::SetTransparency (const Standard_Real theValue)
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : SetText
//purpose :
//=======================================================================
void AIS_TextLabel::SetText(const TCollection_ExtendedString& theText) void AIS_TextLabel::SetText(const TCollection_ExtendedString& theText)
{ {
myText = theText; myText = theText;
} }
//======================================================================= //=================================================================================================
//function : SetPosition
//purpose :
//=======================================================================
void AIS_TextLabel::SetPosition(const gp_Pnt& thePosition) void AIS_TextLabel::SetPosition(const gp_Pnt& thePosition)
{ {
myOrientation3D.SetLocation(thePosition); myOrientation3D.SetLocation(thePosition);
} }
//======================================================================= //=================================================================================================
//function : SetHJustification
//purpose :
//=======================================================================
void AIS_TextLabel::SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust) void AIS_TextLabel::SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust)
{ {
myDrawer->TextAspect()->SetHorizontalJustification(theHJust); myDrawer->TextAspect()->SetHorizontalJustification(theHJust);
@ -114,163 +102,128 @@ void AIS_TextLabel::SetVJustification (const Graphic3d_VerticalTextAlignment the
myDrawer->TextAspect()->SetVerticalJustification(theVJust); myDrawer->TextAspect()->SetVerticalJustification(theVJust);
} }
//======================================================================= //=================================================================================================
//function : SetAngle
//purpose :
//=======================================================================
void AIS_TextLabel::SetAngle(const Standard_Real theAngle) void AIS_TextLabel::SetAngle(const Standard_Real theAngle)
{ {
myDrawer->TextAspect()->Aspect()->SetTextAngle(theAngle * 180.0 / M_PI); myDrawer->TextAspect()->Aspect()->SetTextAngle(theAngle * 180.0 / M_PI);
} }
//======================================================================= //=================================================================================================
//function : SetZoom
//purpose :
//=======================================================================
void AIS_TextLabel::SetZoomable(const Standard_Boolean theIsZoomable) void AIS_TextLabel::SetZoomable(const Standard_Boolean theIsZoomable)
{ {
myDrawer->TextAspect()->Aspect()->SetTextZoomable(theIsZoomable == Standard_True); myDrawer->TextAspect()->Aspect()->SetTextZoomable(theIsZoomable == Standard_True);
} }
//======================================================================= //=================================================================================================
//function : SetHeight
//purpose :
//=======================================================================
void AIS_TextLabel::SetHeight(const Standard_Real theHeight) void AIS_TextLabel::SetHeight(const Standard_Real theHeight)
{ {
myDrawer->TextAspect()->SetHeight(theHeight); myDrawer->TextAspect()->SetHeight(theHeight);
} }
//======================================================================= //=================================================================================================
//function : SetAngle
//purpose :
//=======================================================================
void AIS_TextLabel::SetFontAspect(const Font_FontAspect theFontAspect) void AIS_TextLabel::SetFontAspect(const Font_FontAspect theFontAspect)
{ {
myDrawer->TextAspect()->Aspect()->SetTextFontAspect(theFontAspect); myDrawer->TextAspect()->Aspect()->SetTextFontAspect(theFontAspect);
} }
//======================================================================= //=================================================================================================
//function : SetFont
//purpose :
//=======================================================================
void AIS_TextLabel::SetFont(Standard_CString theFont) void AIS_TextLabel::SetFont(Standard_CString theFont)
{ {
myDrawer->TextAspect()->SetFont(theFont); myDrawer->TextAspect()->SetFont(theFont);
} }
//======================================================================= //=================================================================================================
//function : SetOrientation3D
//purpose :
//=======================================================================
void AIS_TextLabel::SetOrientation3D(const gp_Ax2& theOrientation) void AIS_TextLabel::SetOrientation3D(const gp_Ax2& theOrientation)
{ {
myHasOrientation3D = Standard_True; myHasOrientation3D = Standard_True;
myOrientation3D = theOrientation; myOrientation3D = theOrientation;
} }
//======================================================================= //=================================================================================================
//function : UnsetOrientation3D
//purpose :
//=======================================================================
void AIS_TextLabel::UnsetOrientation3D() void AIS_TextLabel::UnsetOrientation3D()
{ {
myHasOrientation3D = Standard_False; myHasOrientation3D = Standard_False;
} }
//======================================================================= //=================================================================================================
//function : Position
//purpose :
//=======================================================================
const gp_Pnt& AIS_TextLabel::Position() const const gp_Pnt& AIS_TextLabel::Position() const
{ {
return myOrientation3D.Location(); return myOrientation3D.Location();
} }
//======================================================================= //=================================================================================================
//function : FontName
//purpose :
//=======================================================================
const TCollection_AsciiString& AIS_TextLabel::FontName() const const TCollection_AsciiString& AIS_TextLabel::FontName() const
{ {
return myDrawer->TextAspect()->Aspect()->Font(); return myDrawer->TextAspect()->Aspect()->Font();
} }
//======================================================================= //=================================================================================================
//function : FontAspect
//purpose :
//=======================================================================
Font_FontAspect AIS_TextLabel::FontAspect() const Font_FontAspect AIS_TextLabel::FontAspect() const
{ {
return myDrawer->TextAspect()->Aspect()->GetTextFontAspect(); return myDrawer->TextAspect()->Aspect()->GetTextFontAspect();
} }
//======================================================================= //=================================================================================================
//function : Orientation3D
//purpose :
//=======================================================================
const gp_Ax2& AIS_TextLabel::Orientation3D() const const gp_Ax2& AIS_TextLabel::Orientation3D() const
{ {
return myOrientation3D; return myOrientation3D;
} }
//======================================================================= //=================================================================================================
//function : HasOrientation3D
//purpose :
//=======================================================================
Standard_Boolean AIS_TextLabel::HasOrientation3D() const Standard_Boolean AIS_TextLabel::HasOrientation3D() const
{ {
return myHasOrientation3D; return myHasOrientation3D;
} }
//======================================================================= //=================================================================================================
//function : SetFlipping
//purpose :
//=======================================================================
void AIS_TextLabel::SetFlipping(const Standard_Boolean theIsFlipping) void AIS_TextLabel::SetFlipping(const Standard_Boolean theIsFlipping)
{ {
myHasFlipping = theIsFlipping; myHasFlipping = theIsFlipping;
} }
//======================================================================= //=================================================================================================
//function : HasFlipping
//purpose :
//=======================================================================
Standard_Boolean AIS_TextLabel::HasFlipping() const Standard_Boolean AIS_TextLabel::HasFlipping() const
{ {
return myHasFlipping; return myHasFlipping;
} }
//======================================================================= //=================================================================================================
//function : SetDisplayType
//purpose :
//=======================================================================
void AIS_TextLabel::SetDisplayType(const Aspect_TypeOfDisplayText theDisplayType) void AIS_TextLabel::SetDisplayType(const Aspect_TypeOfDisplayText theDisplayType)
{ {
myDrawer->TextAspect()->Aspect()->SetDisplayType(theDisplayType); myDrawer->TextAspect()->Aspect()->SetDisplayType(theDisplayType);
} }
//======================================================================= //=================================================================================================
//function : SetColorSubTitle
//purpose :
//=======================================================================
void AIS_TextLabel::SetColorSubTitle(const Quantity_Color& theColor) void AIS_TextLabel::SetColorSubTitle(const Quantity_Color& theColor)
{ {
myDrawer->TextAspect()->Aspect()->SetColorSubTitle(theColor); myDrawer->TextAspect()->Aspect()->SetColorSubTitle(theColor);
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_TextLabel::Compute(const Handle(PrsMgr_PresentationManager)&, void AIS_TextLabel::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
switch (theMode) switch (theMode)
{ {
case 0: case 0: {
{
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect(); Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
gp_Pnt aPosition = Position(); gp_Pnt aPosition = Position();
@ -281,12 +234,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, aPosition)); SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, aPosition));
aPosition = gp::Origin(); aPosition = gp::Origin();
} }
else if (isTextZoomable else if (isTextZoomable || TransformPersistence().IsNull()
|| TransformPersistence().IsNull()
|| TransformPersistence()->Mode() != Graphic3d_TMF_2d) || TransformPersistence()->Mode() != Graphic3d_TMF_2d)
{ {
Handle(Graphic3d_TransformPers) aTrsfPers = Handle(Graphic3d_TransformPers) aTrsfPers = new Graphic3d_TransformPers(
new Graphic3d_TransformPers (isTextZoomable ? Graphic3d_TMF_RotatePers : Graphic3d_TMF_ZoomRotatePers, aPosition); isTextZoomable ? Graphic3d_TMF_RotatePers : Graphic3d_TMF_ZoomRotatePers,
aPosition);
SetTransformPersistence(aTrsfPers); SetTransformPersistence(aTrsfPers);
aPosition = gp::Origin(); aPosition = gp::Origin();
} }
@ -299,7 +252,9 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
{ {
if (myHasFlipping) if (myHasFlipping)
{ {
gp_Ax2 aFlippingAxes (aCenterOfLabel, myOrientation3D.Direction(), myOrientation3D.XDirection()); gp_Ax2 aFlippingAxes(aCenterOfLabel,
myOrientation3D.Direction(),
myOrientation3D.XDirection());
thePrs->CurrentGroup()->SetFlippingOptions(Standard_True, aFlippingAxes); thePrs->CurrentGroup()->SetFlippingOptions(Standard_True, aFlippingAxes);
} }
gp_Ax2 anOrientation = myOrientation3D; 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, void AIS_TextLabel::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
switch (theMode) switch (theMode)
{ {
case 0: case 0: {
{
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this, 10); Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this, 10);
gp_Pnt aPosition = Position(); gp_Pnt aPosition = Position();
@ -367,7 +319,8 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
if (!calculateLabelParams(aPosition, aCenterOfLabel, aWidth, aHeight)) 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); theSelection->Add(aTextSensitive);
break; 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, Standard_Boolean AIS_TextLabel::calculateLabelParams(const gp_Pnt& thePosition,
gp_Pnt& theCenterOfLabel, gp_Pnt& theCenterOfLabel,
Standard_Real& theWidth, Standard_Real& theWidth,
@ -404,7 +355,8 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
{ {
// Get width and height of text // Get width and height of text
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect(); Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
const Graphic3d_RenderingParams& aRendParams = GetContext()->CurrentViewer()->DefaultRenderingParams(); const Graphic3d_RenderingParams& aRendParams =
GetContext()->CurrentViewer()->DefaultRenderingParams();
Font_FTFontParams aFontParams; Font_FTFontParams aFontParams;
aFontParams.PointSize = (unsigned int)anAsp->Height(); aFontParams.PointSize = (unsigned int)anAsp->Height();
aFontParams.Resolution = aRendParams.Resolution; aFontParams.Resolution = aRendParams.Resolution;
@ -419,7 +371,8 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
} }
const NCollection_String aText(myText.ToExtString()); 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()); theWidth = Abs(aBndBox.Width());
theHeight = Abs(aBndBox.Height()); theHeight = Abs(aBndBox.Height());
@ -444,10 +397,8 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
return Standard_True; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : calculateLabelTrsf
//purpose :
//=======================================================================
gp_Trsf AIS_TextLabel::calculateLabelTrsf(const gp_Pnt& thePosition, gp_Pnt& theCenterOfLabel) const 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; 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 class AIS_TextLabel : public AIS_InteractiveObject
{ {
public: public:
//! Default constructor //! Default constructor
Standard_EXPORT AIS_TextLabel(); Standard_EXPORT AIS_TextLabel();
//! Return TRUE for supported display mode. //! 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. //! Setup color of entire text.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE; Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -108,7 +110,10 @@ public:
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; } Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
//! Set flag if text uses position as point of attach //! 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. //! Define the display type of the text.
//! //!
@ -123,14 +128,17 @@ public:
//! and the colour of backgroubd for the TODT_DEKALE TextDisplayType. //! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
Standard_EXPORT void SetColorSubTitle(const Quantity_Color& theColor); 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; } const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
//! Setup text formatter for presentation. It's empty by default. //! 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: protected:
//! Compute //! Compute
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
@ -151,7 +159,6 @@ protected:
gp_Pnt& theCenterOfLabel) const; gp_Pnt& theCenterOfLabel) const;
protected: protected:
Handle(Font_TextFormatter) myFormatter; Handle(Font_TextFormatter) myFormatter;
TCollection_ExtendedString myText; TCollection_ExtendedString myText;
@ -161,10 +168,8 @@ protected:
Standard_Boolean myHasFlipping; Standard_Boolean myHasFlipping;
public: public:
//! CASCADE RTTI //! CASCADE RTTI
DEFINE_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
}; };
DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)

View File

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

View File

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

View File

@ -24,7 +24,6 @@
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx> #include <Graphic3d_ArrayOfTriangles.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
AIS_Triangulation::AIS_Triangulation(const Handle(Poly_Triangulation)& Triangulation) AIS_Triangulation::AIS_Triangulation(const Handle(Poly_Triangulation)& Triangulation)
@ -35,10 +34,8 @@ AIS_Triangulation::AIS_Triangulation(const Handle(Poly_Triangulation)& Triangula
myFlagColor = 0; myFlagColor = 0;
} }
//======================================================================= //=================================================================================================
//function : SetTransparency
//purpose :
//=======================================================================
void AIS_Triangulation::SetTransparency(const Standard_Real theValue) void AIS_Triangulation::SetTransparency(const Standard_Real theValue)
{ {
if (!myDrawer->HasOwnShadingAspect()) if (!myDrawer->HasOwnShadingAspect())
@ -57,10 +54,8 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
updatePresentation(); updatePresentation();
} }
//======================================================================= //=================================================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
void AIS_Triangulation::UnsetTransparency() void AIS_Triangulation::UnsetTransparency()
{ {
myDrawer->SetTransparency(0.0f); myDrawer->SetTransparency(0.0f);
@ -76,10 +71,8 @@ void AIS_Triangulation::UnsetTransparency()
updatePresentation(); updatePresentation();
} }
//======================================================================= //=================================================================================================
//function : updatePresentation
//purpose :
//=======================================================================
void AIS_Triangulation::updatePresentation() void AIS_Triangulation::updatePresentation()
{ {
if (HasVertexColors()) if (HasVertexColors())
@ -99,7 +92,8 @@ void AIS_Triangulation::updatePresentation()
} }
const Handle(Prs3d_Presentation)& aPrs = aPrsIter.Value(); 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(); const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
aGroup->SetGroupPrimitivesAspect(anAreaAsp); aGroup->SetGroupPrimitivesAspect(anAreaAsp);
@ -108,10 +102,8 @@ void AIS_Triangulation::updatePresentation()
} }
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager)&, void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -124,8 +116,11 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
Standard_Boolean hasVNormals = myTriangulation->HasNormals(); Standard_Boolean hasVNormals = myTriangulation->HasNormals();
Standard_Boolean hasVColors = HasVertexColors(); Standard_Boolean hasVColors = HasVertexColors();
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (myNbNodes, myNbTriangles * 3, Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles(myNbNodes,
hasVNormals, hasVColors, Standard_False); myNbTriangles * 3,
hasVNormals,
hasVColors,
Standard_False);
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup(); Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
Handle(Graphic3d_AspectFillArea3d) anAspect = myDrawer->ShadingAspect()->Aspect(); 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(); const TColStd_Array1OfInteger& colors = myColor->Array1();
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter) 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); myTriangulation->Normal(aNodeIter, aNormal);
anArray->SetVertexNormal(aNodeIter, aNormal.x(), aNormal.y(), aNormal.z()); 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(); const TColStd_Array1OfInteger& colors = myColor->Array1();
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter) 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 else // !hasVColors
@ -184,14 +181,11 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
aGroup->AddPrimitiveArray(anArray); aGroup->AddPrimitiveArray(anArray);
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Triangulation::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/, void AIS_Triangulation::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/) const Standard_Integer /*aMode*/)
{ {
} }
//======================================================================= //=======================================================================
@ -218,35 +212,32 @@ Handle(TColStd_HArray1OfInteger) AIS_Triangulation::GetColors() const
return myColor; return myColor;
} }
//=================================================================================================
//=======================================================================
//function : SetTriangulation
//purpose :
//=======================================================================
void AIS_Triangulation::SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation) void AIS_Triangulation::SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation)
{ {
myTriangulation = aTriangulation; myTriangulation = aTriangulation;
} }
//======================================================================= //=================================================================================================
//function : GetTriangulation
//purpose : Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const
//======================================================================= {
Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const{
return myTriangulation; return myTriangulation;
} }
//======================================================================= //=================================================================================================
//function : AttenuateColor
//purpose :
//=======================================================================
Graphic3d_Vec4ub AIS_Triangulation::attenuateColor(const Standard_Integer theColor, Graphic3d_Vec4ub AIS_Triangulation::attenuateColor(const Standard_Integer theColor,
const Standard_Real theComposition) const Standard_Real theComposition)
{ {
const Standard_Byte* anRgbx = reinterpret_cast<const Standard_Byte*>(&theColor); const Standard_Byte* anRgbx = reinterpret_cast<const Standard_Byte*>(&theColor);
// If IsTranparent() is false alpha value will be ignored anyway. // 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; : 255;
return Graphic3d_Vec4ub((Standard_Byte)(theComposition * anRgbx[0]), 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) DEFINE_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
public: public:
//! Constructs the Triangulation display object //! Constructs the Triangulation display object
Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation); Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
//! Set the color for each node. //! Set the color for each node.
//! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
//! Order of color components is essential for further usage by OpenGL //! Order of color components is essential for further usage by OpenGL
Standard_EXPORT void SetColors(const Handle(TColStd_HArray1OfInteger)& aColor); Standard_EXPORT void SetColors(const Handle(TColStd_HArray1OfInteger)& aColor);
//! Get the color for each node. //! Get the color for each node.
//! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const; Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
//! Returns true if triangulation has vertex colors. //! Returns true if triangulation has vertex colors.
Standard_Boolean HasVertexColors() const Standard_Boolean HasVertexColors() const { return (myFlagColor == 1); }
{
return (myFlagColor == 1);
}
Standard_EXPORT void SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation); Standard_EXPORT void SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation);
@ -64,11 +58,9 @@ public:
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
protected: protected:
Standard_EXPORT void updatePresentation(); Standard_EXPORT void updatePresentation();
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
@ -78,17 +70,18 @@ private:
//! Attenuates 32-bit color by a given attenuation factor (0...1): //! Attenuates 32-bit color by a given attenuation factor (0...1):
//! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red //! 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. //! All color components are multiplied by aComponent, the result is then packed again as 32-bit
//! Color attenuation is applied to the vertex colors in order to have correct visual result //! integer. Color attenuation is applied to the vertex colors in order to have correct visual
//! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat. //! result after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and
Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent); //! flat.
Standard_EXPORT Graphic3d_Vec4ub attenuateColor(const Standard_Integer theColor,
const Standard_Real theComponent);
Handle(Poly_Triangulation) myTriangulation; Handle(Poly_Triangulation) myTriangulation;
Handle(TColStd_HArray1OfInteger) myColor; Handle(TColStd_HArray1OfInteger) myColor;
Standard_Integer myFlagColor; Standard_Integer myFlagColor;
Standard_Integer myNbNodes; Standard_Integer myNbNodes;
Standard_Integer myNbTriangles; Standard_Integer myNbTriangles;
}; };
#endif // _AIS_Triangulation_HeaderFile #endif // _AIS_Triangulation_HeaderFile

View File

@ -46,10 +46,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
//======================================================================= //=================================================================================================
//function : AIS_Trihedron
//purpose :
//=======================================================================
AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent) AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent)
: myComponent(theComponent), : myComponent(theComponent),
myTrihDispMode(Prs3d_DM_WireFrame), myTrihDispMode(Prs3d_DM_WireFrame),
@ -81,20 +79,16 @@ AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent)
myLabels[Prs3d_DatumParts_ZAxis] = "Z"; myLabels[Prs3d_DatumParts_ZAxis] = "Z";
} }
//======================================================================= //=================================================================================================
//function : SetComponent
//purpose :
//=======================================================================
void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& theComponent) void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& theComponent)
{ {
myComponent = theComponent; myComponent = theComponent;
SetToUpdate(); SetToUpdate();
} }
//======================================================================= //=================================================================================================
//function : setOwnDatumAspect
//purpose :
//=======================================================================
void AIS_Trihedron::setOwnDatumAspect() void AIS_Trihedron::setOwnDatumAspect()
{ {
if (myDrawer->HasOwnDatumAspect()) if (myDrawer->HasOwnDatumAspect())
@ -110,10 +104,8 @@ void AIS_Trihedron::setOwnDatumAspect()
} }
} }
//======================================================================= //=================================================================================================
//function : SetSize
//purpose :
//=======================================================================
void AIS_Trihedron::SetSize(const Standard_Real theValue) void AIS_Trihedron::SetSize(const Standard_Real theValue)
{ {
myHasOwnSize = Standard_True; myHasOwnSize = Standard_True;
@ -125,10 +117,8 @@ void AIS_Trihedron::SetSize(const Standard_Real theValue)
UpdateSelection(); UpdateSelection();
} }
//======================================================================= //=================================================================================================
//function : UnsetSize
//purpose :
//=======================================================================
void AIS_Trihedron::UnsetSize() void AIS_Trihedron::UnsetSize()
{ {
if (!myHasOwnSize) if (!myHasOwnSize)
@ -139,9 +129,8 @@ void AIS_Trihedron::UnsetSize()
myHasOwnSize = Standard_False; myHasOwnSize = Standard_False;
if (hasOwnColor) if (hasOwnColor)
{ {
const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() const Handle(Prs3d_DatumAspect) DA =
? myDrawer->Link()->DatumAspect() myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() : new Prs3d_DatumAspect();
: new Prs3d_DatumAspect();
myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis), myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis),
DA->AxisLength(Prs3d_DatumParts_YAxis), DA->AxisLength(Prs3d_DatumParts_YAxis),
DA->AxisLength(Prs3d_DatumParts_ZAxis)); DA->AxisLength(Prs3d_DatumParts_ZAxis));
@ -153,19 +142,15 @@ void AIS_Trihedron::UnsetSize()
UpdateSelection(); UpdateSelection();
} }
//======================================================================= //=================================================================================================
//function : Size
//purpose :
//=======================================================================
Standard_Real AIS_Trihedron::Size() const Standard_Real AIS_Trihedron::Size() const
{ {
return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis); return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Trihedron::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, void AIS_Trihedron::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -178,26 +163,29 @@ void AIS_Trihedron::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr
thePrs->SetInfiniteState(Standard_True); thePrs->SetInfiniteState(Standard_True);
gp_Ax2 anAxis(myComponent->Ax2()); gp_Ax2 anAxis(myComponent->Ax2());
updatePrimitives (myDrawer->DatumAspect(), myTrihDispMode, anAxis.Location(), updatePrimitives(myDrawer->DatumAspect(),
anAxis.XDirection(), anAxis.YDirection(), anAxis.Direction()); myTrihDispMode,
anAxis.Location(),
anAxis.XDirection(),
anAxis.YDirection(),
anAxis.Direction());
computePresentation(thePrsMgr, thePrs); computePresentation(thePrsMgr, thePrs);
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection, void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
switch (theMode) switch (theMode)
{ {
case AIS_TrihedronSelectionMode_EntireObject: case AIS_TrihedronSelectionMode_EntireObject: {
{ Handle(SelectMgr_EntityOwner) anOwner =
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this, mySelectionPriority[Prs3d_DatumParts_None]); new SelectMgr_EntityOwner(this, mySelectionPriority[Prs3d_DatumParts_None]);
const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded; 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) ++aPartIter)
{ {
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter; const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter;
@ -209,19 +197,18 @@ void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
} }
break; break;
} }
case AIS_TrihedronSelectionMode_Origin: case AIS_TrihedronSelectionMode_Origin: {
{
const Prs3d_DatumParts aPart = Prs3d_DatumParts_Origin; const Prs3d_DatumParts aPart = Prs3d_DatumParts_Origin;
if (anAspect->DrawDatumPart(aPart)) 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); Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = arrayOfPrimitives(aPart);
theSelection->Add(createSensitiveEntity(aPart, anOwner)); theSelection->Add(createSensitiveEntity(aPart, anOwner));
} }
break; break;
} }
case AIS_TrihedronSelectionMode_Axes: case AIS_TrihedronSelectionMode_Axes: {
{
for (int aPartIter = Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; ++aPartIter) for (int aPartIter = Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; ++aPartIter)
{ {
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter; const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter;
@ -229,23 +216,25 @@ void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
{ {
continue; 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)); theSelection->Add(createSensitiveEntity(aPart, anOwner));
} }
break; break;
} }
case AIS_TrihedronSelectionMode_MainPlanes: case AIS_TrihedronSelectionMode_MainPlanes: {
{
// create owner for each trihedron plane // 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; const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter;
if (!anAspect->DrawDatumPart(aPart)) if (!anAspect->DrawDatumPart(aPart))
{ {
continue; 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)); 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, void AIS_Trihedron::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) const Handle(SelectMgr_EntityOwner)& theOwner)
@ -305,7 +292,8 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
} }
aGroup->AddPrimitiveArray(arrayOfPrimitives(aPart)); 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) if (aPresentation->GetZLayer() != aLayer)
{ {
aPresentation->SetZLayer(aLayer); aPresentation->SetZLayer(aLayer);
@ -315,10 +303,8 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
thePM->AddToImmediateList(aPresentation); thePM->AddToImmediateList(aPresentation);
} }
//======================================================================== //=================================================================================================
//function : HilightSelected
//purpose :
//========================================================================
void AIS_Trihedron::HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM, void AIS_Trihedron::HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theOwners) const SelectMgr_SequenceOfOwner& theOwners)
{ {
@ -329,8 +315,10 @@ void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager)& t
const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded; const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded;
Handle(Prs3d_Drawer) anAspect = !myHilightDrawer.IsNull() ? myHilightDrawer : GetContext()->SelectionStyle(); Handle(Prs3d_Drawer) anAspect =
for (SelectMgr_SequenceOfOwner::Iterator anIterator (theOwners); anIterator.More(); anIterator.Next()) !myHilightDrawer.IsNull() ? myHilightDrawer : GetContext()->SelectionStyle();
for (SelectMgr_SequenceOfOwner::Iterator anIterator(theOwners); anIterator.More();
anIterator.Next())
{ {
const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value(); const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value();
Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(anOwner); 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(); const Prs3d_DatumParts aPart = aTrihedronOwner->DatumPart();
if (myPartToGroup[aPart].IsNull() if (myPartToGroup[aPart].IsNull() || mySelectedParts.Contains(aPart))
|| mySelectedParts.Contains (aPart))
{ {
continue; continue;
} }
const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart]; const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart];
if (aPart >= Prs3d_DatumParts_XOYAxis if (aPart >= Prs3d_DatumParts_XOYAxis && aPart <= Prs3d_DatumParts_XOZAxis)
&& aPart <= Prs3d_DatumParts_XOZAxis)
{ {
aGroup->SetGroupPrimitivesAspect(anAspect->LineAspect()->Aspect()); 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() void AIS_Trihedron::ClearSelected()
{ {
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
@ -388,8 +372,7 @@ void AIS_Trihedron::ClearSelected()
{ {
const Prs3d_DatumParts aPart = anIterator.Value(); const Prs3d_DatumParts aPart = anIterator.Value();
const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart]; const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart];
if (aPart >= Prs3d_DatumParts_XOYAxis if (aPart >= Prs3d_DatumParts_XOYAxis && aPart <= Prs3d_DatumParts_XOZAxis)
&& aPart <= Prs3d_DatumParts_XOZAxis)
{ {
aGroup->SetGroupPrimitivesAspect(myHiddenLineAspect); aGroup->SetGroupPrimitivesAspect(myHiddenLineAspect);
} }
@ -412,10 +395,8 @@ void AIS_Trihedron::ClearSelected()
mySelectedParts.Clear(); mySelectedParts.Clear();
} }
//======================================================================= //=================================================================================================
//function : computePresentation
//purpose :
//=======================================================================
void AIS_Trihedron::computePresentation(const Handle(PrsMgr_PresentationManager)& /*thePrsMgr*/, void AIS_Trihedron::computePresentation(const Handle(PrsMgr_PresentationManager)& /*thePrsMgr*/,
const Handle(Prs3d_Presentation)& thePrs) const Handle(Prs3d_Presentation)& thePrs)
{ {
@ -448,7 +429,8 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
// display axes // 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; Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!anAspect->DrawDatumPart(aPart)) if (!anAspect->DrawDatumPart(aPart))
@ -493,7 +475,8 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
{ {
Handle(Geom_Axis2Placement) aComponent = myComponent; Handle(Geom_Axis2Placement) aComponent = myComponent;
const gp_Pnt anOrigin = aComponent->Location(); 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; const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!anAspect->DrawDatumPart(aPart)) if (!anAspect->DrawDatumPart(aPart))
@ -506,10 +489,17 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
gp_Dir aDir; gp_Dir aDir;
switch (aPart) switch (aPart)
{ {
case Prs3d_DatumParts_XAxis: aDir = aComponent->XDirection(); break; case Prs3d_DatumParts_XAxis:
case Prs3d_DatumParts_YAxis: aDir = aComponent->YDirection(); break; aDir = aComponent->XDirection();
case Prs3d_DatumParts_ZAxis: aDir = aComponent->Direction(); break; break;
default: 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(); Handle(Graphic3d_Group) aLabelGroup = thePrs->NewGroup();
const gp_Pnt aPoint = anOrigin.XYZ() + aDir.XYZ() * anAxisLength; 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 // 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; Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!anAspect->DrawDatumPart(aPart)) 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, void AIS_Trihedron::SetDatumPartColor(const Prs3d_DatumParts thePart,
const Quantity_Color& theColor) 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(); setOwnDatumAspect();
myDrawer->DatumAspect()->TextAspect(thePart)->SetColor(theColor); myDrawer->DatumAspect()->TextAspect(thePart)->SetColor(theColor);
} }
//======================================================================= //=================================================================================================
//function : SetTextColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetTextColor(const Quantity_Color& theColor) void AIS_Trihedron::SetTextColor(const Quantity_Color& theColor)
{ {
setOwnDatumAspect(); setOwnDatumAspect();
@ -573,10 +558,8 @@ void AIS_Trihedron::SetTextColor (const Quantity_Color& theColor)
myDrawer->DatumAspect()->TextAspect(Prs3d_DatumParts_ZAxis)->SetColor(theColor); myDrawer->DatumAspect()->TextAspect(Prs3d_DatumParts_ZAxis)->SetColor(theColor);
} }
//======================================================================= //=================================================================================================
//function : Color
//purpose :
//=======================================================================
Quantity_Color AIS_Trihedron::DatumPartColor(Prs3d_DatumParts thePart) Quantity_Color AIS_Trihedron::DatumPartColor(Prs3d_DatumParts thePart)
{ {
if (myTrihDispMode == Prs3d_DM_Shaded) 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) void AIS_Trihedron::SetOriginColor(const Quantity_Color& theColor)
{ {
if (myTrihDispMode == Prs3d_DM_Shaded) 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) void AIS_Trihedron::SetXAxisColor(const Quantity_Color& theColor)
{ {
SetDatumPartColor(Prs3d_DatumParts_XAxis, theColor); SetDatumPartColor(Prs3d_DatumParts_XAxis, theColor);
} }
//======================================================================= //=================================================================================================
//function : SetYAxisColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetYAxisColor(const Quantity_Color& theColor) void AIS_Trihedron::SetYAxisColor(const Quantity_Color& theColor)
{ {
SetDatumPartColor(Prs3d_DatumParts_YAxis, theColor); SetDatumPartColor(Prs3d_DatumParts_YAxis, theColor);
} }
//======================================================================= //=================================================================================================
//function : SetAxisColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetAxisColor(const Quantity_Color& theColor) void AIS_Trihedron::SetAxisColor(const Quantity_Color& theColor)
{ {
SetDatumPartColor(Prs3d_DatumParts_ZAxis, theColor); SetDatumPartColor(Prs3d_DatumParts_ZAxis, theColor);
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetColor(const Quantity_Color& theColor) void AIS_Trihedron::SetColor(const Quantity_Color& theColor)
{ {
hasOwnColor = Standard_True; hasOwnColor = Standard_True;
@ -643,12 +616,9 @@ void AIS_Trihedron::SetColor (const Quantity_Color& theColor)
SetDatumPartColor(Prs3d_DatumParts_ZAxis, 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(); setOwnDatumAspect();
myHasOwnArrowColor = Standard_True; myHasOwnArrowColor = Standard_True;
@ -657,45 +627,38 @@ void AIS_Trihedron::SetArrowColor (const Prs3d_DatumParts thePart,
myDrawer->DatumAspect()->LineAspect(anArrowPart)->SetColor(theColor); myDrawer->DatumAspect()->LineAspect(anArrowPart)->SetColor(theColor);
} }
//======================================================================= //=================================================================================================
//function : SetArrowColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetArrowColor(const Quantity_Color& theColor) void AIS_Trihedron::SetArrowColor(const Quantity_Color& theColor)
{ {
setOwnDatumAspect(); setOwnDatumAspect();
myHasOwnArrowColor = Standard_True; myHasOwnArrowColor = Standard_True;
myDrawer->DatumAspect()->ArrowAspect()->SetColor(theColor); 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()->ShadingAspect((Prs3d_DatumParts)anAxisIter)->SetColor(theColor);
myDrawer->DatumAspect()->LineAspect((Prs3d_DatumParts)anAxisIter)->SetColor(theColor); myDrawer->DatumAspect()->LineAspect((Prs3d_DatumParts)anAxisIter)->SetColor(theColor);
} }
} }
//======================================================================= //=================================================================================================
//function : TextColor
//purpose :
//=======================================================================
Quantity_Color AIS_Trihedron::TextColor() const Quantity_Color AIS_Trihedron::TextColor() const
{ {
return myDrawer->DatumAspect()->TextAspect(Prs3d_DatumParts_XAxis)->Aspect()->Color(); return myDrawer->DatumAspect()->TextAspect(Prs3d_DatumParts_XAxis)->Aspect()->Color();
} }
//======================================================================= //=================================================================================================
//function : ArrowColor
//purpose :
//=======================================================================
Quantity_Color AIS_Trihedron::ArrowColor() const Quantity_Color AIS_Trihedron::ArrowColor() const
{ {
return myDrawer->DatumAspect()->ArrowAspect()->Aspect()->Color(); return myDrawer->DatumAspect()->ArrowAspect()->Aspect()->Color();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Trihedron::UnsetColor() void AIS_Trihedron::UnsetColor()
{ {
hasOwnColor = Standard_False; hasOwnColor = Standard_False;
@ -713,30 +676,25 @@ void AIS_Trihedron::UnsetColor()
} }
} }
//======================================================================= //=================================================================================================
//function : ToDrawArrows
//purpose :
//=======================================================================
Standard_Boolean AIS_Trihedron::ToDrawArrows() const Standard_Boolean AIS_Trihedron::ToDrawArrows() const
{ {
return myDrawer->DatumAspect()->ToDrawArrows(); return myDrawer->DatumAspect()->ToDrawArrows();
} }
//======================================================================= //=================================================================================================
//function : SetDrawArrows
//purpose :
//=======================================================================
void AIS_Trihedron::SetDrawArrows(const Standard_Boolean theToDraw) void AIS_Trihedron::SetDrawArrows(const Standard_Boolean theToDraw)
{ {
setOwnDatumAspect(); setOwnDatumAspect();
myDrawer->DatumAspect()->SetDrawArrows(theToDraw); 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 const Handle(SelectMgr_EntityOwner)& theOwner) const
{ {
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect(); Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
@ -746,8 +704,7 @@ Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity (const Prs
return Handle(Select3D_SensitiveEntity)(); return Handle(Select3D_SensitiveEntity)();
} }
if (thePart >= Prs3d_DatumParts_XOYAxis if (thePart >= Prs3d_DatumParts_XOYAxis && thePart <= Prs3d_DatumParts_XOZAxis)
&& thePart <= Prs3d_DatumParts_XOZAxis)
{ // plane { // plane
const gp_Pnt anXYZ1 = aPrimitives->Vertice(1); const gp_Pnt anXYZ1 = aPrimitives->Vertice(1);
const gp_Pnt anXYZ2 = aPrimitives->Vertice(2); const gp_Pnt anXYZ2 = aPrimitives->Vertice(2);
@ -757,17 +714,22 @@ Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity (const Prs
if (myTrihDispMode == Prs3d_DM_Shaded) if (myTrihDispMode == Prs3d_DM_Shaded)
{ {
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (theOwner); Handle(Select3D_SensitivePrimitiveArray) aSelArray =
aSelArray->InitTriangulation (aPrimitives->Attributes(), aPrimitives->Indices(), TopLoc_Location()); new Select3D_SensitivePrimitiveArray(theOwner);
aSelArray->InitTriangulation(aPrimitives->Attributes(),
aPrimitives->Indices(),
TopLoc_Location());
return aSelArray; 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); const gp_Pnt anXYZ1 = aPoints->Vertice(1);
return new Select3D_SensitivePoint(theOwner, anXYZ1); 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 anXYZ1 = aSegments->Vertice(1);
const gp_Pnt anXYZ2 = aSegments->Vertice(2); 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) for (int anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
{ {
Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter; Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
anAxisPoints.Bind(aPart, gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ() * anAxisPoints.Bind(
theAspect->AxisLength(aPart))); aPart,
gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ() * theAspect->AxisLength(aPart)));
} }
if (theMode == Prs3d_DM_WireFrame) 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); const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis(aPart);
if (theAspect->DrawDatumPart(anArrowPart)) 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->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)); (Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes));
} }
} }
@ -843,22 +809,29 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
// origin // origin
if (theAspect->DrawDatumPart(Prs3d_DatumParts_Origin)) if (theAspect->DrawDatumPart(Prs3d_DatumParts_Origin))
{ {
const Standard_Real aSphereRadius = theAspect->AxisLength(Prs3d_DatumParts_XAxis) * const Standard_Real aSphereRadius =
theAspect->Attribute(Prs3d_DatumAttribute_ShadingOriginRadiusPercent); theAspect->AxisLength(Prs3d_DatumParts_XAxis)
* theAspect->Attribute(Prs3d_DatumAttribute_ShadingOriginRadiusPercent);
const Standard_Integer aNbOfFacettes = const Standard_Integer aNbOfFacettes =
(Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes); (Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes);
gp_Trsf aSphereTransform; gp_Trsf aSphereTransform;
aSphereTransform.SetTranslationPart(gp_Vec(gp::Origin(), theOrigin)); 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 // axes
{ {
const Standard_Integer aNbOfFacettes = const Standard_Integer aNbOfFacettes =
(Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes); (Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes);
const Standard_Real aTubeRadiusPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingTubeRadiusPercent); const Standard_Real aTubeRadiusPercent =
const Standard_Real aConeLengthPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent); theAspect->Attribute(Prs3d_DatumAttribute_ShadingTubeRadiusPercent);
const Standard_Real aConeRadiusPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeRadiusPercent); const Standard_Real aConeLengthPercent =
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter) 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 aPart = (Prs3d_DatumParts)anAxisIter;
const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis(aPart); 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)) if (theAspect->DrawDatumPart(aPart))
{ {
// draw cylinder // draw cylinder
myPrimitives[aPart] = Prs3d_Arrow::DrawShaded (anAxis, anAxisLength * aTubeRadiusPercent, myPrimitives[aPart] = Prs3d_Arrow::DrawShaded(
anAxis,
anAxisLength * aTubeRadiusPercent,
aDrawArrow ? (anAxisLength - anAxisLength * aConeLengthPercent) : anAxisLength, aDrawArrow ? (anAxisLength - anAxisLength * aConeLengthPercent) : anAxisLength,
0.0, 0.0, aNbOfFacettes); 0.0,
0.0,
aNbOfFacettes);
} }
// draw arrow // draw arrow
if (aDrawArrow) if (aDrawArrow)
{ {
myPrimitives[anArrowPart] = Prs3d_Arrow::DrawShaded (anAxis, 0.0, anAxisLength, myPrimitives[anArrowPart] = Prs3d_Arrow::DrawShaded(anAxis,
0.0,
anAxisLength,
anAxisLength * aConeRadiusPercent, anAxisLength * aConeRadiusPercent,
anAxisLength * aConeLengthPercent, aNbOfFacettes); anAxisLength * aConeLengthPercent,
aNbOfFacettes);
} }
} }
} }
} }
// planes // 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; const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPlaneIter;
if (!theAspect->DrawDatumPart(aPart)) 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; Prs3d_DatumParts aPart1 = Prs3d_DatumParts_XAxis, aPart2 = Prs3d_DatumParts_XAxis;
switch (aPart) switch (aPart)
{ {
case Prs3d_DatumParts_XOYAxis: case Prs3d_DatumParts_XOYAxis: {
{
aPart1 = Prs3d_DatumParts_XAxis; aPart1 = Prs3d_DatumParts_XAxis;
aPart2 = Prs3d_DatumParts_YAxis; aPart2 = Prs3d_DatumParts_YAxis;
break; break;
} }
case Prs3d_DatumParts_YOZAxis: case Prs3d_DatumParts_YOZAxis: {
{
aPart1 = Prs3d_DatumParts_YAxis; aPart1 = Prs3d_DatumParts_YAxis;
aPart2 = Prs3d_DatumParts_ZAxis; aPart2 = Prs3d_DatumParts_ZAxis;
break; break;
} }
case Prs3d_DatumParts_XOZAxis: case Prs3d_DatumParts_XOZAxis: {
{
aPart1 = Prs3d_DatumParts_XAxis; aPart1 = Prs3d_DatumParts_XAxis;
aPart2 = Prs3d_DatumParts_ZAxis; aPart2 = Prs3d_DatumParts_ZAxis;
break; break;
} }
default: break; default:
break;
} }
aPrims->AddVertex(anAxisPoints.Find(aPart1)); aPrims->AddVertex(anAxisPoints.Find(aPart1));
aPrims->AddVertex(anAxisPoints.Find(aPart2)); 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 void AIS_Trihedron::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{ {
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream) 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) DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
public: public:
//! Initializes a trihedron entity. //! Initializes a trihedron entity.
Standard_EXPORT AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent); Standard_EXPORT AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent);
@ -93,8 +92,7 @@ public:
Standard_EXPORT void SetTextColor(const Quantity_Color& theColor); Standard_EXPORT void SetTextColor(const Quantity_Color& theColor);
//! Sets color of label of trihedron axis. //! Sets color of label of trihedron axis.
Standard_EXPORT void SetTextColor (const Prs3d_DatumParts thePart, Standard_EXPORT void SetTextColor(const Prs3d_DatumParts thePart, const Quantity_Color& theColor);
const Quantity_Color& theColor);
//! Returns true if trihedron has own arrow color //! Returns true if trihedron has own arrow color
Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; } Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; }
@ -139,11 +137,13 @@ public:
Standard_EXPORT void SetDrawArrows(const Standard_Boolean theToDraw); Standard_EXPORT void SetDrawArrows(const Standard_Boolean theToDraw);
//! Returns priority of selection for owner of the given type //! 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 //! Sets priority of selection for owner of the given type
void SetSelectionPriority (Prs3d_DatumParts thePart, void SetSelectionPriority(Prs3d_DatumParts thePart, Standard_Integer thePriority)
Standard_Integer thePriority)
{ {
mySelectionPriority[thePart] = thePriority; mySelectionPriority[thePart] = thePriority;
} }
@ -152,14 +152,12 @@ public:
const TCollection_ExtendedString& Label(Prs3d_DatumParts thePart) { return myLabels[thePart]; } const TCollection_ExtendedString& Label(Prs3d_DatumParts thePart) { return myLabels[thePart]; }
//! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis
void SetLabel (const Prs3d_DatumParts thePart, void SetLabel(const Prs3d_DatumParts thePart, const TCollection_ExtendedString& theName)
const TCollection_ExtendedString& theName)
{ {
myLabels[thePart] = theName; myLabels[thePart] = theName;
} }
public: public:
//! Sets the color theColor for this trihedron object, it changes color of axes. //! Sets the color theColor for this trihedron object, it changes color of axes.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE; 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; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; }
//! Indicates that the type of Interactive Object is datum. //! 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. //! Removes the settings for color.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
public: public:
//! Method which clear all selected owners belonging //! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw ). //! to this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
//! Method which draws selected owners ( for fast presentation draw ). //! Method which draws selected owners ( for fast presentation draw ).
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM, 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 //! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw ). //! 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(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
protected: protected:
//! Compute trihedron presentation. //! Compute trihedron presentation.
Standard_EXPORT void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
@ -206,12 +207,13 @@ protected:
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Dumps the content of me into the stream //! 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: protected:
//! Creates a sensitive entity for the datum part that will be used in selection owner creation. //! 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; const Handle(SelectMgr_EntityOwner)& theOwner) const;
//! Computes presentation for display mode equal 1. //! Computes presentation for display mode equal 1.
@ -222,7 +224,10 @@ protected:
Standard_EXPORT void setOwnDatumAspect(); Standard_EXPORT void setOwnDatumAspect();
//! Returns primitives. //! 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 //! Updates graphic groups for the current datum mode
//! Parameters of datum position and orientation //! 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) DEFINE_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner)
public: public:
//! Creates an owner of AIS_Trihedron object. //! Creates an owner of AIS_Trihedron object.
Standard_EXPORT AIS_TrihedronOwner(const Handle(SelectMgr_SelectableObject)& theSelObject, Standard_EXPORT AIS_TrihedronOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
const Prs3d_DatumParts theDatumPart, const Prs3d_DatumParts theDatumPart,
@ -40,7 +39,8 @@ public:
//! Returns true if the presentation manager thePM //! Returns true if the presentation manager thePM
//! highlights selections corresponding to the selection mode aMode. //! 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; const Standard_Integer theMode) const Standard_OVERRIDE;
//! Removes highlighting from the owner of a detected //! 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 // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <AIS_TypeFilter.hxx> #include <AIS_TypeFilter.hxx>
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
@ -22,8 +21,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_TypeFilter, SelectMgr_Filter) IMPLEMENT_STANDARD_RTTIEXT(AIS_TypeFilter, SelectMgr_Filter)
AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind): AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind)
myKind(TheKind){} : myKind(TheKind)
{
}
Standard_Boolean AIS_TypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const Standard_Boolean AIS_TypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{ {

View File

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

View File

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

View File

@ -52,12 +52,10 @@ namespace
} }
return aNbComps; return aNbComps;
} }
} } // namespace
//=================================================================================================
//=======================================================================
//function : AIS_ViewCubeSensitive
//purpose :
//=======================================================================
AIS_ViewCubeSensitive::AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner, AIS_ViewCubeSensitive::AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(Graphic3d_ArrayOfTriangles)& theTris) const Handle(Graphic3d_ArrayOfTriangles)& theTris)
: Select3D_SensitivePrimitiveArray(theOwner) : Select3D_SensitivePrimitiveArray(theOwner)
@ -65,20 +63,16 @@ AIS_ViewCubeSensitive::AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner
InitTriangulation(theTris->Attributes(), theTris->Indices(), TopLoc_Location()); InitTriangulation(theTris->Attributes(), theTris->Indices(), TopLoc_Location());
} }
//======================================================================= //=================================================================================================
//function : Matches
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCubeSensitive::Matches(SelectBasics_SelectingVolumeManager& theMgr, Standard_Boolean AIS_ViewCubeSensitive::Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) SelectBasics_PickResult& thePickResult)
{ {
return isValidRay(theMgr) && Select3D_SensitivePrimitiveArray::Matches(theMgr, thePickResult); return isValidRay(theMgr) && Select3D_SensitivePrimitiveArray::Matches(theMgr, thePickResult);
} }
//======================================================================= //=================================================================================================
//function : isValidRay
//purpose :
//=======================================================================
bool AIS_ViewCubeSensitive::isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const bool AIS_ViewCubeSensitive::isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const
{ {
if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point) if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point)
@ -97,37 +91,29 @@ bool AIS_ViewCubeSensitive::isValidRay (const SelectBasics_SelectingVolumeManage
return true; return true;
} }
//======================================================================= //=================================================================================================
//function : IsBoxSide
//purpose :
//=======================================================================
bool AIS_ViewCube::IsBoxSide(V3d_TypeOfOrientation theOrient) bool AIS_ViewCube::IsBoxSide(V3d_TypeOfOrientation theOrient)
{ {
return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 1; return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 1;
} }
//======================================================================= //=================================================================================================
//function : IsBoxEdge
//purpose :
//=======================================================================
bool AIS_ViewCube::IsBoxEdge(V3d_TypeOfOrientation theOrient) bool AIS_ViewCube::IsBoxEdge(V3d_TypeOfOrientation theOrient)
{ {
return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 2; return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 2;
} }
//======================================================================= //=================================================================================================
//function : IsBoxCorner
//purpose :
//=======================================================================
bool AIS_ViewCube::IsBoxCorner(V3d_TypeOfOrientation theOrient) bool AIS_ViewCube::IsBoxCorner(V3d_TypeOfOrientation theOrient)
{ {
return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 3; return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 3;
} }
//======================================================================= //=================================================================================================
//function : AIS_ViewCube
//purpose :
//=======================================================================
AIS_ViewCube::AIS_ViewCube() AIS_ViewCube::AIS_ViewCube()
: myBoxEdgeAspect(new Prs3d_ShadingAspect()), : myBoxEdgeAspect(new Prs3d_ShadingAspect()),
myBoxCornerAspect(new Prs3d_ShadingAspect()), myBoxCornerAspect(new Prs3d_ShadingAspect()),
@ -157,7 +143,9 @@ AIS_ViewCube::AIS_ViewCube()
myInfiniteState = true; myInfiniteState = true;
myIsMutable = true; myIsMutable = true;
myDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost); 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->SetTextAspect(new Prs3d_TextAspect());
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
@ -185,10 +173,8 @@ AIS_ViewCube::AIS_ViewCube()
SetSize(70.0); SetSize(70.0);
} }
//======================================================================= //=================================================================================================
//function : setDefaultAttributes
//purpose :
//=======================================================================
void AIS_ViewCube::setDefaultAttributes() void AIS_ViewCube::setDefaultAttributes()
{ {
myDrawer->TextAspect()->SetHorizontalJustification(Graphic3d_HTA_CENTER); myDrawer->TextAspect()->SetHorizontalJustification(Graphic3d_HTA_CENTER);
@ -220,10 +206,8 @@ void AIS_ViewCube::setDefaultAttributes()
myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30); myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30);
} }
//======================================================================= //=================================================================================================
//function : setDefaultHighlightAttributes
//purpose :
//=======================================================================
void AIS_ViewCube::setDefaultHighlightAttributes() void AIS_ViewCube::setDefaultHighlightAttributes()
{ {
Graphic3d_MaterialAspect aHighlightMaterial; Graphic3d_MaterialAspect aHighlightMaterial;
@ -239,12 +223,9 @@ void AIS_ViewCube::setDefaultHighlightAttributes()
myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1); 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) if (myIsYup == theIsYup)
{ {
@ -253,18 +234,18 @@ void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
myIsYup = theIsYup; myIsYup = theIsYup;
static const V3d_TypeOfOrientation THE_ZUP_ORI_LIST[6] = static const V3d_TypeOfOrientation THE_ZUP_ORI_LIST[6] = {V3d_TypeOfOrientation_Zup_Front,
{ V3d_TypeOfOrientation_Zup_Back,
V3d_TypeOfOrientation_Zup_Front, V3d_TypeOfOrientation_Zup_Back, V3d_TypeOfOrientation_Zup_Top,
V3d_TypeOfOrientation_Zup_Top, V3d_TypeOfOrientation_Zup_Bottom, V3d_TypeOfOrientation_Zup_Bottom,
V3d_TypeOfOrientation_Zup_Left, V3d_TypeOfOrientation_Zup_Right V3d_TypeOfOrientation_Zup_Left,
}; V3d_TypeOfOrientation_Zup_Right};
static const V3d_TypeOfOrientation THE_YUP_ORI_LIST[6] = static const V3d_TypeOfOrientation THE_YUP_ORI_LIST[6] = {V3d_TypeOfOrientation_Yup_Front,
{ V3d_TypeOfOrientation_Yup_Back,
V3d_TypeOfOrientation_Yup_Front, V3d_TypeOfOrientation_Yup_Back, V3d_TypeOfOrientation_Yup_Top,
V3d_TypeOfOrientation_Yup_Top, V3d_TypeOfOrientation_Yup_Bottom, V3d_TypeOfOrientation_Yup_Bottom,
V3d_TypeOfOrientation_Yup_Left, V3d_TypeOfOrientation_Yup_Right V3d_TypeOfOrientation_Yup_Left,
}; V3d_TypeOfOrientation_Yup_Right};
if (theToUpdateLabels) if (theToUpdateLabels)
{ {
NCollection_Array1<TCollection_AsciiString> aLabels(0, 5); NCollection_Array1<TCollection_AsciiString> aLabels(0, 5);
@ -283,10 +264,8 @@ void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
SetToUpdate(); SetToUpdate();
} }
//======================================================================= //=================================================================================================
//function : ResetStyles
//purpose :
//=======================================================================
void AIS_ViewCube::ResetStyles() void AIS_ViewCube::ResetStyles()
{ {
UnsetAttributes(); UnsetAttributes();
@ -306,12 +285,9 @@ void AIS_ViewCube::ResetStyles()
SetSize(70.0); 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(); const bool isNewSize = Abs(mySize - theValue) > Precision::Confusion();
mySize = theValue; mySize = theValue;
@ -333,10 +309,8 @@ void AIS_ViewCube::SetSize (Standard_Real theValue,
} }
} }
//======================================================================= //=================================================================================================
//function : SetRoundRadius
//purpose :
//=======================================================================
void AIS_ViewCube::SetRoundRadius(const Standard_Real theValue) void AIS_ViewCube::SetRoundRadius(const Standard_Real theValue)
{ {
Standard_OutOfRange_Raise_if(theValue < 0.0 || theValue > 0.5, 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, void AIS_ViewCube::createRoundRectangleTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes, Standard_Integer& theNbNodes,
Standard_Integer& theNbTris, 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)); theTris->AddVertex(gp_Pnt(0.0, 0.0, 0.0).Transformed(theTrsf));
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter) 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)); const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
theTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf)); 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) 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)); const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
theTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf)); 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) 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)); const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
theTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf)); -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) 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)); const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
theTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf)); -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 // 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); 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); theTris->SetVertexNormal(aVertIter, -aNorm);
} }
} }
//======================================================================= //=================================================================================================
//function : createBoxPartTriangles
//purpose :
//=======================================================================
void AIS_ViewCube::createBoxPartTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris, void AIS_ViewCube::createBoxPartTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes, Standard_Integer& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
@ -433,22 +424,18 @@ void AIS_ViewCube::createBoxPartTriangles (const Handle(Graphic3d_ArrayOfTriangl
{ {
createBoxSideTriangles(theTris, theNbNodes, theNbTris, theDir); createBoxSideTriangles(theTris, theNbNodes, theNbTris, theDir);
} }
else if (IsBoxEdge (theDir) else if (IsBoxEdge(theDir) && myToDisplayEdges)
&& myToDisplayEdges)
{ {
createBoxEdgeTriangles(theTris, theNbNodes, theNbTris, theDir); createBoxEdgeTriangles(theTris, theNbNodes, theNbTris, theDir);
} }
else if (IsBoxCorner (theDir) else if (IsBoxCorner(theDir) && myToDisplayVertices)
&& myToDisplayVertices)
{ {
createBoxCornerTriangles(theTris, theNbNodes, theNbTris, theDir); createBoxCornerTriangles(theTris, theNbNodes, theNbTris, theDir);
} }
} }
//======================================================================= //=================================================================================================
//function : createBoxSideTriangles
//purpose :
//=======================================================================
void AIS_ViewCube::createBoxSideTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris, void AIS_ViewCube::createBoxSideTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes, Standard_Integer& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
@ -462,37 +449,43 @@ void AIS_ViewCube::createBoxSideTriangles (const Handle(Graphic3d_ArrayOfTriangl
gp_Trsf aTrsf; gp_Trsf aTrsf;
aTrsf.SetTransformation(aSystem, gp_Ax3()); aTrsf.SetTransformation(aSystem, gp_Ax3());
createRoundRectangleTriangles (theTris, theNbNodes, theNbTris, createRoundRectangleTriangles(theTris,
gp_XY (mySize, mySize), myRoundRadius * mySize, aTrsf); theNbNodes,
theNbTris,
gp_XY(mySize, mySize),
myRoundRadius * mySize,
aTrsf);
} }
//======================================================================= //=================================================================================================
//function : createBoxEdgeTriangles
//purpose :
//=======================================================================
void AIS_ViewCube::createBoxEdgeTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris, void AIS_ViewCube::createBoxEdgeTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes, Standard_Integer& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDirection) const 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_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()); const gp_Ax2 aPosition(aPos, aDir.Reversed());
gp_Ax3 aSystem(aPosition); gp_Ax3 aSystem(aPosition);
gp_Trsf aTrsf; gp_Trsf aTrsf;
aTrsf.SetTransformation(aSystem, gp_Ax3()); aTrsf.SetTransformation(aSystem, gp_Ax3());
createRoundRectangleTriangles (theTris, theNbNodes, theNbTris, createRoundRectangleTriangles(theTris,
gp_XY (aThickness, mySize), myRoundRadius * mySize, aTrsf); theNbNodes,
theNbTris,
gp_XY(aThickness, mySize),
myRoundRadius * mySize,
aTrsf);
} }
//======================================================================= //=================================================================================================
//function : createBoxCornerTriangles
//purpose :
//=======================================================================
void AIS_ViewCube::createBoxCornerTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris, void AIS_ViewCube::createBoxCornerTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes, Standard_Integer& theNbNodes,
Standard_Integer& theNbTris, 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)); theTris->AddVertex(gp_Pnt(0.0, 0.0, 0.0).Transformed(aTrsf));
for (Standard_Integer aNodeIter = 0; aNodeIter < THE_NB_DISK_SLICES; ++aNodeIter) 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)); const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
theTris->AddVertex (gp_Pnt (aRadius * Cos (anAngle), aRadius * Sin (anAngle), 0.0).Transformed (aTrsf)); 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); 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); theTris->SetVertexNormal(aVertIter, aDir);
} }
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ViewCube::Compute(const Handle(PrsMgr_PresentationManager)&, void AIS_ViewCube::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -575,14 +571,16 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
return; 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 // Display axes
if (myToDisplayAxes) if (myToDisplayAxes)
{ {
const Standard_Real anAxisSize = mySize + 2.0 * myBoxFacetExtension + myAxesPadding; const Standard_Real anAxisSize = mySize + 2.0 * myBoxFacetExtension + myAxesPadding;
const Handle(Prs3d_DatumAspect)& aDatumAspect = myDrawer->DatumAspect(); 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; const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!aDatumAspect->DrawDatumPart(aPart)) if (!aDatumAspect->DrawDatumPart(aPart))
@ -593,10 +591,17 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
gp_Ax1 anAx1; gp_Ax1 anAx1;
switch (aPart) switch (aPart)
{ {
case Prs3d_DatumParts_XAxis: anAx1 = gp_Ax1 (aLocation, gp::DX()); break; case Prs3d_DatumParts_XAxis:
case Prs3d_DatumParts_YAxis: anAx1 = gp_Ax1 (aLocation, gp::DY()); break; anAx1 = gp_Ax1(aLocation, gp::DX());
case Prs3d_DatumParts_ZAxis: anAx1 = gp_Ax1 (aLocation, gp::DZ()); break; break;
default: 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(); Handle(Graphic3d_Group) anAxisGroup = thePrs->NewGroup();
@ -604,19 +609,28 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
anAxisGroup->SetGroupPrimitivesAspect(aDatumAspect->ShadingAspect(aPart)->Aspect()); anAxisGroup->SetGroupPrimitivesAspect(aDatumAspect->ShadingAspect(aPart)->Aspect());
const Standard_Real anArrowLength = 0.2 * anAxisSize; 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); anAxisGroup->AddPrimitiveArray(aTriangleArray);
TCollection_AsciiString anAxisLabel; TCollection_AsciiString anAxisLabel;
if (aDatumAspect->ToDrawLabels() if (aDatumAspect->ToDrawLabels() && myAxesLabels.Find(aPart, anAxisLabel)
&& myAxesLabels.Find (aPart, anAxisLabel)
&& !anAxisLabel.IsEmpty()) && !anAxisLabel.IsEmpty())
{ {
Handle(Graphic3d_Group) anAxisLabelGroup = thePrs->NewGroup(); 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().Y() * (anAxisSize + anArrowLength),
anAx1.Direction().Z() * (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 // Display box sides
{ {
Standard_Integer aNbNodes = 0, aNbTris = 0; 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) 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; Handle(Graphic3d_ArrayOfSegments) aSegs;
if (myDrawer->FaceBoundaryDraw()) if (myDrawer->FaceBoundaryDraw())
{ {
aSegs = new Graphic3d_ArrayOfSegments(aNbNodes, aNbNodes * 2, Graphic3d_ArrayFlags_None); aSegs = new Graphic3d_ArrayOfSegments(aNbNodes, aNbNodes * 2, Graphic3d_ArrayFlags_None);
} }
aNbNodes = aNbTris = 0; 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(); Standard_Integer aTriNodesFrom = aTris->VertexNumber();
const Standard_Integer aTriFrom = aNbTris; const Standard_Integer aTriFrom = aNbTris;
@ -666,7 +686,8 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// clang-format off // clang-format off
for (Standard_Integer aVertIter = (aNbTris - aTriFrom) > 2 ? aTriNodesFrom + 2 : aTriNodesFrom + 1; // skip triangle fan center for (Standard_Integer aVertIter = (aNbTris - aTriFrom) > 2 ? aTriNodesFrom + 2 : aTriNodesFrom + 1; // skip triangle fan center
// clang-format on // clang-format on
aVertIter <= aTris->VertexNumber(); ++aVertIter) aVertIter <= aTris->VertexNumber();
++aVertIter)
{ {
aSegs->AddVertex(aTris->Vertice(aVertIter)); aSegs->AddVertex(aTris->Vertice(aVertIter));
} }
@ -691,13 +712,13 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box sides labels // Display box sides labels
Handle(Graphic3d_Group) aTextGroup = thePrs->NewGroup(); Handle(Graphic3d_Group) aTextGroup = thePrs->NewGroup();
aTextGroup->SetGroupPrimitivesAspect(myDrawer->TextAspect()->Aspect()); 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; const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation)aPartIter;
TCollection_AsciiString aLabel; TCollection_AsciiString aLabel;
if (!myBoxSideLabels.Find (anOrient, aLabel) if (!myBoxSideLabels.Find(anOrient, aLabel) || aLabel.IsEmpty())
|| aLabel.IsEmpty())
{ {
continue; continue;
} }
@ -706,8 +727,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
gp_Dir anUp = myIsYup ? gp::DY() : gp::DZ(); gp_Dir anUp = myIsYup ? gp::DY() : gp::DZ();
if (myIsYup) if (myIsYup)
{ {
if (anOrient == V3d_Ypos if (anOrient == V3d_Ypos || anOrient == V3d_Yneg)
|| anOrient == V3d_Yneg)
{ {
anUp = -gp::DZ(); 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_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension + anOffset);
const gp_Ax2 aPosition(aPos, aDir, anUp.Crossed(aDir)); 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->SetText(aLabel);
aText->SetOrientation(aPosition); aText->SetOrientation(aPosition);
aText->SetOwnAnchorPoint(false); aText->SetOwnAnchorPoint(false);
@ -741,15 +762,21 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box edges // Display box edges
{ {
Standard_Integer aNbNodes = 0, aNbTris = 0; 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) 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; 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; const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation)aPartIter;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOrient); createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOrient);
@ -765,15 +792,23 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box corners // Display box corners
{ {
Standard_Integer aNbNodes = 0, aNbTris = 0; 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) 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; 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; const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation)aPartIter;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOrient); 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, void AIS_ViewCube::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
@ -809,7 +842,8 @@ void AIS_ViewCube::ComputeSelection (const Handle(SelectMgr_Selection)& theSelec
continue; 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; aNbNodes = aNbTris = 0;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOri); 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 Standard_Real AIS_ViewCube::Duration() const
{ {
return myViewAnimation->OwnDuration(); return myViewAnimation->OwnDuration();
} }
//======================================================================= //=================================================================================================
//function : SetDuration
//purpose :
//=======================================================================
void AIS_ViewCube::SetDuration(Standard_Real theDurationSec) void AIS_ViewCube::SetDuration(Standard_Real theDurationSec)
{ {
myViewAnimation->SetOwnDuration(theDurationSec); myViewAnimation->SetOwnDuration(theDurationSec);
} }
//======================================================================= //=================================================================================================
//function : HasAnimation
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCube::HasAnimation() const Standard_Boolean AIS_ViewCube::HasAnimation() const
{ {
return !myViewAnimation->IsStopped(); return !myViewAnimation->IsStopped();
} }
//======================================================================= //=================================================================================================
//function : viewFitAll
//purpose :
//=======================================================================
void AIS_ViewCube::viewFitAll(const Handle(V3d_View)& theView, void AIS_ViewCube::viewFitAll(const Handle(V3d_View)& theView,
const Handle(Graphic3d_Camera)& theCamera) const Handle(Graphic3d_Camera)& theCamera)
{ {
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection (theView) : theView->View()->MinMaxValues(); Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection(theView)
if (aBndBox.IsVoid() : theView->View()->MinMaxValues();
&& myToFitSelected) if (aBndBox.IsVoid() && myToFitSelected)
{ {
aBndBox = theView->View()->MinMaxValues(); 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) void AIS_ViewCube::StartAnimation(const Handle(AIS_ViewCubeOwner)& theOwner)
{ {
Handle(V3d_View) aView = GetContext()->LastActiveView(); Handle(V3d_View) aView = GetContext()->LastActiveView();
if (theOwner.IsNull() if (theOwner.IsNull() || aView.IsNull())
|| aView.IsNull())
{ {
return; return;
} }
@ -902,14 +925,12 @@ void AIS_ViewCube::StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner)
} }
const gp_Dir aNewDir = myEndState->Direction(); const gp_Dir aNewDir = myEndState->Direction();
if (!myToResetCameraUp if (!myToResetCameraUp && !aNewDir.IsEqual(myStartState->Direction(), Precision::Angular()))
&& !aNewDir.IsEqual (myStartState->Direction(), Precision::Angular()))
{ {
// find the Up direction closest to current instead of default one // find the Up direction closest to current instead of default one
const gp_Ax1 aNewDirAx1(gp::Origin(), aNewDir); const gp_Ax1 aNewDirAx1(gp::Origin(), aNewDir);
const gp_Dir anOldUp = myStartState->Up(); const gp_Dir anOldUp = myStartState->Up();
const gp_Dir anUpList[4] = const gp_Dir anUpList[4] = {
{
myEndState->Up(), myEndState->Up(),
myEndState->Up().Rotated(aNewDirAx1, M_PI_2), myEndState->Up().Rotated(aNewDirAx1, M_PI_2),
myEndState->Up().Rotated(aNewDirAx1, M_PI), 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); myViewAnimation->StartTimer(0.0, 1.0, true, false);
} }
//======================================================================= //=================================================================================================
//function : updateAnimation
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCube::updateAnimation() Standard_Boolean AIS_ViewCube::updateAnimation()
{ {
const Standard_Real aPts = myViewAnimation->UpdateTimer(); const Standard_Real aPts = myViewAnimation->UpdateTimer();
@ -956,21 +975,17 @@ Standard_Boolean AIS_ViewCube::updateAnimation()
return Standard_True; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : UpdateAnimation
//purpose :
//=======================================================================
Standard_Boolean AIS_ViewCube::UpdateAnimation(const Standard_Boolean theToUpdate) Standard_Boolean AIS_ViewCube::UpdateAnimation(const Standard_Boolean theToUpdate)
{ {
Handle(V3d_View) aView = myViewAnimation->View(); Handle(V3d_View) aView = myViewAnimation->View();
if (!HasAnimation() if (!HasAnimation() || !updateAnimation())
|| !updateAnimation())
{ {
return Standard_False; return Standard_False;
} }
if (theToUpdate if (theToUpdate && !aView.IsNull())
&& !aView.IsNull())
{ {
aView->IsInvalidated() ? aView->Redraw() : aView->RedrawImmediate(); aView->IsInvalidated() ? aView->Redraw() : aView->RedrawImmediate();
} }
@ -979,10 +994,8 @@ Standard_Boolean AIS_ViewCube::UpdateAnimation (const Standard_Boolean theToUpda
return Standard_True; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : HandleClick
//purpose :
//=======================================================================
void AIS_ViewCube::HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner) void AIS_ViewCube::HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner)
{ {
if (!myToAutoStartAnim) 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, void AIS_ViewCube::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) const Handle(SelectMgr_EntityOwner)& theOwner)
{ {
if (theOwner.IsNull() if (theOwner.IsNull() || !thePrsMgr->IsImmediateModeOn())
|| !thePrsMgr->IsImmediateModeOn())
{ {
return; 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()); const AIS_ViewCubeOwner* aCubeOwner = dynamic_cast<AIS_ViewCubeOwner*>(theOwner.get());
Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation(thePrsMgr); Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation(thePrsMgr);
@ -1028,10 +1039,14 @@ void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManage
Handle(Graphic3d_Group) aGroup = aHiPrs->NewGroup(); Handle(Graphic3d_Group) aGroup = aHiPrs->NewGroup();
aGroup->SetGroupPrimitivesAspect(theStyle->ShadingAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect(theStyle->ShadingAspect()->Aspect());
Standard_Integer aNbNodes = 0, aNbTris = 0; 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) 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; aNbNodes = aNbTris = 0;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, aCubeOwner->MainOrientation()); createBoxPartTriangles(aTris, aNbNodes, aNbTris, aCubeOwner->MainOrientation());
aGroup->AddPrimitiveArray(aTris); 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)&, void AIS_ViewCube::HilightSelected(const Handle(PrsMgr_PresentationManager)&,
const SelectMgr_SequenceOfOwner& theSeq) 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) if (theSeq.Size() == 1)
{ {
// HandleClick (Handle(AIS_ViewCubeOwner)::DownCast (theSeq.First())); // 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, //! The object is expected to behave like a trihedron in the view corner,
//! therefore its position should be defined using transformation persistence flags: //! 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), //! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
//! and every its owner AIS_ViewCubeOwner corresponds to camera transformation. //! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
@ -54,13 +55,12 @@ class V3d_View;
//! or //! or
//! @code aViewCube->HandleClick (aDetectedOwner); @endcode //! @code aViewCube->HandleClick (aDetectedOwner); @endcode
//! that includes transformation loop. //! that includes transformation loop.
//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterAnimation(), //! This loop allows external actions like application updating. For this purpose AIS_ViewCube has
//! that is to be redefined on application level. //! virtual interface onAfterAnimation(), that is to be redefined on application level.
class AIS_ViewCube : public AIS_InteractiveObject class AIS_ViewCube : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
public: public:
//! Return TRUE if specified orientation belongs to box side. //! Return TRUE if specified orientation belongs to box side.
Standard_EXPORT static bool IsBoxSide(V3d_TypeOfOrientation theOrient); Standard_EXPORT static bool IsBoxSide(V3d_TypeOfOrientation theOrient);
@ -71,7 +71,6 @@ public:
Standard_EXPORT static bool IsBoxCorner(V3d_TypeOfOrientation theOrient); Standard_EXPORT static bool IsBoxCorner(V3d_TypeOfOrientation theOrient);
public: public:
//! Empty constructor. //! Empty constructor.
Standard_EXPORT AIS_ViewCube(); Standard_EXPORT AIS_ViewCube();
@ -79,9 +78,13 @@ public:
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; } const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
//! Set view animation. //! 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; } Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
//! Enable/disable automatic camera transformation on selection (highlighting). //! Enable/disable automatic camera transformation on selection (highlighting).
@ -100,7 +103,6 @@ public:
Standard_EXPORT void ResetStyles(); Standard_EXPORT void ResetStyles();
protected: protected:
//! Set default visual attributes //! Set default visual attributes
Standard_EXPORT void setDefaultAttributes(); Standard_EXPORT void setDefaultAttributes();
@ -108,14 +110,12 @@ protected:
Standard_EXPORT void setDefaultHighlightAttributes(); Standard_EXPORT void setDefaultHighlightAttributes();
public: //! @name Geometry management API public: //! @name Geometry management API
//! @return size (width and height) of View cube sides; 100 by default. //! @return size (width and height) of View cube sides; 100 by default.
Standard_Real Size() const { return mySize; } Standard_Real Size() const { return mySize; }
//! Sets size (width and height) of View cube sides. //! Sets size (width and height) of View cube sides.
//! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size //! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
Standard_EXPORT void SetSize (Standard_Real theValue, Standard_EXPORT void SetSize(Standard_Real theValue, Standard_Boolean theToAdaptAnother = true);
Standard_Boolean theToAdaptAnother = true);
//! Return box facet extension to edge/corner facet split; 10 by default. //! Return box facet extension to edge/corner facet split; 10 by default.
Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; } Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
@ -276,7 +276,6 @@ public: //! @name Geometry management API
Standard_Boolean theToUpdateLabels = Standard_True); Standard_Boolean theToUpdateLabels = Standard_True);
public: //! @name Style management API public: //! @name Style management API
//! Return shading style of box sides. //! Return shading style of box sides.
const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); } const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
@ -323,7 +322,10 @@ public: //! @name Style management API
} }
//! Return color of sides back material. //! 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: //! Set color of sides back material. Alias for:
//! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode //! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
@ -342,8 +344,7 @@ public: //! @name Style management API
} }
//! Set box side label. //! Set box side label.
void SetBoxSideLabel (const V3d_TypeOfOrientation theSide, void SetBoxSideLabel(const V3d_TypeOfOrientation theSide, const TCollection_AsciiString& theLabel)
const TCollection_AsciiString& theLabel)
{ {
if (!IsBoxSide(theSide)) if (!IsBoxSide(theSide))
{ {
@ -410,13 +411,9 @@ public: //! @name Style management API
} }
public: public:
//! Set new value of color for the whole object. //! Set new value of color for the whole object.
//! @param[in] theColor input color value. //! @param[in] theColor input color value.
virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE { SetBoxColor(theColor); }
{
SetBoxColor (theColor);
}
//! Reset color for the whole object. //! Reset color for the whole object.
virtual void UnsetColor() Standard_OVERRIDE virtual void UnsetColor() Standard_OVERRIDE
@ -435,10 +432,7 @@ public:
} }
//! Reset transparency for the whole object. //! Reset transparency for the whole object.
virtual void UnsetTransparency() Standard_OVERRIDE virtual void UnsetTransparency() Standard_OVERRIDE { SetBoxTransparency(0.0f); }
{
SetBoxTransparency (0.0f);
}
//! Sets the material for the interactive object. //! Sets the material for the interactive object.
virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
@ -464,7 +458,6 @@ public:
} }
public: //! @name animation methods public: //! @name animation methods
//! Return duration of animation in seconds; 0.5 sec by default //! Return duration of animation in seconds; 0.5 sec by default
Standard_EXPORT Standard_Real Duration() const; Standard_EXPORT Standard_Real Duration() const;
@ -472,15 +465,17 @@ public: //! @name animation methods
//! @param[in] theValue input value of duration in seconds //! @param[in] theValue input value of duration in seconds
Standard_EXPORT void SetDuration(Standard_Real theValue); 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. //! Return TRUE if new camera Up direction should be always set to default value for a new camera
//! When this flag is FALSE, the new camera Up will be set as current Up orthogonalized to the new camera Direction, //! Direction; FALSE by default. When this flag is FALSE, the new camera Up will be set as current
//! and will set to default Up on second click. //! Up orthogonalized to the new camera Direction, and will set to default Up on second click.
Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; } 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; } 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; } Standard_Boolean ToFitSelected() const { return myToFitSelected; }
//! Set if animation should fit selected objects or to fit entire scene. //! 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); Standard_EXPORT virtual void HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner);
protected: protected:
//! Perform internal single step of animation. //! Perform internal single step of animation.
//! @return FALSE if animation has been finished //! @return FALSE if animation has been finished
Standard_EXPORT Standard_Boolean updateAnimation(); Standard_EXPORT Standard_Boolean updateAnimation();
@ -514,7 +508,6 @@ protected:
const Handle(Graphic3d_Camera)& theCamera); const Handle(Graphic3d_Camera)& theCamera);
protected: //! @name protected virtual API protected: //! @name protected virtual API
//! Method that is called after one step of transformation. //! Method that is called after one step of transformation.
virtual void onAfterAnimation() {} virtual void onAfterAnimation() {}
@ -522,12 +515,17 @@ protected: //! @name protected virtual API
virtual void onAnimationFinished() {} virtual void onAnimationFinished() {}
public: //! @name Presentation computation public: //! @name Presentation computation
//! Return TRUE for supported display mode. //! 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. //! 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. //! Compute 3D part of View Cube.
//! @param[in] thePrsMgr presentation manager. //! @param[in] thePrsMgr presentation manager.
@ -545,7 +543,8 @@ public: //! @name Presentation computation
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE; 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; } virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
//! Method which clear all selected owners belonging to this selectable object. //! 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] thePM presentation manager
//! @param[in] theStyle style for dynamic highlighting. //! @param[in] theStyle style for dynamic highlighting.
//! @param[in] theOwner input entity owner. //! @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(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
//! Method which draws selected owners. //! Method which draws selected owners.
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM, 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 //! Set default parameters for visual attributes
//! @sa Attributes() //! @sa Attributes()
@ -581,57 +582,70 @@ public: //! @name Presentation computation
} }
protected: //! @name Auxiliary classes to fill presentation with proper primitives protected: //! @name Auxiliary classes to fill presentation with proper primitives
//! Create triangulation for a box part - for presentation and selection purposes. //! Create triangulation for a box part - for presentation and selection purposes.
//! @param theTris [in,out] triangulation to fill, or NULL to return size //! @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 theNbNodes [in,out] should be incremented by a number of nodes defining this
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation //! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define //! @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& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const; V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box side. //! Create triangulation for a box side.
//! @param theTris [in,out] triangulation to fill, or NULL to return size //! @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 theNbNodes [in,out] should be incremented by a number of nodes defining this
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation //! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define //! @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& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const; V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box edge. //! Create triangulation for a box edge.
//! @param theTris [in,out] triangulation to fill, or NULL to return size //! @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 theNbNodes [in,out] should be incremented by a number of nodes defining this
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation //! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define //! @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& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const; V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box corner (vertex). //! Create triangulation for a box corner (vertex).
//! @param theTris [in,out] triangulation to fill, or NULL to return size //! @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 theNbNodes [in,out] should be incremented by a number of nodes defining this
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation //! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define //! @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& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const; V3d_TypeOfOrientation theDir) const;
protected: protected:
//! Create triangulation for a rectangle with round corners. //! Create triangulation for a rectangle with round corners.
//! @param theTris [in,out] triangulation to fill, or NULL to return size //! @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 theNbNodes [in,out] should be incremented by a number of nodes defining this
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation //! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theSize rectangle dimensions //! @param[in] theSize rectangle dimensions
//! @param[in] theRadius radius at corners //! @param[in] theRadius radius at corners
//! @param[in] theTrsf transformation //! @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& theNbNodes,
Standard_Integer& theNbTris, Standard_Integer& theNbTris,
const gp_XY& theSize, const gp_XY& theSize,
@ -639,7 +653,6 @@ protected:
const gp_Trsf& theTrsf); const gp_Trsf& theTrsf);
protected: protected:
NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString> NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString>
myBoxSideLabels; //!< map with box side labels myBoxSideLabels; //!< map with box side labels
NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString> NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
@ -665,7 +678,6 @@ protected:
// clang-format on // clang-format on
protected: //! @name Animation options protected: //! @name Animation options
Handle(AIS_AnimationCamera) myViewAnimation; //!< Camera animation object Handle(AIS_AnimationCamera) myViewAnimation; //!< Camera animation object
Handle(Graphic3d_Camera) myStartState; //!< Start state of view camera Handle(Graphic3d_Camera) myStartState; //!< Start state of view camera
Handle(Graphic3d_Camera) myEndState; //!< End state of view camera Handle(Graphic3d_Camera) myEndState; //!< End state of view camera
@ -675,7 +687,6 @@ protected: //! @name Animation options
// clang-format off // clang-format off
Standard_Boolean myToResetCameraUp; //!< always reset camera up direction to default Standard_Boolean myToResetCameraUp; //!< always reset camera up direction to default
// clang-format on // clang-format on
}; };
//! Redefined entity owner that is highlighted when owner is detected, //! 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) DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
public: public:
//! Main constructor. //! Main constructor.
AIS_ViewCubeOwner(const Handle(AIS_ViewCube)& theObject, AIS_ViewCubeOwner(const Handle(AIS_ViewCube)& theObject,
V3d_TypeOfOrientation theOrient, V3d_TypeOfOrientation theOrient,
@ -708,16 +718,17 @@ public:
Aspect_VKeyFlags theModifiers, Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick) Standard_OVERRIDE 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); AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube*>(mySelectable);
aCubePrs->HandleClick(this); aCubePrs->HandleClick(this);
return Standard_True; return Standard_True;
} }
protected: protected:
V3d_TypeOfOrientation myMainOrient; //!< new orientation to set V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
}; };
//! Simple sensitive element for picking by point only. //! 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) DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
public: public:
//! Constructor. //! Constructor.
Standard_EXPORT AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner, Standard_EXPORT AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(Graphic3d_ArrayOfTriangles)& theTris); const Handle(Graphic3d_ArrayOfTriangles)& theTris);
//! Checks whether element overlaps current selecting volume. //! Checks whether element overlaps current selecting volume.
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr, Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; SelectBasics_PickResult& thePickResult)
Standard_OVERRIDE;
protected: protected:
//! Checks if picking ray can be used for detection. //! Checks if picking ray can be used for detection.
Standard_EXPORT bool isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const; Standard_EXPORT bool isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const;
}; };
#endif // _AIS_ViewCube_HeaderFile #endif // _AIS_ViewCube_HeaderFile

View File

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

View File

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

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