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,51 +18,44 @@
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)
//============================================================================= : myName(theAnimationName),
AIS_Animation::AIS_Animation (const TCollection_AsciiString& theAnimationName) myState(AnimationState_Stopped),
: myName (theAnimationName), myPtsStart(0.0),
myState (AnimationState_Stopped), myOwnDuration(0.0),
myPtsStart (0.0), myChildrenDuration(0.0)
myOwnDuration (0.0),
myChildrenDuration (0.0)
{ {
// //
} }
//============================================================================= //=================================================================================================
//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())
{ {
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)
{ {
@ -71,17 +64,16 @@ void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
} }
} }
myAnimations.Append (theAnimation); myAnimations.Append(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,17 +83,16 @@ 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)
{ {
myAnimations.Remove (anIter); myAnimations.Remove(anIter);
UpdateTotalDuration(); UpdateTotalDuration();
return Standard_True; return Standard_True;
} }
@ -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,
//============================================================================= const Handle(AIS_Animation)& theAnimationNew)
Standard_Boolean AIS_Animation::Replace (const Handle(AIS_Animation)& theAnimationOld,
const Handle(AIS_Animation)& theAnimationNew)
{ {
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
if (anIter.Value() == theAnimationOld) if (anIter.Value() == theAnimationOld)
{ {
@ -128,63 +118,59 @@ 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());
} }
UpdateTotalDuration(); UpdateTotalDuration();
myPtsStart = theOther->myPtsStart; myPtsStart = theOther->myPtsStart;
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,
//============================================================================= const Standard_Real thePlaySpeed,
void AIS_Animation::StartTimer (const Standard_Real theStartPts, const Standard_Boolean theToUpdate,
const Standard_Real thePlaySpeed, const Standard_Boolean theToStopTimer)
const Standard_Boolean theToUpdate,
const Standard_Boolean theToStopTimer)
{ {
if (myTimer.IsNull()) if (myTimer.IsNull())
{ {
myTimer = new Media_Timer(); myTimer = new Media_Timer();
} }
myTimer->Stop(); myTimer->Stop();
myTimer->Seek (theStartPts); myTimer->Seek(theStartPts);
myTimer->SetPlaybackSpeed (thePlaySpeed); myTimer->SetPlaybackSpeed(thePlaySpeed);
Start (theToUpdate); Start(theToUpdate);
if (theToStopTimer) if (theToStopTimer)
{ {
myTimer->Stop(); myTimer->Stop();
myTimer->Seek (theStartPts); myTimer->Seek(theStartPts);
} }
} }
//============================================================================= //=================================================================================================
//function : UpdateTimer
//purpose :
//=============================================================================
Standard_Real AIS_Animation::UpdateTimer() Standard_Real AIS_Animation::UpdateTimer()
{ {
if (myTimer.IsNull()) if (myTimer.IsNull())
@ -193,29 +179,26 @@ Standard_Real AIS_Animation::UpdateTimer()
} }
const Standard_Real anElapsedTime = myTimer->ElapsedTime(); const Standard_Real anElapsedTime = myTimer->ElapsedTime();
Update (anElapsedTime); Update(anElapsedTime);
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() Update(anElapsedTime);
: 0.0;
Update (anElapsedTime);
} }
if (!myTimer.IsNull()) if (!myTimer.IsNull())
@ -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;
@ -253,56 +233,50 @@ void AIS_Animation::Stop()
{ {
const Standard_Real anElapsedTime = ElapsedTime(); const Standard_Real anElapsedTime = ElapsedTime();
myTimer->Stop(); myTimer->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) aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
: 0.0; aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
aPosition.LocalNormalized = Max (0.0, aPosition.LocalNormalized); updateWithChildren(aPosition);
aPosition.LocalNormalized = Min (1.0, aPosition.LocalNormalized);
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);
} }
if (thePosition.LocalPts >= Duration()) if (thePosition.LocalPts >= Duration())
@ -310,5 +284,5 @@ void AIS_Animation::updateWithChildren (const AIS_AnimationProgress& thePosition
Stop(); Stop();
} }
update (thePosition); update(thePosition);
} }

View File

@ -22,13 +22,18 @@
//! Structure defining current animation progress. //! Structure defining current animation progress.
struct AIS_AnimationProgress struct AIS_AnimationProgress
{ {
Standard_Real Pts; //!< global presentation timestamp Standard_Real Pts; //!< global presentation timestamp
Standard_Real LocalPts; //!< presentation within current animation Standard_Real LocalPts; //!< presentation within current animation
// clang-format off // clang-format off
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,38 +43,43 @@ 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);
//! Destruct object, clear arguments //! Destruct object, clear arguments
Standard_EXPORT virtual ~AIS_Animation(); Standard_EXPORT virtual ~AIS_Animation();
@ -78,15 +88,14 @@ 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; }
//! Sets time limits for animation in the animation timeline //! Sets time limits for animation in the animation timeline
void SetStartPts (const Standard_Real thePtsStart) { myPtsStart = thePtsStart; } void SetStartPts(const Standard_Real thePtsStart) { myPtsStart = thePtsStart; }
//! @return duration of the animation in the timeline //! @return duration of the animation in the timeline
Standard_Real Duration() const { return Max (myOwnDuration, myChildrenDuration); } Standard_Real Duration() const { return Max(myOwnDuration, myChildrenDuration); }
//! Update total duration considering all animations on timeline. //! Update total duration considering all animations on timeline.
Standard_EXPORT void UpdateTotalDuration(); Standard_EXPORT void UpdateTotalDuration();
@ -98,49 +107,50 @@ public:
Standard_Real OwnDuration() const { return myOwnDuration; } Standard_Real OwnDuration() const { return myOwnDuration; }
//! Defines duration of the animation. //! Defines duration of the animation.
void SetOwnDuration (const Standard_Real theDuration) { myOwnDuration = theDuration; } void SetOwnDuration(const Standard_Real theDuration) { myOwnDuration = theDuration; }
//! Add single animation to the timeline. //! Add single animation to the timeline.
//! @param theAnimation input animation //! @param theAnimation input animation
Standard_EXPORT void Add (const Handle(AIS_Animation)& theAnimation); Standard_EXPORT void Add(const Handle(AIS_Animation)& theAnimation);
//! Clear animation timeline - remove all animations from it. //! Clear animation timeline - remove all animations from it.
Standard_EXPORT void Clear(); Standard_EXPORT void Clear();
//! Return the child animation with the given name. //! Return the child animation with the given name.
Standard_EXPORT Handle(AIS_Animation) Find (const TCollection_AsciiString& theAnimationName) const; Standard_EXPORT Handle(AIS_Animation) Find(const TCollection_AsciiString& theAnimationName) const;
//! Remove the child animation. //! Remove the child animation.
Standard_EXPORT Standard_Boolean Remove (const Handle(AIS_Animation)& theAnimation); Standard_EXPORT Standard_Boolean Remove(const Handle(AIS_Animation)& theAnimation);
//! Replace the child animation. //! Replace the child animation.
Standard_EXPORT Standard_Boolean Replace (const Handle(AIS_Animation)& theAnimationOld, Standard_EXPORT Standard_Boolean Replace(const Handle(AIS_Animation)& theAnimationOld,
const Handle(AIS_Animation)& theAnimationNew); const Handle(AIS_Animation)& theAnimationNew);
//! Clears own children and then copy child animations from another object. //! Clears own children and then copy child animations from another object.
//! Copy also Start Time and Duration values. //! Copy also Start Time and Duration values.
Standard_EXPORT void CopyFrom (const Handle(AIS_Animation)& theOther); Standard_EXPORT void CopyFrom(const Handle(AIS_Animation)& theOther);
//! Return sequence of child animations. //! Return sequence of child animations.
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)
//! @param theToUpdate flag to update defined animations to specified start position //! @param theToUpdate flag to update defined animations to specified start position
//! @param theToStopTimer flag to pause timer at the starting position //! @param theToStopTimer flag to pause timer at the starting position
Standard_EXPORT virtual void StartTimer (const Standard_Real theStartPts, Standard_EXPORT virtual void StartTimer(const Standard_Real theStartPts,
const Standard_Real thePlaySpeed, const Standard_Real thePlaySpeed,
const Standard_Boolean theToUpdate, const Standard_Boolean theToUpdate,
const Standard_Boolean theToStopTimer = Standard_False); const Standard_Boolean theToStopTimer = Standard_False);
//! Update single frame of animation, update timer state //! Update single frame of animation, update timer state
//! @return current time of timeline progress. //! @return current time of timeline progress.
@ -153,14 +163,13 @@ public:
const Handle(Media_Timer)& Timer() const { return myTimer; } const Handle(Media_Timer)& Timer() const { return myTimer; }
//! Set playback timer. //! Set playback timer.
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
Standard_EXPORT virtual void Start (const Standard_Boolean theToUpdate); Standard_EXPORT virtual void Start(const Standard_Boolean theToUpdate);
//! Pause the process timeline. //! Pause the process timeline.
Standard_EXPORT virtual void Pause(); Standard_EXPORT virtual void Pause();
@ -176,19 +185,17 @@ public:
//! Update single frame of animation, update timer state //! Update single frame of animation, update timer state
//! @param[in] thePts the time moment within [0; Duration()] //! @param[in] thePts the time moment within [0; Duration()]
//! @return True if timeline is in progress //! @return True if timeline is in progress
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
Standard_Real myPtsStart; //!< time of start in the timeline
Standard_Real myOwnDuration; //!< duration of animation excluding children
Standard_Real myChildrenDuration; //!< duration of animation including children
AnimationState myState; //!< animation state - started, stopped of paused
Standard_Real myPtsStart; //!< time of start in the timeline
Standard_Real myOwnDuration; //!< duration of animation excluding children
Standard_Real myChildrenDuration; //!< duration of animation including children
}; };
#endif // _AIS_Animation_HeaderFile #endif // _AIS_Animation_HeaderFile

View File

@ -15,37 +15,35 @@
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, const Standard_Real theAngleStart,
const Standard_Real theAngleStart, const Standard_Real theAngleEnd)
const Standard_Real theAngleEnd) : AIS_BaseAnimationObject(theAnimationName, theContext, theObject),
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject), myRotAxis(theAxis),
myRotAxis (theAxis), myAngleStart(theAngleStart),
myAngleStart (theAngleStart), myAngleEnd(theAngleEnd)
myAngleEnd (theAngleEnd)
{ {
// //
} }
//============================================================================= //=================================================================================================
//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())
{ {
return; return;
} }
gp_Trsf aTrsf; gp_Trsf aTrsf;
Standard_Real aCurrentAngle = (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd; Standard_Real aCurrentAngle =
aTrsf.SetRotation (myRotAxis, aCurrentAngle); (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
updateTrsf (aTrsf); aTrsf.SetRotation(myRotAxis, aCurrentAngle);
updateTrsf(aTrsf);
} }

View File

@ -22,7 +22,6 @@ class AIS_AnimationAxisRotation : public AIS_BaseAnimationObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject) 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
@ -30,24 +29,21 @@ public:
//! @param[in] theAxis rotation axis //! @param[in] theAxis rotation axis
//! @param[in] theAngleStart rotation angle at the start of animation //! @param[in] theAngleStart rotation angle at the start of animation
//! @param[in] theAngleEnd rotation angle at the end of animation //! @param[in] theAngleEnd rotation angle at the end of animation
Standard_EXPORT AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName, Standard_EXPORT 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,
const Standard_Real theAngleStart, const Standard_Real theAngleStart,
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,38 +18,32 @@
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,
//============================================================================= const Handle(V3d_View)& theView)
AIS_AnimationCamera::AIS_AnimationCamera (const TCollection_AsciiString& theAnimationName, : AIS_Animation(theAnimationName),
const Handle(V3d_View)& theView) myView(theView)
: AIS_Animation (theAnimationName),
myView (theView)
{ {
// //
} }
//============================================================================= //=================================================================================================
//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;
} }
Handle(Graphic3d_Camera) aCamera = myView->Camera(); Handle(Graphic3d_Camera) aCamera = myView->Camera();
Graphic3d_CameraLerp aCamLerp (myCamStart, myCamEnd); Graphic3d_CameraLerp aCamLerp(myCamStart, myCamEnd);
aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera); aCamLerp.Interpolate(HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False); const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate(Standard_False);
myView->SetCamera (aCamera); myView->SetCamera(aCamera);
myView->SetImmediateUpdate (aPrevImmUpdate); myView->SetImmediateUpdate(aPrevImmUpdate);
myView->Invalidate(); myView->Invalidate();
} }

View File

@ -25,40 +25,39 @@ 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);
//! Return the target view. //! Return the target view.
const Handle(V3d_View)& View() const { return myView; } const Handle(V3d_View)& View() const { return myView; }
//! Set target view. //! Set target view.
void SetView (const Handle(V3d_View)& theView) { myView = theView; } void SetView(const Handle(V3d_View)& theView) { myView = theView; }
//! Return camera start position. //! Return camera start position.
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; }
//! Define camera end position. //! Define camera end position.
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,26 +16,22 @@
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,
//============================================================================= const Handle(AIS_InteractiveContext)& theContext,
AIS_AnimationObject::AIS_AnimationObject (const TCollection_AsciiString& theAnimationName, const Handle(AIS_InteractiveObject)& theObject,
const Handle(AIS_InteractiveContext)& theContext, const gp_Trsf& theTrsfStart,
const Handle(AIS_InteractiveObject)& theObject, const gp_Trsf& theTrsfEnd)
const gp_Trsf& theTrsfStart, : AIS_BaseAnimationObject(theAnimationName, theContext, theObject),
const gp_Trsf& theTrsfEnd) myTrsfLerp(theTrsfStart, theTrsfEnd)
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject),
myTrsfLerp (theTrsfStart, theTrsfEnd)
{ {
// //
} }
//============================================================================= //=================================================================================================
//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())
{ {
@ -43,6 +39,6 @@ void AIS_AnimationObject::update (const AIS_AnimationProgress& theProgress)
} }
gp_Trsf aTrsf; gp_Trsf aTrsf;
myTrsfLerp.Interpolate (theProgress.LocalNormalized, aTrsf); myTrsfLerp.Interpolate(theProgress.LocalNormalized, aTrsf);
updateTrsf (aTrsf); updateTrsf(aTrsf);
} }

View File

@ -23,30 +23,27 @@ 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,
const Handle(AIS_InteractiveObject)& theObject, const Handle(AIS_InteractiveObject)& theObject,
const gp_Trsf& theTrsfStart, const gp_Trsf& theTrsfStart,
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,46 +14,49 @@
// 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>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
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)
: myCol(aCol),
hasC(Standard_True),
hasW(Standard_False)
{
}
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol): AIS_AttributeFilter::AIS_AttributeFilter(const Standard_Real aWid)
myCol(aCol), : myWid(aWid),
hasC(Standard_True), hasC(Standard_False),
hasW(Standard_False){} hasW(Standard_True)
{
}
AIS_AttributeFilter::AIS_AttributeFilter(const Standard_Real aWid):
myWid(aWid),
hasC(Standard_False),
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;
Standard_Boolean okstat = Standard_True; Standard_Boolean okstat = Standard_True;
if( hasC && aSelectable->HasColor() ) if (hasC && aSelectable->HasColor())
{ {
Quantity_Color aColor; Quantity_Color aColor;
aSelectable->Color (aColor); aSelectable->Color(aColor);
okstat = (myCol == aColor.Name()); okstat = (myCol == aColor.Name());
} }
if( hasW && aSelectable->HasWidth() ) if (hasW && aSelectable->HasWidth())
okstat = (myWid == aSelectable->Width()) && okstat; okstat = (myWid == aSelectable->Width()) && okstat;
return okstat; return okstat;

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; }
@ -69,17 +64,17 @@ public:
Standard_Boolean HasWidth() const { return hasW; } Standard_Boolean HasWidth() const { return hasW; }
//! Sets the color. //! Sets the color.
void SetColor (const Quantity_NameOfColor theCol) void SetColor(const Quantity_NameOfColor theCol)
{ {
myCol = theCol; myCol = theCol;
hasC = Standard_True; hasC = Standard_True;
} }
//! Sets the line width. //! Sets the line width.
void SetWidth (const Standard_Real theWidth) void SetWidth(const Standard_Real theWidth)
{ {
myWid = theWidth; myWid = theWidth;
hasW = Standard_True; hasW = Standard_True;
} }
//! Removes the setting for color from the filter. //! Removes the setting for color from the filter.
@ -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

@ -38,47 +38,46 @@
#include <StdPrs_Curve.hxx> #include <StdPrs_Curve.hxx>
#include <UnitsAPI.hxx> #include <UnitsAPI.hxx>
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),
AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent): myTypeOfAxis(AIS_TOAX_Unknown),
myComponent(aComponent), myIsXYZAxis(Standard_False)
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{ {
myDrawer->SetLineAspect(new Prs3d_LineAspect myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
SetInfiniteState(); SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction(); gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location(); gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ(); myPfirst = loc.XYZ() + aLength * thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ(); myPlast = loc.XYZ() - aLength * thedir.XYZ();
} }
//======================================================================= //=======================================================================
//function : AIS_Axis // function : AIS_Axis
//purpose : Xaxis, YAxis, ZAxis // purpose : Xaxis, YAxis, ZAxis
//======================================================================= //=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType)
const AIS_TypeOfAxis anAxisType): : myAx2(aComponent),
myAx2(aComponent), myTypeOfAxis(anAxisType),
myTypeOfAxis(anAxisType), myIsXYZAxis(Standard_True)
myIsXYZAxis(Standard_True)
{ {
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); Handle(Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
Standard_Real aLength; Standard_Real aLength;
try { try
aLength = UnitsAPI::AnyToLS(100. ,"mm"); {
} catch (Standard_Failure const&) { aLength = UnitsAPI::AnyToLS(100., "mm");
}
catch (Standard_Failure const&)
{
aLength = 0.1; aLength = 0.1;
} }
DA->SetAxisLength(aLength,aLength,aLength); DA->SetAxisLength(aLength, aLength, aLength);
Quantity_Color col (Quantity_NOC_TURQUOISE); Quantity_Color col(Quantity_NOC_TURQUOISE);
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col);
@ -87,141 +86,122 @@ myIsXYZAxis(Standard_True)
ComputeFields(); ComputeFields();
} }
//======================================================================= //=================================================================================================
//function : AIS_Axis
//purpose :
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis) AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
:myComponent(new Geom_Line(anAxis->Ax1())), : myComponent(new Geom_Line(anAxis->Ax1())),
myTypeOfAxis(AIS_TOAX_Unknown), myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False) myIsXYZAxis(Standard_False)
{ {
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.)); myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
SetInfiniteState(); SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction(); gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location(); gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ(); myPfirst = loc.XYZ() + aLength * thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ(); myPlast = loc.XYZ() - aLength * thedir.XYZ();
} }
//======================================================================= //=================================================================================================
//function : AIS_Axis
//purpose : AIS_Axis::AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength)
//======================================================================= : myComponent(new Geom_Line(theAxis)),
AIS_Axis::AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength) myTypeOfAxis(AIS_TOAX_ZAxis),
: myComponent (new Geom_Line (theAxis)), myIsXYZAxis(Standard_True)
myTypeOfAxis (AIS_TOAX_ZAxis),
myIsXYZAxis (Standard_True)
{ {
myDir = theAxis.Direction(); myDir = theAxis.Direction();
myPfirst = theAxis.Location(); myPfirst = theAxis.Location();
if (theLength <= 0 && theLength != -1) if (theLength <= 0 && theLength != -1)
{ {
throw Standard_NumericError ("AIS_Axis::AIS_Axis : invalid value for theLength parameter"); throw Standard_NumericError("AIS_Axis::AIS_Axis : invalid value for theLength parameter");
} }
myVal = (theLength == -1) ? UnitsAPI::AnyToLS (250000., "mm") : theLength; myVal = (theLength == -1) ? UnitsAPI::AnyToLS(250000., "mm") : theLength;
myPlast = myPfirst.XYZ() + myVal * myDir.XYZ(); myPlast = myPfirst.XYZ() + myVal * myDir.XYZ();
SetInfiniteState(); SetInfiniteState();
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 =
myDrawer->SetLineAspect (aDefaultLineAspect); new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
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)
{ {
myComponent = aComponent; myComponent = aComponent;
myTypeOfAxis = AIS_TOAX_Unknown; myTypeOfAxis = AIS_TOAX_Unknown;
myIsXYZAxis = Standard_False; myIsXYZAxis = Standard_False;
SetInfiniteState(); SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction(); gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location(); gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ(); myPfirst = loc.XYZ() + aLength * thedir.XYZ();
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)
{ {
myAx2 = aComponent; myAx2 = aComponent;
myTypeOfAxis = anAxisType; myTypeOfAxis = anAxisType;
myIsXYZAxis = Standard_True; myIsXYZAxis = Standard_True;
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)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_Axis::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer )
{ {
thePrs->SetInfiniteState (myInfiniteState); thePrs->SetInfiniteState(myInfiniteState);
if (!myIsXYZAxis) if (!myIsXYZAxis)
{ {
GeomAdaptor_Curve curv (myComponent); GeomAdaptor_Curve curv(myComponent);
StdPrs_Curve::Add (thePrs, curv, myDrawer); StdPrs_Curve::Add(thePrs, curv, myDrawer);
} }
else else
{ {
DsgPrs_XYZAxisPresentation::Add (thePrs, myLineAspect, myDir, myVal, DsgPrs_XYZAxisPresentation::Add(thePrs,
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "", myLineAspect,
myPfirst, myPlast); myDir,
myVal,
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "",
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;
myDrawer->SetColor (aCol); myDrawer->SetColor(aCol);
myDrawer->LineAspect()->SetColor(aCol); myDrawer->LineAspect()->SetColor(aCol);
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect(); const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
@ -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,87 +229,80 @@ 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);
myLineAspect = myDrawer->LineAspect(); myLineAspect = myDrawer->LineAspect();
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();
const gp_Pnt& Orig = anAxis.Location(); const gp_Pnt& Orig = anAxis.Location();
const gp_Dir& oX = anAxis.XDirection(); const gp_Dir& oX = anAxis.XDirection();
const gp_Dir& oY = anAxis.YDirection(); const gp_Dir& oY = anAxis.YDirection();
const gp_Dir& oZ = anAxis.Direction(); const gp_Dir& oZ = anAxis.Direction();
Standard_Real xo,yo,zo,x = 0.,y = 0.,z = 0.; Standard_Real xo, yo, zo, x = 0., y = 0., z = 0.;
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;
myLineAspect = DA->LineAspect(Prs3d_DatumParts_XAxis); myLineAspect = DA->LineAspect(Prs3d_DatumParts_XAxis);
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; myLineAspect = DA->LineAspect(Prs3d_DatumParts_YAxis);
myLineAspect = DA->LineAspect(Prs3d_DatumParts_YAxis); 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; myLineAspect = DA->LineAspect(Prs3d_DatumParts_ZAxis);
myLineAspect = DA->LineAspect(Prs3d_DatumParts_ZAxis); myText = Standard_CString("Z");
myText = Standard_CString ("Z"); break;
break;
} }
default: default:
break; break;
} }
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;
myPlast.SetCoord(x,y,z); y = yo + y * myVal;
z = zo + z * myVal;
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);
@ -52,14 +52,14 @@ public:
//! Initializes the ray as axis with start point and direction //! Initializes the ray as axis with start point and direction
//! @param[in] theAxis Start point and direction of the ray //! @param[in] theAxis Start point and direction of the ray
//! @param[in] theLength Optional length of the ray (ray is infinite by default). //! @param[in] theLength Optional length of the ray (ray is infinite by default).
Standard_EXPORT AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength = -1); Standard_EXPORT AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength = -1);
//! Returns the axis entity aComponent and identifies it //! Returns the axis entity aComponent and identifies it
//! as a component of a shape. //! as a component of a shape.
const Handle(Geom_Line)& Component() const { return myComponent; } const Handle(Geom_Line)& Component() const { return myComponent; }
//! Sets the coordinates of the lin aComponent. //! Sets the coordinates of the lin aComponent.
Standard_EXPORT void SetComponent (const Handle(Geom_Line)& aComponent); Standard_EXPORT void SetComponent(const Handle(Geom_Line)& aComponent);
//! Returns the position of axis2 and positions it by //! Returns the position of axis2 and positions it by
//! identifying it as the x, y, or z axis and giving its //! identifying it as the x, y, or z axis and giving its
@ -69,17 +69,18 @@ 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);
//! Returns the type of axis. //! Returns the type of axis.
AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; } AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; }
//! Constructs the entity theTypeAxis to stock information //! Constructs the entity theTypeAxis to stock information
//! concerning type of axis. //! concerning type of axis.
void SetTypeOfAxis (const AIS_TypeOfAxis theTypeAxis) { myTypeOfAxis = theTypeAxis; } void SetTypeOfAxis(const AIS_TypeOfAxis theTypeAxis) { myTypeOfAxis = theTypeAxis; }
//! Returns a signature of 2 for axis datums. When you //! Returns a signature of 2 for axis datums. When you
//! activate mode 2 by a signature, you pick AIS objects //! activate mode 2 by a signature, you pick AIS objects
@ -87,47 +88,48 @@ 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;
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Set required visualization parameters. //! Set required visualization parameters.
Standard_EXPORT void SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewDatumAspect); Standard_EXPORT void SetDisplayAspect(const Handle(Prs3d_LineAspect)& theNewDatumAspect);
Standard_EXPORT void UnsetColor() Standard_OVERRIDE; Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE;
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;
gp_Pnt myPlast; gp_Pnt myPlast;
AIS_TypeOfAxis myTypeOfAxis; AIS_TypeOfAxis myTypeOfAxis;
Standard_Boolean myIsXYZAxis; Standard_Boolean myIsXYZAxis;
gp_Dir myDir; gp_Dir myDir;
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

@ -22,85 +22,71 @@
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
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
{ {
if (myContour==0) if (myContour == 0)
return Standard_True; return Standard_True;
Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO)); Handle(StdSelect_BRepOwner) aBO(Handle(StdSelect_BRepOwner)::DownCast(EO));
if (aBO.IsNull()) if (aBO.IsNull())
return Standard_True; return Standard_True;
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;
} }
} }
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,50 +34,33 @@ 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.
Standard_EXPORT void SetContour (const Standard_Integer Index); Standard_EXPORT void SetContour(const Standard_Integer Index);
//! Adds an edge to the list of non-selectionnable //! Adds an edge to the list of non-selectionnable
//! edges. //! edges.
Standard_EXPORT void AddEdge (const TopoDS_Edge& anEdge, const Standard_Integer Index); Standard_EXPORT void AddEdge(const TopoDS_Edge& anEdge, const Standard_Integer Index);
//! removes from the list of non-selectionnable edges //! removes from the list of non-selectionnable edges
//! 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,41 +17,35 @@
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,
//============================================================================= const Handle(AIS_InteractiveContext)& theContext,
AIS_BaseAnimationObject::AIS_BaseAnimationObject (const TCollection_AsciiString& theAnimationName, const Handle(AIS_InteractiveObject)& theObject)
const Handle(AIS_InteractiveContext)& theContext, : AIS_Animation(theAnimationName),
const Handle(AIS_InteractiveObject)& theObject) myContext(theContext),
: AIS_Animation (theAnimationName), myObject(theObject)
myContext (theContext),
myObject (theObject)
{ {
// //
} }
//============================================================================= //=================================================================================================
//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())
{ {
myContext->SetLocation (myObject, theTrsf); myContext->SetLocation(myObject, theTrsf);
invalidateViewer(); invalidateViewer();
} }
else else
{ {
myObject->SetLocalTransformation (theTrsf); myObject->SetLocalTransformation(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,28 +22,24 @@ 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
//! @param[in] theObject object to apply local transformation //! @param[in] theObject object to apply local transformation
Standard_EXPORT AIS_BaseAnimationObject (const TCollection_AsciiString& theAnimationName, Standard_EXPORT 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);
//! Update the transformation. //! Update the transformation.
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>
@ -27,65 +26,62 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
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()); {
it.Next(); Face2 = TopoDS::Face(it.Value());
if (!it.More()) { it.Next();
GeomAbs_Shape ShapeContinuity = if (!it.More())
BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2); {
Ok = (ShapeContinuity == GeomAbs_C0); GeomAbs_Shape ShapeContinuity =
} BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)), Face1, Face2);
Ok = (ShapeContinuity == GeomAbs_C0);
}
} }
} }
if (Ok) { if (Ok)
const TopoDS_Shape& curEdge = SubShapes.FindKey( i ); {
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
{ {
Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO)); Handle(StdSelect_BRepOwner) aBO(Handle(StdSelect_BRepOwner)::DownCast(EO));
if (aBO.IsNull()) if (aBO.IsNull())
return Standard_False; return Standard_False;
const TopoDS_Shape& aShape = aBO->Shape(); const TopoDS_Shape& aShape = aBO->Shape();
if(aShape.ShapeType()!= TopAbs_EDGE) if (aShape.ShapeType() != TopAbs_EDGE)
return Standard_False; return Standard_False;
return (myMapOfEdges.Contains(aShape)); return (myMapOfEdges.Contains(aShape));

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

@ -29,51 +29,45 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
namespace 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)
{ {
myDrawer->SetLineAspect (new Prs3d_LineAspect (THE_DEFAULT_COLOR, Aspect_TOL_SOLID, 1.0)); myDrawer->SetLineAspect(new Prs3d_LineAspect(THE_DEFAULT_COLOR, Aspect_TOL_SOLID, 1.0));
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect(); Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
aShadingAspect->SetMaterial (Graphic3d_NameOfMaterial_Plastified); aShadingAspect->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
aShadingAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend); aShadingAspect->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_Blend);
aShadingAspect->SetTransparency (THE_DEFAULT_TRANSPARENCY); aShadingAspect->SetTransparency(THE_DEFAULT_TRANSPARENCY);
aShadingAspect->SetColor (THE_DEFAULT_COLOR); aShadingAspect->SetColor(THE_DEFAULT_COLOR);
myDrawer->SetShadingAspect (aShadingAspect); myDrawer->SetShadingAspect(aShadingAspect);
myDrawer->SetTransparency (THE_DEFAULT_TRANSPARENCY); myDrawer->SetTransparency(THE_DEFAULT_TRANSPARENCY);
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())
{ {
return; return;
} }
theCamera->FrustumPoints (myPoints); theCamera->FrustumPoints(myPoints);
fillTriangles(); fillTriangles();
fillBorders(); fillBorders();
@ -81,22 +75,18 @@ 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);
myDrawer->ShadingAspect()->SetColor (theColor); myDrawer->ShadingAspect()->SetColor(theColor);
myDrawer->LineAspect()->SetColor (theColor); myDrawer->LineAspect()->SetColor(theColor);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::UnsetColor() void AIS_CameraFrustum::UnsetColor()
{ {
if (!HasColor()) if (!HasColor())
@ -106,26 +96,22 @@ void AIS_CameraFrustum::UnsetColor()
AIS_InteractiveObject::UnsetColor(); AIS_InteractiveObject::UnsetColor();
myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR); myDrawer->ShadingAspect()->SetColor(THE_DEFAULT_COLOR);
myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR); myDrawer->LineAspect()->SetColor(THE_DEFAULT_COLOR);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::UnsetTransparency() void AIS_CameraFrustum::UnsetTransparency()
{ {
myDrawer->ShadingAspect()->SetTransparency (0.0f); myDrawer->ShadingAspect()->SetTransparency(0.0f);
myDrawer->SetTransparency (0.0f); myDrawer->SetTransparency(0.0f);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : fillTriangles
//purpose :
//=======================================================================
void AIS_CameraFrustum::fillTriangles() void AIS_CameraFrustum::fillTriangles()
{ {
if (myTriangles.IsNull()) if (myTriangles.IsNull())
@ -133,18 +119,19 @@ 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,
myTriangles->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0)); aPlaneTriangleVertsNb * aPlanesNb);
myTriangles->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
// Triangles go in order (clockwise vertices traversing for correct normal): // Triangles go in order (clockwise vertices traversing for correct normal):
// (0, 2, 1), (3, 1, 2) // (0, 2, 1), (3, 1, 2)
const Standard_Integer aLookup1_clockwise[] = { 0, 1, 0, 1, 0, 1 }; const Standard_Integer aLookup1_clockwise[] = {0, 1, 0, 1, 0, 1};
const Standard_Integer aLookup2_clockwise[] = { 0, 0, 1, 1, 1, 0 }; const Standard_Integer aLookup2_clockwise[] = {0, 0, 1, 1, 1, 0};
// Triangles go in order (counterclockwise vertices traversing for correct normal): // Triangles go in order (counterclockwise vertices traversing for correct normal):
// (1, 2, 0), (2, 1, 3) // (1, 2, 0), (2, 1, 3)
const Standard_Integer aLookup1_anticlockwise[] = { 0, 1, 0, 1, 0, 1 }; const Standard_Integer aLookup1_anticlockwise[] = {0, 1, 0, 1, 0, 1};
const Standard_Integer aLookup2_anticlockwise[] = { 1, 0, 0, 0, 1, 1 }; const Standard_Integer aLookup2_anticlockwise[] = {1, 0, 0, 0, 1, 1};
Standard_Integer aShifts[] = { 0, 0, 0 }; Standard_Integer aShifts[] = {0, 0, 0};
// Planes go in order: // Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR // LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
@ -167,37 +154,37 @@ void AIS_CameraFrustum::fillTriangles()
} }
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2]; Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
myTriangles->AddEdge (anIndex + 1); myTriangles->AddEdge(anIndex + 1);
} }
} }
} }
} }
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,
myBorders->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0)); aPlaneSegmVertsNb * aPlanesNb);
myBorders->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
// Segments go in order: // Segments go in order:
// (0, 2), (2, 3), (3, 1), (1, 0) // (0, 2), (2, 3), (3, 1), (1, 0)
const Standard_Integer aLookup1[] = { 0, 1, 1, 1, 1, 0, 0, 0 }; const Standard_Integer aLookup1[] = {0, 1, 1, 1, 1, 0, 0, 0};
const Standard_Integer aLookup2[] = { 0, 0, 0, 1, 1, 1, 1, 0 }; const Standard_Integer aLookup2[] = {0, 0, 0, 1, 1, 1, 1, 0};
Standard_Integer aShifts[] = { 0, 0, 0 }; Standard_Integer aShifts[] = {0, 0, 0};
// Planes go in order: // Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR // LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
@ -207,33 +194,32 @@ void AIS_CameraFrustum::fillBorders()
{ {
for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter) for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter)
{ {
aShifts[aFaceIdx] = i; aShifts[aFaceIdx] = i;
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter]; aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter];
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter]; aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter];
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2]; Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
myBorders->AddEdge (anIndex + 1); myBorders->AddEdge(anIndex + 1);
} }
} }
} }
} }
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)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{ {
thePrs->SetInfiniteState (true); thePrs->SetInfiniteState(true);
if (myTriangles.IsNull()) if (myTriangles.IsNull())
{ {
return; return;
@ -241,48 +227,48 @@ 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);
break; break;
} }
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_CameraFrustum::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
//======================================================================= const Standard_Integer theMode)
void AIS_CameraFrustum::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
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(),
theSelection->Add (aSelArray); myTriangles->Indices(),
TopLoc_Location());
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,15 +35,14 @@ public:
}; };
public: public:
//! Constructs camera frustum with default configuration. //! Constructs camera frustum with default configuration.
Standard_EXPORT AIS_CameraFrustum(); Standard_EXPORT AIS_CameraFrustum();
//! Sets camera frustum. //! Sets camera frustum.
Standard_EXPORT void SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera); Standard_EXPORT void SetCameraFrustum(const Handle(Graphic3d_Camera)& theCamera);
//! Setup custom color. //! Setup custom color.
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;
@ -53,21 +51,20 @@ 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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection. //! Compute selection.
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;
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

@ -33,105 +33,99 @@
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <StdPrs_DeflectionCurve.hxx> #include <StdPrs_DeflectionCurve.hxx>
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): myComponent(aComponent),
AIS_InteractiveObject(PrsMgr_TOP_AllView), myUStart(0.0),
myComponent(aComponent), myUEnd(2.0 * M_PI),
myUStart (0.0), myCircleIsArc(Standard_False),
myUEnd (2.0 * M_PI), myIsFilledCircleSens(Standard_False)
myCircleIsArc (Standard_False),
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,
const Standard_Boolean theIsFilledCircleSens) const Standard_Boolean theIsFilledCircleSens)
: AIS_InteractiveObject(PrsMgr_TOP_AllView), : AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent (theComponent), myComponent(theComponent),
myUStart (theUStart), myUStart(theUStart),
myUEnd (theUEnd), myUEnd(theUEnd),
myCircleIsArc (Abs (Abs (theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()), myCircleIsArc(Abs(Abs(theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()),
myIsFilledCircleSens (theIsFilledCircleSens) myIsFilledCircleSens(theIsFilledCircleSens)
{ {
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_Circle::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer)
const Handle(Prs3d_Presentation)& thePrs,
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())
{ {
myDrawer->SetLineAspect (theAspect); myDrawer->SetLineAspect(theAspect);
return; return;
} }
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);
Graphic3d_MapOfAspectsToAspects aReplaceMap; Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew); aReplaceMap.Bind(anAspectOld, anAspectNew);
replaceAspects (aReplaceMap); replaceAspects(aReplaceMap);
} }
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Circle::SetColor(const Quantity_Color &aCol) void AIS_Circle::SetColor(const Quantity_Color& aCol)
{ {
hasOwnColor=Standard_True; hasOwnColor = Standard_True;
myDrawer->SetColor (aCol); myDrawer->SetColor(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,20 +134,20 @@ 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;
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();
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
} }
else else
{ {
@ -162,101 +156,90 @@ 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;
if (!HasWidth()) if (!HasWidth())
{ {
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
} }
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())
{ {
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
} }
else else
{ {
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.0f; Standard_ShortReal WW =
myDrawer->LineAspect()->SetWidth(WW); myDrawer->HasLink()
myOwnWidth = WW; ? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.0f;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeCircle
//purpose : void AIS_Circle::ComputeCircle(const Handle(Prs3d_Presentation)& thePresentation)
//=======================================================================
void AIS_Circle::ComputeCircle (const Handle(Prs3d_Presentation)& thePresentation)
{ {
GeomAdaptor_Curve curv(myComponent); GeomAdaptor_Curve curv(myComponent);
Standard_Real prevdev = myDrawer->DeviationCoefficient(); Standard_Real prevdev = myDrawer->DeviationCoefficient();
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);
Standard_Real prevdev = myDrawer->DeviationCoefficient(); Standard_Real prevdev = myDrawer->DeviationCoefficient();
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 : 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,
myIsFilledCircleSens); myUEnd,
theSelection->Add (aSeg); myIsFilledCircleSens);
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,46 +35,52 @@ 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; }
//! Constructs instances of the starting point and the end //! Constructs instances of the starting point and the end
//! point parameters, theU1 and theU2. //! point parameters, theU1 and theU2.
void Parameters (Standard_Real& theU1, Standard_Real& theU2) const void Parameters(Standard_Real& theU1, Standard_Real& theU2) const
{ {
theU1 = myUStart; theU1 = myUStart;
theU2 = myUEnd; theU2 = myUEnd;
} }
//! Allows you to provide settings for the circle datum aCircle. //! Allows you to provide settings for the circle datum aCircle.
void SetCircle (const Handle(Geom_Circle)& theCircle) { myComponent = theCircle; } void SetCircle(const Handle(Geom_Circle)& theCircle) { myComponent = theCircle; }
//! Allows you to set the parameter theU for the starting point of an arc. //! Allows you to set the parameter theU for the starting point of an arc.
void SetFirstParam (const Standard_Real theU) void SetFirstParam(const Standard_Real theU)
{ {
myUStart = theU; myUStart = theU;
myCircleIsArc = Standard_True; myCircleIsArc = Standard_True;
} }
//! Allows you to provide the parameter theU for the end point of an arc. //! Allows you to provide the parameter theU for the end point of an arc.
void SetLastParam (const Standard_Real theU) void SetLastParam(const Standard_Real theU)
{ {
myUEnd = theU; myUEnd = theU;
myCircleIsArc = Standard_True; myCircleIsArc = Standard_True;
} }
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
//! Assigns the width aValue to the solid line boundary of the circle datum. //! Assigns the width aValue to the solid line boundary of the circle datum.
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Removes color from the solid line boundary of the circle datum. //! Removes color from the solid line boundary of the circle datum.
Standard_EXPORT void UnsetColor() Standard_OVERRIDE; Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
@ -88,36 +93,36 @@ 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,
const Handle(Prs3d_Presentation)& theprs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& theprs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, Standard_EXPORT void ComputeCircle(const Handle(Prs3d_Presentation)& aPresentation);
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeCircle (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeArc(const Handle(Prs3d_Presentation)& aPresentation);
Standard_EXPORT void ComputeArc (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeCircleSelection (const Handle(SelectMgr_Selection)& aSelection); Standard_EXPORT void ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeArcSelection (const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value. //! Replace aspects of already computed groups with the new value.
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)

File diff suppressed because it is too large Load Diff

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,71 +40,81 @@ 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
Standard_EXPORT static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
const Standard_Integer theColorsCount,
const Graphic3d_Vec3d& theColorHlsMin,
const Graphic3d_Vec3d& theColorHlsMax,
Quantity_Color& theColor);
//! 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, static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin, const Standard_Real theMin,
const Standard_Real theMax, const Standard_Real theMax,
const Standard_Integer theColorsCount, const Standard_Integer theColorsCount,
const Graphic3d_Vec3d& theColorHlsMin, Quantity_Color& theColor)
const Graphic3d_Vec3d& theColorHlsMax,
Quantity_Color& theColor);
//! Calculate color according passed value; returns true if value is in range or false, if isn't
static Standard_Boolean FindColor (const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
const Standard_Integer theColorsCount,
Quantity_Color& theColor)
{ {
return FindColor (theValue, theMin, theMax, theColorsCount, return FindColor(theValue,
Graphic3d_Vec3d (230.0, 1.0, 1.0), theMin,
Graphic3d_Vec3d (0.0, 1.0, 1.0), theMax,
theColor); theColorsCount,
Graphic3d_Vec3d(230.0, 1.0, 1.0),
Graphic3d_Vec3d(0.0, 1.0, 1.0),
theColor);
} }
//! 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
static Standard_Real hueToValidRange (const Standard_Real theHue) //! interpolation.
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; }
//! Sets the minimal value of color scale. //! Sets the minimal value of color scale.
void SetMin (const Standard_Real theMin) { SetRange (theMin, GetMax()); } void SetMin(const Standard_Real theMin) { SetRange(theMin, GetMax()); }
//! Returns maximal value of color scale, 1.0 by default. //! Returns maximal value of color scale, 1.0 by default.
Standard_Real GetMax() const { return myMax; } Standard_Real GetMax() const { return myMax; }
//! Sets the maximal value of color scale. //! Sets the maximal value of color scale.
void SetMax (const Standard_Real theMax) { SetRange (GetMin(), theMax); } void SetMax(const Standard_Real theMax) { SetRange(GetMin(), theMax); }
//! Returns minimal and maximal values of color scale, 0.0 to 1.0 by default. //! Returns minimal and maximal values of color scale, 0.0 to 1.0 by default.
void GetRange (Standard_Real& theMin, Standard_Real& theMax) const void GetRange(Standard_Real& theMin, Standard_Real& theMax) const
{ {
theMin = myMin; theMin = myMin;
theMax = myMax; theMax = myMax;
} }
//! 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);
//! Returns the hue angle corresponding to minimum value, 230 by default (blue). //! Returns the hue angle corresponding to minimum value, 230 by default (blue).
Standard_Real HueMin() const { return myColorHlsMin[0]; } Standard_Real HueMin() const { return myColorHlsMin[0]; }
@ -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,27 +132,30 @@ 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);
} }
//! Returns the type of labels, Aspect_TOCSD_AUTO by default. //! Returns the type of labels, Aspect_TOCSD_AUTO by default.
@ -152,7 +166,7 @@ public:
//! Sets the type of labels. //! Sets the type of labels.
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals //! Aspect_TOCSD_AUTO - labels as boundary values for intervals
//! Aspect_TOCSD_USER - user specified label is used //! Aspect_TOCSD_USER - user specified label is used
void SetLabelType (const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; } void SetLabelType(const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; }
//! Returns the type of colors, Aspect_TOCSD_AUTO by default. //! Returns the type of colors, Aspect_TOCSD_AUTO by default.
//! Aspect_TOCSD_AUTO - value between Red and Blue //! Aspect_TOCSD_AUTO - value between Red and Blue
@ -162,19 +176,19 @@ public:
//! Sets the type of colors. //! Sets the type of colors.
//! Aspect_TOCSD_AUTO - value between Red and Blue //! Aspect_TOCSD_AUTO - value between Red and Blue
//! Aspect_TOCSD_USER - user specified color from color map //! Aspect_TOCSD_USER - user specified color from color map
void SetColorType (const Aspect_TypeOfColorScaleData theType) { myColorType = theType; } void SetColorType(const Aspect_TypeOfColorScaleData theType) { myColorType = theType; }
//! Returns the number of color scale intervals, 10 by default. //! Returns the number of color scale intervals, 10 by default.
Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; } Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; }
//! Sets the number of color scale intervals. //! Sets the number of color scale intervals.
Standard_EXPORT void SetNumberOfIntervals (const Standard_Integer theNum); Standard_EXPORT void SetNumberOfIntervals(const Standard_Integer theNum);
//! Returns the color scale title string, empty string by default. //! Returns the color scale title string, empty string by default.
const TCollection_ExtendedString& GetTitle() const { return myTitle; } const TCollection_ExtendedString& GetTitle() const { return myTitle; }
//! Sets the color scale title string. //! Sets the color scale title string.
void SetTitle (const TCollection_ExtendedString& theTitle) { myTitle = theTitle; } void SetTitle(const TCollection_ExtendedString& theTitle) { myTitle = theTitle; }
//! Returns the format for numbers, "%.4g" by default. //! Returns the format for numbers, "%.4g" by default.
//! The same like format for function printf(). //! The same like format for function printf().
@ -185,58 +199,60 @@ public:
const TCollection_AsciiString& Format() const { return myFormat; } const TCollection_AsciiString& Format() const { return myFormat; }
//! Sets the color scale auto label format specification. //! Sets the color scale auto label format specification.
void SetFormat (const TCollection_AsciiString& theFormat) { myFormat = theFormat; } void SetFormat(const TCollection_AsciiString& theFormat) { myFormat = theFormat; }
//! Returns the user specified label with index theIndex. //! Returns the user specified label with index theIndex.
//! Index is in range from 1 to GetNumberOfIntervals() or to //! Index is in range from 1 to GetNumberOfIntervals() or to
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. //! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true.
//! Returns empty string if label not defined. //! Returns empty string if label not defined.
Standard_EXPORT TCollection_ExtendedString GetLabel (const Standard_Integer theIndex) const; Standard_EXPORT TCollection_ExtendedString GetLabel(const Standard_Integer theIndex) const;
//! Returns the user specified color from color map with index (starts at 1). //! Returns the user specified color from color map with index (starts at 1).
//! Returns default color if index is out of range in color map. //! Returns default color if index is out of range in color map.
Standard_EXPORT Quantity_Color GetIntervalColor (const Standard_Integer theIndex) const; Standard_EXPORT Quantity_Color GetIntervalColor(const Standard_Integer theIndex) const;
//! Sets the color of the specified interval. //! Sets the color of the specified interval.
//! Note that list is automatically resized to include specified index. //! Note that list is automatically resized to include specified index.
//! @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;
//! Returns the user specified labels. //! Returns the user specified labels.
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.
Standard_EXPORT void GetColors (Aspect_SequenceOfColor& theColors) const; Standard_EXPORT void GetColors(Aspect_SequenceOfColor& theColors) const;
//! Returns the user specified colors. //! Returns the user specified colors.
const Aspect_SequenceOfColor& GetColors() const { return myColors; } const Aspect_SequenceOfColor& GetColors() const { return myColors; }
//! Sets the color scale colors. //! Sets the color scale colors.
//! The length of the sequence should be equal to GetNumberOfIntervals(). //! The length of the sequence should be equal to GetNumberOfIntervals().
Standard_EXPORT void SetColors (const Aspect_SequenceOfColor& theSeq); Standard_EXPORT void SetColors(const Aspect_SequenceOfColor& theSeq);
//! Populates colors scale by colors of the same lightness value in CIE Lch //! Populates colors scale by colors of the same lightness value in CIE Lch
//! color space, distributed by hue, with perceptually uniform differences //! color space, distributed by hue, with perceptually uniform differences
//! 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);
} }
//! Generates sequence of colors of the same lightness value in CIE Lch //! Generates sequence of colors of the same lightness value in CIE Lch
@ -254,22 +270,25 @@ 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.
void SetLabelPosition (const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; } void SetLabelPosition(const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; }
//! Returns the position of color scale title, Aspect_TOCSP_LEFT by default. //! Returns the position of color scale title, Aspect_TOCSP_LEFT by default.
Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; } Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; }
//! 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.
//! - Normal, bottom-up order with Minimal value on the Bottom and Maximum value on Top. //! - Normal, bottom-up order with Minimal value on the Bottom and Maximum value on Top.
@ -277,14 +296,14 @@ public:
Standard_Boolean IsReversed() const { return myIsReversed; } Standard_Boolean IsReversed() const { return myIsReversed; }
//! Sets true if the labels and colors used in reversed order. //! Sets true if the labels and colors used in reversed order.
void SetReversed (const Standard_Boolean theReverse) { myIsReversed = theReverse; } void SetReversed(const Standard_Boolean theReverse) { myIsReversed = theReverse; }
//! Return TRUE if color transition between neighbor intervals //! Return TRUE if color transition between neighbor intervals
//! should be linearly interpolated, FALSE by default. //! should be linearly interpolated, FALSE by default.
Standard_Boolean IsSmoothTransition() const { return myIsSmooth; } Standard_Boolean IsSmoothTransition() const { return myIsSmooth; }
//! Setup smooth color transition. //! Setup smooth color transition.
void SetSmoothTransition (const Standard_Boolean theIsSmooth) { myIsSmooth = theIsSmooth; } void SetSmoothTransition(const Standard_Boolean theIsSmooth) { myIsSmooth = theIsSmooth; }
//! Returns TRUE if the labels are placed at border of color intervals, TRUE by default. //! Returns TRUE if the labels are placed at border of color intervals, TRUE by default.
//! The automatically generated label will show value exactly on the current position: //! The automatically generated label will show value exactly on the current position:
@ -294,31 +313,33 @@ public:
//! Sets true if the labels are placed at border of color intervals (TRUE by default). //! Sets true if the labels are placed at border of color intervals (TRUE by default).
//! If set to False, labels will be drawn at color intervals rather than at borders. //! If set to False, labels will be drawn at color intervals rather than at borders.
void SetLabelAtBorder (const Standard_Boolean theOn) { myIsLabelAtBorder = theOn; } void SetLabelAtBorder(const Standard_Boolean theOn) { myIsLabelAtBorder = theOn; }
//! Returns TRUE if the color scale has logarithmic intervals, FALSE by default. //! Returns TRUE if the color scale has logarithmic intervals, FALSE by default.
Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; } Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; }
//! Sets true if the color scale has logarithmic intervals. //! Sets true if the color scale has logarithmic intervals.
void SetLogarithmic (const Standard_Boolean isLogarithmic) { myIsLogarithmic = isLogarithmic; } void SetLogarithmic(const Standard_Boolean isLogarithmic) { myIsLogarithmic = isLogarithmic; }
//! 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).
void GetSize (Standard_Integer& theBreadth, Standard_Integer& theHeight) const void GetSize(Standard_Integer& theBreadth, Standard_Integer& theHeight) const
{ {
theBreadth = myBreadth; theBreadth = myBreadth;
theHeight = myHeight; theHeight = myHeight;
} }
//! Sets the size of color bar. //! Sets the size of color bar.
void SetSize (const Standard_Integer theBreadth, const Standard_Integer theHeight) void SetSize(const Standard_Integer theBreadth, const Standard_Integer theHeight)
{ {
myBreadth = theBreadth; myBreadth = theBreadth;
myHeight = theHeight; myHeight = theHeight;
@ -329,24 +350,24 @@ public:
Standard_Integer GetBreadth() const { return myBreadth; } Standard_Integer GetBreadth() const { return myBreadth; }
//! Sets the width of color bar. //! Sets the width of color bar.
void SetBreadth (const Standard_Integer theBreadth) { myBreadth = theBreadth; } void SetBreadth(const Standard_Integer theBreadth) { myBreadth = theBreadth; }
//! Returns the height of color bar, 0 by default //! Returns the height of color bar, 0 by default
//! (e.g. should be set by user explicitly before displaying). //! (e.g. should be set by user explicitly before displaying).
Standard_Integer GetHeight() const { return myHeight; } Standard_Integer GetHeight() const { return myHeight; }
//! Sets the height of color bar. //! Sets the height of color bar.
void SetHeight (const Standard_Integer theHeight) { myHeight = theHeight; } void SetHeight(const Standard_Integer theHeight) { myHeight = theHeight; }
//! Returns the bottom-left position of color scale, 0x0 by default. //! Returns the bottom-left position of color scale, 0x0 by default.
void GetPosition (Standard_Real& theX, Standard_Real& theY) const void GetPosition(Standard_Real& theX, Standard_Real& theY) const
{ {
theX = myXPos; theX = myXPos;
theY = myYPos; theY = myYPos;
} }
//! Sets the position of color scale. //! Sets the position of color scale.
void SetPosition (const Standard_Integer theX, const Standard_Integer theY) void SetPosition(const Standard_Integer theX, const Standard_Integer theY)
{ {
myXPos = theX; myXPos = theX;
myYPos = theY; myYPos = theY;
@ -356,67 +377,69 @@ public:
Standard_Integer GetXPosition() const { return myXPos; } Standard_Integer GetXPosition() const { return myXPos; }
//! Sets the left position of color scale. //! Sets the left position of color scale.
void SetXPosition (const Standard_Integer theX) { myXPos = theX; } void SetXPosition(const Standard_Integer theX) { myXPos = theX; }
//! Returns the bottom position of color scale, 0 by default. //! Returns the bottom position of color scale, 0 by default.
Standard_Integer GetYPosition() const { return myYPos; } Standard_Integer GetYPosition() const { return myYPos; }
//! Sets the bottom position of color scale. //! Sets the bottom position of color scale.
void SetYPosition (const Standard_Integer theY) { myYPos = theY; } void SetYPosition(const Standard_Integer theY) { myYPos = theY; }
//! Returns the font height of text labels, 20 by default. //! Returns the font height of text labels, 20 by default.
Standard_Integer GetTextHeight() const { return myTextHeight; } Standard_Integer GetTextHeight() const { return myTextHeight; }
//! Sets the height of text of color scale. //! Sets the height of text of color scale.
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;
//! Returns the height of text. //! Returns the height of text.
//! @param[in] theText the text of which to calculate height. //! @param[in] theText the text of which to calculate height.
Standard_EXPORT Standard_Integer TextHeight (const TCollection_ExtendedString& theText) const; Standard_EXPORT Standard_Integer TextHeight(const TCollection_ExtendedString& theText) const;
Standard_EXPORT void TextSize (const TCollection_ExtendedString& theText, Standard_EXPORT void TextSize(const TCollection_ExtendedString& theText,
const Standard_Integer theHeight, const Standard_Integer theHeight,
Standard_Integer& theWidth, Standard_Integer& theWidth,
Standard_Integer& theAscent, Standard_Integer& theAscent,
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,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! 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.
void SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const; void SizeHint(Standard_Integer& theWidth, Standard_Integer& theHeight) const;
//! Returns the upper value of given interval, or minimum for theIndex = 0. //! Returns the upper value of given interval, or minimum for theIndex = 0.
Standard_Real GetIntervalValue (const Standard_Integer theIndex) const; Standard_Real GetIntervalValue(const Standard_Integer theIndex) const;
//! Returns the color for the given value in the given interval. //! Returns the color for the given value in the given interval.
//! @param[in] theValue the current value of interval //! @param[in] theValue the current value of interval
//! @param[in] theMin the min value of interval //! @param[in] theMin the min value of interval
//! @param[in] theMax the max value of interval //! @param[in] theMax the max value of interval
Quantity_Color colorFromValue (const Standard_Real theValue, Quantity_Color colorFromValue(const Standard_Real theValue,
const Standard_Real theMin, const Standard_Real theMin,
const Standard_Real theMax) const; const Standard_Real theMax) const;
//! Initialize text aspect for drawing the labels. //! Initialize text aspect for drawing the labels.
void updateTextAspect(); void updateTextAspect();
@ -427,28 +450,29 @@ private:
//! @param[in] theX X coordinate of text position //! @param[in] theX X coordinate of text position
//! @param[in] theY Y coordinate of text position //! @param[in] theY Y coordinate of text position
//! @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 Graphic3d_VerticalTextAlignment theVertAlignment); const Standard_Integer theY,
const Graphic3d_VerticalTextAlignment theVertAlignment);
//! Determine the maximum text label width in pixels. //! Determine the maximum text label width in pixels.
Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const; Standard_Integer computeMaxLabelWidth(const TColStd_SequenceOfExtendedString& theLabels) const;
//! Draw labels. //! Draw labels.
void drawLabels (const Handle(Graphic3d_Group)& theGroup, void drawLabels(const Handle(Graphic3d_Group)& theGroup,
const TColStd_SequenceOfExtendedString& theLabels, const TColStd_SequenceOfExtendedString& theLabels,
const Standard_Integer theBarBottom, const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight, const Standard_Integer theBarHeight,
const Standard_Integer theMaxLabelWidth, const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth); const Standard_Integer theColorBreadth);
//! Draw a color bar. //! Draw a color bar.
void drawColorBar (const Handle(Prs3d_Presentation)& thePrs, void drawColorBar(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theBarBottom, const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight, const Standard_Integer theBarHeight,
const Standard_Integer theMaxLabelWidth, const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth); const Standard_Integer theColorBreadth);
//! Draw a frame. //! Draw a frame.
//! @param[in] theX the X coordinate of frame position. //! @param[in] theX the X coordinate of frame position.
@ -456,16 +480,17 @@ private:
//! @param[in] theWidth the width of frame. //! @param[in] theWidth the width of frame.
//! @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 Quantity_Color& theColor); const Standard_Integer theWidth,
const Standard_Integer theHeight,
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
Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value
Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value
TCollection_ExtendedString myTitle; //!< optional title string TCollection_ExtendedString myTitle; //!< optional title string
@ -480,15 +505,14 @@ private:
Aspect_SequenceOfColor myColors; //!< sequence of custom colors Aspect_SequenceOfColor myColors; //!< sequence of custom colors
TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels
Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale
// clang-format on // clang-format on
Aspect_TypeOfColorScalePosition myTitlePos; //!< title position Aspect_TypeOfColorScalePosition myTitlePos; //!< title position
Standard_Integer myXPos; //!< left position Standard_Integer myXPos; //!< left position
Standard_Integer myYPos; //!< bottom position Standard_Integer myYPos; //!< bottom position
Standard_Integer myBreadth; //!< color scale breadth Standard_Integer myBreadth; //!< color scale breadth
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,45 +22,51 @@ 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),
myHasOwnMaterial(false), myHasOwnMaterial(false),
myHasOwnColor (false), myHasOwnColor(false),
myHasOwnTransp(false), myHasOwnTransp(false),
myHasOwnWidth (false) myHasOwnWidth(false)
{ {
Link (theLink); Link(theLink);
} }
bool IsHidden() const { return myIsHidden; } bool IsHidden() const { return myIsHidden; }
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
bool HasOwnMaterial() const { return myHasOwnMaterial; } void SetHidden(const bool theToHide) { myIsHidden = theToHide; }
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
void SetOwnMaterial() { myHasOwnMaterial = true; }
bool HasOwnColor() const { return myHasOwnColor; } bool HasOwnMaterial() const { return myHasOwnMaterial; }
void UnsetOwnColor() { myHasOwnColor = false; }
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
bool HasOwnTransparency() const { return myHasOwnTransp; } void UnsetOwnMaterial() { myHasOwnMaterial = false; }
void UnsetOwnTransparency() { myHasOwnTransp = false; }
void SetOwnTransparency (Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
bool HasOwnWidth() const { return myHasOwnWidth; } void SetOwnMaterial() { myHasOwnMaterial = true; }
void UnsetOwnWidth() { myHasOwnWidth = false; }
void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
public: //! @name list of overridden properties bool HasOwnColor() const { return myHasOwnColor; }
void UnsetOwnColor() { myHasOwnColor = false; }
void SetOwnColor(const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
bool HasOwnTransparency() const { return myHasOwnTransp; }
void UnsetOwnTransparency() { myHasOwnTransp = false; }
void SetOwnTransparency(Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
bool HasOwnWidth() const { return myHasOwnWidth; }
void UnsetOwnWidth() { myHasOwnWidth = false; }
void SetOwnWidth(const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
public: //! @name list of overridden properties
bool myIsHidden; bool 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)

File diff suppressed because it is too large Load Diff

View File

@ -28,39 +28,36 @@ 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);
//! Copy constructor //! Copy constructor
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.
Standard_EXPORT virtual Handle(AIS_ColoredDrawer) CustomAspects (const TopoDS_Shape& theShape); Standard_EXPORT virtual Handle(AIS_ColoredDrawer) CustomAspects(const TopoDS_Shape& theShape);
//! Reset the map of custom sub-shape aspects. //! Reset the map of custom sub-shape aspects.
Standard_EXPORT virtual void ClearCustomAspects(); Standard_EXPORT virtual void ClearCustomAspects();
//! Reset custom properties of specified sub-shape. //! Reset custom properties of specified sub-shape.
//! @param theToUnregister unregister or not sub-shape from the map //! @param theToUnregister unregister or not sub-shape from the map
Standard_EXPORT void UnsetCustomAspects (const TopoDS_Shape& theShape, Standard_EXPORT void UnsetCustomAspects(const TopoDS_Shape& theShape,
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,
Standard_Real theTransparency); Standard_Real theTransparency);
//! Customize line width of specified sub-shape //! Customize line width of specified sub-shape
Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape, Standard_EXPORT void SetCustomWidth(const TopoDS_Shape& theShape,
const Standard_Real theLineWidth); const Standard_Real theLineWidth);
//! Return the map of custom aspects. //! Return the map of custom aspects.
const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; } const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; }
@ -69,21 +66,20 @@ 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;
//! Setup line width of entire shape. //! Setup line width of entire shape.
Standard_EXPORT virtual void SetWidth (const Standard_Real theLineWidth) Standard_OVERRIDE; Standard_EXPORT virtual void SetWidth(const Standard_Real theLineWidth) Standard_OVERRIDE;
//! Sets transparency value. //! Sets transparency value.
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,22 +87,20 @@ 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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection considering sub-shape hidden state. //! Compute selection considering sub-shape hidden state.
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;
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,41 +109,45 @@ 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 TopoDS_Shape& theShapeToParse, const Handle(AIS_ColoredDrawer)& theParentDrawer,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap, const TopoDS_Shape& theShapeToParse,
const TopAbs_ShapeEnum theParentType, const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const Standard_Boolean theIsParentClosed, const TopAbs_ShapeEnum theParentType,
DataMapOfDrawerCompd* theDrawerOpenedShapePerType, const Standard_Boolean theIsParentClosed,
DataMapOfDrawerCompd& theDrawerClosedFaces); DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
protected: DataMapOfDrawerCompd& theDrawerClosedFaces);
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
Standard_EXPORT void fillSubshapeDrawerMap (AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const; //! container for subshapes.
Standard_EXPORT void fillSubshapeDrawerMap(AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const;
//! Add shape to presentation //! Add shape to presentation
//! @param thePrs the presentation //! @param thePrs the presentation
//! @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 DataMapOfDrawerCompd* theDrawerOpenedShapePerType, const Handle(Prs3d_Presentation)& thePrs,
const DataMapOfDrawerCompd& theDrawerClosedFaces, const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
const Standard_Integer theMode); const DataMapOfDrawerCompd& theDrawerClosedFaces,
const Standard_Integer theMode);
//! Check all shapes from myShapeColorsfor visibility //! Check all shapes from myShapeColorsfor visibility
Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const; Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const;
//! 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
Standard_EXPORT void bindSubShapes (AIS_DataMapOfShapeDrawer& theShapeDrawerMap, Standard_EXPORT void bindSubShapes(AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theKeyShape, const TopoDS_Shape& theKeyShape,
const Handle(AIS_ColoredDrawer)& theDrawer) const; const Handle(AIS_ColoredDrawer)& theDrawer) const;
//! Add sub-shape to selection considering hidden state (recursively). //! Add sub-shape to selection considering hidden state (recursively).
//! @param theParentDrawer drawer of parent shape //! @param theParentDrawer drawer of parent shape
@ -160,24 +158,21 @@ protected:
//! @param theTypOfSel type of selection //! @param theTypOfSel type of selection
//! @param theDeflection linear deflection //! @param theDeflection linear deflection
//! @param theDeflAngle angular deflection //! @param theDeflAngle angular deflection
Standard_EXPORT void computeSubshapeSelection (const Handle(AIS_ColoredDrawer)& theParentDrawer, Standard_EXPORT void computeSubshapeSelection(const Handle(AIS_ColoredDrawer)& theParentDrawer,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap, const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const Handle(StdSelect_BRepOwner)& theOwner, const Handle(StdSelect_BRepOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection, const Handle(SelectMgr_Selection)& theSelection,
const TopAbs_ShapeEnum theTypOfSel, const TopAbs_ShapeEnum theTypOfSel,
const Standard_Integer thePriority, const Standard_Integer thePriority,
const Standard_Real theDeflection, const Standard_Real theDeflection,
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

@ -31,32 +31,30 @@
#include <StdSelect_BRepOwner.hxx> #include <StdSelect_BRepOwner.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
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,
//======================================================================= const Handle(TopLoc_Datum3D)& theLocation)
void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theLocation)
{ {
if (myReference == theAnotherObj) if (myReference == theAnotherObj)
{ {
setLocalTransformation (theLocation); setLocalTransformation(theLocation);
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,59 +65,57 @@ 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())
{ {
if (myReference->HasInteractiveContext() if (myReference->HasInteractiveContext()
&& 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()
{ {
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) for (PrsMgr_Presentations::Iterator aPrsIter(myPresentations); aPrsIter.More(); aPrsIter.Next())
{ {
const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value(); const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
if (!aPrs.IsNull()) if (!aPrs.IsNull())
{ {
aPrs->DisconnectAll (Graphic3d_TOC_DESCENDANT); aPrs->DisconnectAll(Graphic3d_TOC_DESCENDANT);
} }
} }
} }
//=======================================================================
//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)
{ {
if (HasConnection()) if (HasConnection())
{ {
thePrs->Clear (Standard_False); thePrs->Clear(Standard_False);
thePrs->DisconnectAll (Graphic3d_TOC_DESCENDANT); thePrs->DisconnectAll(Graphic3d_TOC_DESCENDANT);
if (!myReference->HasInteractiveContext()) if (!myReference->HasInteractiveContext())
{ {
myReference->SetContext (GetContext()); myReference->SetContext(GetContext());
} }
thePrsMgr->Connect (this, myReference, theMode, theMode); thePrsMgr->Connect(this, myReference, theMode, theMode);
if (thePrsMgr->Presentation (myReference, theMode)->MustBeUpdated()) if (thePrsMgr->Presentation(myReference, theMode)->MustBeUpdated())
{ {
thePrsMgr->Update (myReference, theMode); thePrsMgr->Update(myReference, theMode);
} }
} }
@ -129,17 +125,14 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)
} }
} }
//======================================================================= //=================================================================================================
//function : computeHLR
//purpose : void AIS_ConnectedInteractive::computeHLR(const Handle(Graphic3d_Camera)& theProjector,
//======================================================================= const Handle(TopLoc_Datum3D)& theTransformation,
void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& theProjector, const Handle(Prs3d_Presentation)& thePresentation)
const Handle(TopLoc_Datum3D)& theTransformation,
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())
{ {
return; return;
@ -147,22 +140,20 @@ void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& thePr
if (hasTrsf) if (hasTrsf)
{ {
const TopLoc_Location& aLocation = myShape.Location(); const TopLoc_Location& aLocation = myShape.Location();
TopoDS_Shape aShape = myShape.Located (TopLoc_Location (theTransformation->Trsf()) * aLocation); TopoDS_Shape aShape = myShape.Located(TopLoc_Location(theTransformation->Trsf()) * aLocation);
AIS_Shape::computeHlrPresentation (theProjector, thePresentation, aShape, myDrawer); AIS_Shape::computeHlrPresentation(theProjector, thePresentation, aShape, myDrawer);
} }
else else
{ {
AIS_Shape::computeHlrPresentation (theProjector, thePresentation, myShape, myDrawer); AIS_Shape::computeHlrPresentation(theProjector, thePresentation, myShape, myDrawer);
} }
} }
//======================================================================= //=================================================================================================
//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);
if (anAisShape.IsNull()) if (anAisShape.IsNull())
{ {
return; return;
@ -174,22 +165,20 @@ void AIS_ConnectedInteractive::updateShape (const Standard_Boolean isWithLocatio
return; return;
} }
if(!isWithLocation) if (!isWithLocation)
{ {
myShape = aShape; myShape = aShape;
} }
else else
{ {
myShape = aShape.Moved (TopLoc_Location (Transformation())); myShape = aShape.Moved(TopLoc_Location(Transformation()));
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
//======================================================================= const Standard_Integer theMode)
void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{ {
if (!HasConnection()) if (!HasConnection())
{ {
@ -198,27 +187,30 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
if (theMode != 0 && myReference->AcceptShapeDecomposition()) if (theMode != 0 && myReference->AcceptShapeDecomposition())
{ {
computeSubShapeSelection (theSelection, theMode); computeSubShapeSelection(theSelection, theMode);
return; return;
} }
if (!myReference->HasSelection (theMode)) if (!myReference->HasSelection(theMode))
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection (theMode); const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(theMode);
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this); Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
TopLoc_Location aLocation (Transformation()); TopLoc_Location aLocation(Transformation());
anOwner->SetLocation (aLocation); anOwner->SetLocation(aLocation);
if (TheRefSel->IsEmpty()) if (TheRefSel->IsEmpty())
{ {
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())
{ {
@ -226,67 +218,73 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
if (Handle(Select3D_SensitiveEntity) aNewSensitive = aSensitive->GetConnected()) if (Handle(Select3D_SensitiveEntity) aNewSensitive = aSensitive->GetConnected())
{ {
aNewSensitive->Set(anOwner); aNewSensitive->Set(anOwner);
theSelection->Add (aNewSensitive); theSelection->Add(aNewSensitive);
} }
} }
} }
} }
//======================================================================= //=================================================================================================
//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))
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode); const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection(theMode);
if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full) if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full)
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
// 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))
{ {
aShapes2EntitiesMap.Bind (aSubShape, SensitiveList()); aShapes2EntitiesMap.Bind(aSubShape, SensitiveList());
} }
aShapes2EntitiesMap (aSubShape).Append (aSE); aShapes2EntitiesMap(aSubShape).Append(aSE);
} }
} }
} }
// Fill in selection from aShapes2EntitiesMap // Fill in selection from aShapes2EntitiesMap
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 =
anOwner->SetLocation (Transformation()); new StdSelect_BRepOwner(aMapIt.Key(),
for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next()) this,
aSEList.First()->OwnerId()->Priority(),
Standard_True);
anOwner->SetLocation(Transformation());
for (SensitiveList::Iterator aListIt(aSEList); aListIt.More(); aListIt.Next())
{ {
if (Handle(Select3D_SensitiveEntity) aNewSE = aListIt.Value()->GetConnected()) if (Handle(Select3D_SensitiveEntity) aNewSE = aListIt.Value()->GetConnected())
{ {
aNewSE->Set (anOwner); aNewSE->Set(anOwner);
theSelection->Add (aNewSE); theSelection->Add(aNewSE);
} }
} }
} }
StdSelect::SetDrawerForBRepOwner (theSelection, myDrawer); StdSelect::SetDrawerForBRepOwner(theSelection, myDrawer);
} }

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 //! 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)
const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (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 Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); } 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.
@ -86,14 +97,12 @@ 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.
@ -103,35 +112,36 @@ protected:
//! compute anything, but just uses the //! compute anything, but just uses the
//! presentation of this last object, with //! presentation of this last object, with
//! a transformation if there's one stored. //! a transformation if there's one stored.
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;
//! 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);
Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj, Standard_EXPORT void connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
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,15 +17,14 @@
#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,
//! - shaded, //! - shaded,
enum AIS_DisplayMode enum AIS_DisplayMode
{ {
AIS_WireFrame, AIS_WireFrame,
AIS_Shaded AIS_Shaded
}; };
#endif // _AIS_DisplayMode_HeaderFile #endif // _AIS_DisplayMode_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_ExclusionFilter.hxx> #include <AIS_ExclusionFilter.hxx>
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
@ -22,55 +21,52 @@
#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx> #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx> #include <TColStd_ListOfInteger.hxx>
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);
} }
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))
return Standard_False; return Standard_False;
TColStd_ListOfInteger L; TColStd_ListOfInteger L;
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L); myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
return Standard_True; return Standard_True;
} }
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);
return Standard_True; return Standard_True;
} }
@ -78,26 +74,27 @@ 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;
} }
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,105 +102,82 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
return Standard_False; return Standard_False;
} }
//=================================================================================================
//======================================================================= void AIS_ExclusionFilter::Clear()
//function : Clear
//purpose :
//=======================================================================
void AIS_ExclusionFilter::Clear()
{ {
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger Mit(myStoredTypes); TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger Mit(myStoredTypes);
for(;Mit.More();Mit.Next()) for (; Mit.More(); Mit.Next())
myStoredTypes.ChangeFind(Mit.Key()).Clear(); myStoredTypes.ChangeFind(Mit.Key()).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
{ {
TheList.Clear(); TheList.Clear();
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger MIT(myStoredTypes); TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger MIT(myStoredTypes);
for(;MIT.More();MIT.Next()) for (; MIT.More(); MIT.Next())
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))
for(TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType));it.More();it.Next()) for (TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType)); it.More(); it.Next())
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
{ {
if(myStoredTypes.IsEmpty()) if (myStoredTypes.IsEmpty())
return myIsExclusionFlagOn; return myIsExclusionFlagOn;
if(EO.IsNull()) if (EO.IsNull())
return Standard_False; return Standard_False;
Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
if(IO.IsNull()) if (IO.IsNull())
return Standard_False; return Standard_False;
// type of AIS is not in the map... // type of AIS is not in the map...
if(!myStoredTypes.IsBound(IO->Type())) if (!myStoredTypes.IsBound(IO->Type()))
return myIsExclusionFlagOn ; return myIsExclusionFlagOn;
// type of AIS is not in the map and there is no signature indicated // type of AIS is not in the map and there is no signature indicated
if(myStoredTypes(IO->Type()).IsEmpty()) if (myStoredTypes(IO->Type()).IsEmpty())
return !myIsExclusionFlagOn ; return !myIsExclusionFlagOn;
// one or several signatures are indicated... // one or several signatures are indicated...
if(IsSignatureIn(IO->Type(),IO->Signature())) if (IsSignatureIn(IO->Type(), IO->Signature()))
return !myIsExclusionFlagOn; return !myIsExclusionFlagOn;
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,46 +55,52 @@ 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();
Standard_Boolean IsExclusionFlagOn() const { return myIsExclusionFlagOn; } Standard_Boolean IsExclusionFlagOn() const { return myIsExclusionFlagOn; }
void SetExclusionFlag (const Standard_Boolean theStatus) { myIsExclusionFlagOn = theStatus; } void SetExclusionFlag(const Standard_Boolean theStatus) { myIsExclusionFlagOn = theStatus; }
Standard_EXPORT Standard_Boolean IsStored (const AIS_KindOfInteractive aType) const; Standard_EXPORT Standard_Boolean IsStored(const AIS_KindOfInteractive aType) const;
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,
const Standard_Integer aSignature) const;
Standard_EXPORT Standard_Boolean IsSignatureIn (const AIS_KindOfInteractive aType, 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

@ -23,8 +23,8 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
// purpose : // purpose :
// ======================================================================= // =======================================================================
AIS_GlobalStatus::AIS_GlobalStatus() AIS_GlobalStatus::AIS_GlobalStatus()
: myDispMode (0), : myDispMode(0),
myIsHilit(Standard_False), myIsHilit(Standard_False),
mySubInt (Standard_False) mySubInt(Standard_False)
{ {
} }

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();
@ -39,16 +38,16 @@ public:
Standard_Integer DisplayMode() const { return myDispMode; } Standard_Integer DisplayMode() const { return myDispMode; }
//! Sets display mode. //! Sets display mode.
void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; } void SetDisplayMode(const Standard_Integer theMode) { myDispMode = theMode; }
//! Returns TRUE if object is highlighted //! Returns TRUE if object is highlighted
Standard_Boolean IsHilighted() const { return myIsHilit; } Standard_Boolean IsHilighted() const { return myIsHilit; }
//! Sets highlighted state. //! Sets highlighted state.
void SetHilightStatus (const Standard_Boolean theStatus) { myIsHilit = theStatus; } void SetHilightStatus(const Standard_Boolean theStatus) { myIsHilit = theStatus; }
//! Changes applied highlight style for a particular object //! Changes applied highlight style for a particular object
void SetHilightStyle (const Handle(Prs3d_Drawer)& theStyle) { myHiStyle = theStyle; } void SetHilightStyle(const Handle(Prs3d_Drawer)& theStyle) { myHiStyle = theStyle; }
//! Returns applied highlight style for a particular object //! Returns applied highlight style for a particular object
const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; } const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; }
@ -57,46 +56,41 @@ public:
const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; } const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; }
//! Return TRUE if selection mode was registered. //! Return TRUE if selection mode was registered.
Standard_Boolean IsSModeIn (Standard_Integer theMode) const Standard_Boolean IsSModeIn(Standard_Integer theMode) const
{ {
return mySelModes.Contains (theMode); return mySelModes.Contains(theMode);
} }
//! Add selection mode. //! Add selection mode.
Standard_Boolean AddSelectionMode (const Standard_Integer theMode) Standard_Boolean AddSelectionMode(const Standard_Integer theMode)
{ {
if (!mySelModes.Contains (theMode)) if (!mySelModes.Contains(theMode))
{ {
mySelModes.Append (theMode); mySelModes.Append(theMode);
return Standard_True; return Standard_True;
} }
return Standard_False; return Standard_False;
} }
//! Remove selection mode. //! Remove selection mode.
Standard_Boolean RemoveSelectionMode (const Standard_Integer theMode) Standard_Boolean RemoveSelectionMode(const Standard_Integer theMode)
{ {
return mySelModes.Remove (theMode); return mySelModes.Remove(theMode);
} }
//! 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>
@ -27,96 +26,99 @@
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr, static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att) const AIS_TypeOfAttribute Att)
{ {
switch(Att) switch (Att)
{ {
case AIS_TOA_Line: case AIS_TOA_Line:
return Dr->LineAspect(); return Dr->LineAspect();
case AIS_TOA_Dimension: case AIS_TOA_Dimension:
return Dr->DimensionAspect()->LineAspect(); return Dr->DimensionAspect()->LineAspect();
case AIS_TOA_Wire: case AIS_TOA_Wire:
return Dr->WireAspect(); return Dr->WireAspect();
case AIS_TOA_Plane: case AIS_TOA_Plane:
return Dr->PlaneAspect()->EdgesAspect(); return Dr->PlaneAspect()->EdgesAspect();
case AIS_TOA_Vector: case AIS_TOA_Vector:
return Dr->VectorAspect(); return Dr->VectorAspect();
case AIS_TOA_UIso: case AIS_TOA_UIso:
return Handle(Prs3d_LineAspect) (Dr->UIsoAspect()); return Handle(Prs3d_LineAspect)(Dr->UIsoAspect());
case AIS_TOA_VIso: case AIS_TOA_VIso:
return Handle(Prs3d_LineAspect) (Dr->VIsoAspect()); return Handle(Prs3d_LineAspect)(Dr->VIsoAspect());
case AIS_TOA_Free: case AIS_TOA_Free:
return Dr->FreeBoundaryAspect(); return Dr->FreeBoundaryAspect();
case AIS_TOA_UnFree: case AIS_TOA_UnFree:
return Dr->UnFreeBoundaryAspect(); return Dr->UnFreeBoundaryAspect();
case AIS_TOA_Section: case AIS_TOA_Section:
return Dr->SectionAspect(); return Dr->SectionAspect();
case AIS_TOA_Hidden: case AIS_TOA_Hidden:
return Dr->HiddenLineAspect(); return Dr->HiddenLineAspect();
case AIS_TOA_Seen: case AIS_TOA_Seen:
return Dr->SeenLineAspect(); return Dr->SeenLineAspect();
case AIS_TOA_FaceBoundary: case AIS_TOA_FaceBoundary:
return Dr->FaceBoundaryAspect(); return Dr->FaceBoundaryAspect();
case AIS_TOA_FirstAxis: case AIS_TOA_FirstAxis:
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis); return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis);
case AIS_TOA_SecondAxis: case AIS_TOA_SecondAxis:
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis); return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis);
case AIS_TOA_ThirdAxis: case AIS_TOA_ThirdAxis:
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis); return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis);
} }
Handle(Prs3d_LineAspect) bid; Handle(Prs3d_LineAspect) bid;
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();
} }
Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr, Standard_Real AIS_GraphicTool::GetLineWidth(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att) const AIS_TypeOfAttribute Att)
{ {
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,
const AIS_TypeOfAttribute Att) Aspect_TypeOfLine AIS_GraphicTool::GetLineType(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{ {
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
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,
Standard_Real& W, Standard_Real& W,
Aspect_TypeOfLine& TYP) Aspect_TypeOfLine& TYP)
{ {
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
Col = LA->Aspect()->Color().Name(); Col = LA->Aspect()->Color().Name();
W = LA->Aspect()->Width(); W = LA->Aspect()->Width();
TYP = LA->Aspect()->Type(); TYP = LA->Aspect()->Type();
} }
Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr) Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
{ {
Quantity_Color color; Quantity_Color color;
GetInteriorColor(Dr,color); GetInteriorColor(Dr, color);
return color.Name(); return color.Name();
} }
void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor) void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color& aColor)
{ {
Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect(); Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
aColor = AFA->InteriorColor(); aColor = AFA->InteriorColor();
} }
Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr) Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)

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,
Standard_EXPORT static Quantity_NameOfColor GetInteriorColor (const Handle(Prs3d_Drawer)& aDrawer); Aspect_TypeOfLine& aTyp);
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 Quantity_NameOfColor GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer);
Standard_EXPORT static void GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer,
Quantity_Color& aColor);
Standard_EXPORT static Graphic3d_MaterialAspect GetMaterial(const Handle(Prs3d_Drawer)& aDrawer);
protected: 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

@ -27,59 +27,50 @@
#include <Prs3d_TextAspect.hxx> #include <Prs3d_TextAspect.hxx>
#include <PrsMgr_PresentationManager.hxx> #include <PrsMgr_PresentationManager.hxx>
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)
return; return;
myCTXPtr->Redisplay (this, Standard_False, AllModes); myCTXPtr->Redisplay(this, Standard_False, AllModes);
} }
//======================================================================= //=================================================================================================
//function : ProcessDragging
//purpose : Standard_Boolean AIS_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)&,
//======================================================================= const Handle(V3d_View)&,
Standard_Boolean AIS_InteractiveObject::ProcessDragging (const Handle(AIS_InteractiveContext)&, const Handle(SelectMgr_EntityOwner)&,
const Handle(V3d_View)&, const Graphic3d_Vec2i&,
const Handle(SelectMgr_EntityOwner)&, const Graphic3d_Vec2i&,
const Graphic3d_Vec2i&, const AIS_DragAction)
const Graphic3d_Vec2i&,
const AIS_DragAction)
{ {
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())
{ {
@ -89,33 +80,27 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
myCTXPtr = theCtx.get(); myCTXPtr = theCtx.get();
if (!theCtx.IsNull()) if (!theCtx.IsNull())
{ {
myDrawer->Link (theCtx->DefaultDrawer()); myDrawer->Link(theCtx->DefaultDrawer());
} }
} }
//======================================================================= //=================================================================================================
//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)
{ {
@ -147,31 +131,29 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect
const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last(); const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last();
if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect)) if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aShadingAspect->Aspect());
} }
else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect)) else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aLineAspect->Aspect());
} }
else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect)) else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aPointAspect->Aspect());
} }
else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect)) else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aTextAspect->Aspect());
} }
} }
//======================================================================= //=================================================================================================
//function : DumpJson
//purpose :
//=======================================================================
void AIS_InteractiveObject::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_SelectableObject) void AIS_InteractiveObject::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCTXPtr) {
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner) OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, SelectMgr_SelectableObject)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myCTXPtr)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myOwner)
} }

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; }
@ -66,7 +68,7 @@ public:
//! corresponding AIS_InteractiveContext instance for cases when it //! corresponding AIS_InteractiveContext instance for cases when it
//! is accessible. This method just redirects call to myCTXPtr, //! is accessible. This method just redirects call to myCTXPtr,
//! so this class field must be up to date for proper result. //! so this class field must be up to date for proper result.
Standard_EXPORT void Redisplay (const Standard_Boolean AllModes = Standard_False); Standard_EXPORT void Redisplay(const Standard_Boolean AllModes = Standard_False);
//! Indicates whether the Interactive Object has a pointer to an interactive context. //! Indicates whether the Interactive Object has a pointer to an interactive context.
Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; } Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
@ -76,10 +78,11 @@ public:
//! Sets the interactive context aCtx and provides a link //! Sets the interactive context aCtx and provides a link
//! to the default drawing tool or "Drawer" if there is none. //! to the default drawing tool or "Drawer" if there is none.
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,15 +117,15 @@ 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(V3d_View)& theView, const Handle(AIS_InteractiveContext)& theCtx,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theDragFrom, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragTo, const Graphic3d_Vec2i& theDragFrom,
const AIS_DragAction theAction); const Graphic3d_Vec2i& theDragTo,
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;
@ -131,26 +137,26 @@ public:
//! Sets the graphic basic aspect to the current presentation. //! Sets the graphic basic aspect to the current presentation.
Standard_DEPRECATED("Deprecated method, results might be undefined") Standard_DEPRECATED("Deprecated method, results might be undefined")
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,15 +27,16 @@ 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
AIS_KOI_None = AIS_KindOfInteractive_None, AIS_KOI_None = AIS_KindOfInteractive_None,
AIS_KOI_Datum = AIS_KindOfInteractive_Datum, AIS_KOI_Datum = AIS_KindOfInteractive_Datum,
AIS_KOI_Shape = AIS_KindOfInteractive_Shape, AIS_KOI_Shape = AIS_KindOfInteractive_Shape,
AIS_KOI_Object = AIS_KindOfInteractive_Object, AIS_KOI_Object = AIS_KindOfInteractive_Object,
AIS_KOI_Relation = AIS_KindOfInteractive_Relation, AIS_KOI_Relation = AIS_KindOfInteractive_Relation,
AIS_KOI_Dimension = AIS_KindOfInteractive_Dimension AIS_KOI_Dimension = AIS_KindOfInteractive_Dimension
}; };

File diff suppressed because it is too large Load Diff

View File

@ -29,28 +29,27 @@ 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);
//! Returns the light. //! Returns the light.
const Handle(Graphic3d_CLight)& Light() const { return myLightSource; } const Handle(Graphic3d_CLight)& Light() const { return myLightSource; }
//! Set the light. //! Set the light.
void SetLight (const Handle(Graphic3d_CLight)& theLight) void SetLight(const Handle(Graphic3d_CLight)& theLight)
{ {
myLightSource = theLight; myLightSource = theLight;
SetToUpdate(); SetToUpdate();
} }
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,12 +63,12 @@ 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.
void SetDisplayRange (Standard_Boolean theToDisplay) void SetDisplayRange(Standard_Boolean theToDisplay)
{ {
if (myToDisplayRange != theToDisplay) if (myToDisplayRange != theToDisplay)
{ {
@ -82,7 +81,7 @@ public: //! @name Light properties
Standard_Real Size() const { return mySize; } Standard_Real Size() const { return mySize; }
//! Sets the size of presentation. //! Sets the size of presentation.
void SetSize (Standard_Real theSize) void SetSize(Standard_Real theSize)
{ {
if (mySize != theSize) if (mySize != theSize)
{ {
@ -95,7 +94,7 @@ public: //! @name Light properties
Standard_Integer ArcSize() const { return mySensSphereArcSize; } Standard_Integer ArcSize() const { return mySensSphereArcSize; }
//! Sets the size of sensitive sphere arc. //! Sets the size of sensitive sphere arc.
void SetArcSize (Standard_Integer theSize) void SetArcSize(Standard_Integer theSize)
{ {
if (mySensSphereArcSize != theSize) if (mySensSphereArcSize != theSize)
{ {
@ -110,7 +109,7 @@ public: //! @name Light properties
bool IsZoomable() const { return myIsZoomable; } bool IsZoomable() const { return myIsZoomable; }
//! Sets if transform-persistence is allowed. //! Sets if transform-persistence is allowed.
void SetZoomable (bool theIsZoomable) void SetZoomable(bool theIsZoomable)
{ {
if (myIsZoomable != theIsZoomable) if (myIsZoomable != theIsZoomable)
{ {
@ -120,7 +119,7 @@ public: //! @name Light properties
} }
//! Sets if dragging is allowed. //! Sets if dragging is allowed.
void SetDraggable (bool theIsDraggable) void SetDraggable(bool theIsDraggable)
{ {
if (myIsDraggable != theIsDraggable) if (myIsDraggable != theIsDraggable)
{ {
@ -132,13 +131,13 @@ public: //! @name Light properties
bool ToSwitchOnClick() const { return myToSwitchOnClick; } bool ToSwitchOnClick() const { return myToSwitchOnClick; }
//! Sets if mouse click should turn light on/off. //! Sets if mouse click should turn light on/off.
void SetSwitchOnClick (bool theToHandle) { myToSwitchOnClick = theToHandle; } void SetSwitchOnClick(bool theToHandle) { myToSwitchOnClick = theToHandle; }
//! Returns a number of directional light arrows to display; 5 by default. //! Returns a number of directional light arrows to display; 5 by default.
Standard_Integer NbArrows() const { return myNbArrows; } Standard_Integer NbArrows() const { return myNbArrows; }
//! Returns a number of directional light arrows to display (supported values: 1, 3, 5, 9). //! Returns a number of directional light arrows to display (supported values: 1, 3, 5, 9).
void SetNbArrows (Standard_Integer theNbArrows) void SetNbArrows(Standard_Integer theNbArrows)
{ {
if (myNbArrows != theNbArrows) if (myNbArrows != theNbArrows)
{ {
@ -149,25 +148,29 @@ 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()
? Aspect_TOM_USERDEFINED ? Aspect_TOM_USERDEFINED
: (theIsEnabled ? Aspect_TOM_O_POINT : Aspect_TOM_O_X); : (theIsEnabled ? Aspect_TOM_O_POINT : Aspect_TOM_O_X);
} }
//! 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;
} }
@ -176,34 +179,36 @@ public: //! @name Light properties
Standard_Integer NbSplitsQuadric() const { return myNbSplitsQuadric; } Standard_Integer NbSplitsQuadric() const { return myNbSplitsQuadric; }
//! Sets tessellation level for quadric surfaces. //! Sets tessellation level for quadric surfaces.
void SetNbSplitsQuadric (Standard_Integer theNbSplits) { myNbSplitsQuadric = theNbSplits; } void SetNbSplitsQuadric(Standard_Integer theNbSplits) { myNbSplitsQuadric = theNbSplits; }
//! Returns tessellation level for arrows; 20 by default. //! Returns tessellation level for arrows; 20 by default.
Standard_Integer NbSplitsArrow() const { return myNbSplitsArrow; } Standard_Integer NbSplitsArrow() const { return myNbSplitsArrow; }
//! Sets tessellation level for arrows. //! Sets tessellation level for arrows.
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.
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;
//! Fills presentation. //! Fills presentation.
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;
//! Drag object in the viewer. //! Drag object in the viewer.
//! @param[in] theCtx interactive context //! @param[in] theCtx interactive context
@ -213,15 +218,17 @@ 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(V3d_View)& theView, const Handle(AIS_InteractiveContext)& theCtx,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theDragFrom, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragTo, const Graphic3d_Vec2i& theDragFrom,
const AIS_DragAction theAction) Standard_OVERRIDE; const Graphic3d_Vec2i& theDragTo,
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();
@ -233,26 +240,26 @@ protected:
Standard_EXPORT virtual void updateLightAspects(); Standard_EXPORT virtual void updateLightAspects();
//! Compute ambient light source presentation as a sphere at view corner. //! Compute ambient light source presentation as a sphere at view corner.
Standard_EXPORT virtual void computeAmbient (const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void computeAmbient(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode); const Standard_Integer theMode);
//! Compute directional light source presentation as a set of arrows at view corner. //! Compute directional light source presentation as a set of arrows at view corner.
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
Standard_EXPORT virtual void computePositional (const Handle(Prs3d_Presentation)& thePrs, //! size representing a maximum range.
const Standard_Integer theMode); Standard_EXPORT virtual void computePositional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode);
//! Compute spot light source presentation as a cone. //! Compute spot light source presentation as a cone.
Standard_EXPORT virtual void computeSpot (const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void computeSpot(const Handle(Prs3d_Presentation)& thePrs,
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
Handle(Graphic3d_AspectMarker3d) myDisabledMarkerAspect; //!< disabled light source marker style Handle(Graphic3d_AspectMarker3d) myDisabledMarkerAspect; //!< disabled light source marker style
Handle(Graphic3d_AspectLine3d) myArrowLineAspectShadow; //!< arrow shadow style Handle(Graphic3d_AspectLine3d) myArrowLineAspectShadow; //!< arrow shadow style
Handle(Graphic3d_MarkerImage) myMarkerImages[2]; //!< icon of disabled (0) and enabled (1) light Handle(Graphic3d_MarkerImage) myMarkerImages[2]; //!< icon of disabled (0) and enabled (1) light
@ -269,11 +276,10 @@ protected:
Standard_Integer mySensSphereArcSize; //! sensitive sphere arc size in pixels Standard_Integer mySensSphereArcSize; //! sensitive sphere arc size in pixels
Standard_Boolean myIsZoomable; //!< flag to allow/disallow transform-persistence when possible Standard_Boolean myIsZoomable; //!< flag to allow/disallow transform-persistence when possible
Standard_Boolean myIsDraggable; //!< flag to allow/disallow rotate directional light source by dragging Standard_Boolean myIsDraggable; //!< flag to allow/disallow rotate directional light source by dragging
// clang-format on // clang-format on
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,27 +287,27 @@ 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);
//! Handle mouse button click event. //! Handle mouse button click event.
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
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr, //! SelectMgr_SelectableObject::HilightOwnerWithColor method.
const Handle(Prs3d_Drawer)& theStyle, Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode) Standard_OVERRIDE; const Handle(Prs3d_Drawer)& theStyle,
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

@ -34,46 +34,43 @@
#include <StdPrs_Curve.hxx> #include <StdPrs_Curve.hxx>
#include <UnitsAPI.hxx> #include <UnitsAPI.hxx>
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): myLineIsSegment(Standard_False)
myComponent (aComponent),
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),
myEndPoint(aEndPoint),
myLineIsSegment(Standard_True)
{}
//======================================================================= AIS_Line::AIS_Line(const Handle(Geom_Point)& aStartPoint, const Handle(Geom_Point)& aEndPoint)
//function : Compute : myStartPoint(aStartPoint),
//purpose : myEndPoint(aEndPoint),
//======================================================================= myLineIsSegment(Standard_True)
void AIS_Line::Compute (const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer )
{ {
if (!myLineIsSegment) { ComputeInfiniteLine (thePrs); }
else { ComputeSegmentLine (thePrs); }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer)
{
if (!myLineIsSegment)
{
ComputeInfiniteLine(thePrs);
}
else
{
ComputeSegmentLine(thePrs);
}
}
//=================================================================================================
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,186 +89,171 @@ 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())
{ {
myDrawer->SetLineAspect (theAspect); myDrawer->SetLineAspect(theAspect);
return; return;
} }
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);
Graphic3d_MapOfAspectsToAspects aReplaceMap; Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew); aReplaceMap.Bind(anAspectOld, anAspectNew);
replaceAspects (aReplaceMap); replaceAspects(aReplaceMap);
} }
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Line::SetColor(const Quantity_Color &aCol)
{
hasOwnColor=Standard_True;
myDrawer->SetColor (aCol);
Standard_Real WW = HasWidth()? myOwnWidth: void AIS_Line::SetColor(const Quantity_Color& aCol)
myDrawer->HasLink() ? {
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.; hasOwnColor = Standard_True;
myDrawer->SetColor(aCol);
Standard_Real WW = HasWidth() ? myOwnWidth
: myDrawer->HasLink()
? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.;
if (!myDrawer->HasOwnLineAspect()) if (!myDrawer->HasOwnLineAspect())
{ {
replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW)); replaceWithNewLineAspect(new Prs3d_LineAspect(aCol, Aspect_TOL_SOLID, WW));
} }
else else
{ {
myDrawer->LineAspect()->SetColor (aCol); myDrawer->LineAspect()->SetColor(aCol);
SynchronizeAspects(); SynchronizeAspects();
} }
} }
//=================================================================================================
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Line::UnsetColor() void AIS_Line::UnsetColor()
{ {
hasOwnColor = Standard_False; hasOwnColor = Standard_False;
if (!HasWidth()) if (!HasWidth())
{ {
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
} }
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;
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();
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
} }
else else
{ {
myDrawer->LineAspect()->SetWidth (aValue); myDrawer->LineAspect()->SetWidth(aValue);
SynchronizeAspects(); SynchronizeAspects();
} }
} }
//=================================================================================================
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Line::UnsetWidth() void AIS_Line::UnsetWidth()
{ {
if (!HasColor()) if (!HasColor())
{ {
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
} }
else else
{ {
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.0f; Standard_ShortReal WW =
myDrawer->LineAspect()->SetWidth (WW); myDrawer->HasLink()
myOwnWidth = WW; ? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
SynchronizeAspects(); : 1.0f;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
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);
StdPrs_Curve::Add(aPresentation,curv,myDrawer); StdPrs_Curve::Add(aPresentation, curv, myDrawer);
//pas de prise en compte lors du FITALL // pas de prise en compte lors du FITALL
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();
gp_Pnt P2 = myEndPoint->Pnt(); gp_Pnt P2 = myEndPoint->Pnt();
myComponent = new Geom_Line(P1,gp_Dir(P2.XYZ()-P1.XYZ())); myComponent = new Geom_Line(P1, gp_Dir(P2.XYZ() - P1.XYZ()));
Standard_Real dist = P1.Distance(P2); Standard_Real dist = P1.Distance(P2);
GeomAdaptor_Curve curv(myComponent,0.,dist); GeomAdaptor_Curve curv(myComponent, 0., dist);
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)
{ {
/* // on calcule les points min max a partir desquels on cree un segment sensible... /* // on calcule les points min max a partir desquels on cree un segment sensible...
GeomAdaptor_Curve curv(myComponent); GeomAdaptor_Curve curv(myComponent);
gp_Pnt P1,P2; gp_Pnt P1,P2;
FindLimits(curv,myDrawer->MaximalParameterValue(),P1,P2); FindLimits(curv,myDrawer->MaximalParameterValue(),P1,P2);
*/ */
const gp_Dir& thedir = myComponent->Position().Direction(); const gp_Dir& thedir = myComponent->Position().Direction();
const gp_Pnt& loc = myComponent->Position().Location(); const gp_Pnt& loc = myComponent->Position().Location();
const gp_XYZ& dir_xyz = thedir.XYZ(); const gp_XYZ& dir_xyz = thedir.XYZ();
const gp_XYZ& loc_xyz = loc.XYZ(); const gp_XYZ& loc_xyz = loc.XYZ();
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH"); // POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS (250000. ,"mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
gp_Pnt P1 = loc_xyz + aLength*dir_xyz; gp_Pnt P1 = loc_xyz + aLength * dir_xyz;
gp_Pnt P2 = loc_xyz - aLength*dir_xyz; gp_Pnt P2 = loc_xyz - aLength * dir_xyz;
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,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 =
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, new Select3D_SensitiveSegment(eown, myStartPoint->Pnt(), myEndPoint->Pnt());
myStartPoint->Pnt(),
myEndPoint->Pnt());
aSelection->Add(seg); aSelection->Add(seg);
} }

View File

@ -29,40 +29,43 @@ 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; }
//! Returns the starting point thePStart and the end point thePEnd of the line set by SetPoints. //! Returns the starting point thePStart and the end point thePEnd of the line set by SetPoints.
void Points (Handle(Geom_Point)& thePStart, Handle(Geom_Point)& thePEnd) const void Points(Handle(Geom_Point)& thePStart, Handle(Geom_Point)& thePEnd) const
{ {
thePStart = myStartPoint; thePStart = myStartPoint;
thePEnd = myEndPoint; thePEnd = myEndPoint;
} }
//! instantiates an infinite line. //! instantiates an infinite line.
void SetLine (const Handle(Geom_Line)& theLine) void SetLine(const Handle(Geom_Line)& theLine)
{ {
myComponent = theLine; myComponent = theLine;
myLineIsSegment = Standard_False; myLineIsSegment = Standard_False;
} }
//! Sets the starting point thePStart and ending point thePEnd of the //! Sets the starting point thePStart and ending point thePEnd of the
//! infinite line to create a finite line segment. //! infinite line to create a finite line segment.
void SetPoints (const Handle(Geom_Point)& thePStart, const Handle(Geom_Point)& thePEnd) void SetPoints(const Handle(Geom_Point)& thePStart, const Handle(Geom_Point)& thePEnd)
{ {
myStartPoint = thePStart; myStartPoint = thePStart;
myEndPoint = thePEnd; myEndPoint = thePEnd;
@ -70,11 +73,11 @@ public:
} }
//! Provides a new color setting aColor for the line in the drawing tool, or "Drawer". //! Provides a new color setting aColor for the line in the drawing tool, or "Drawer".
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
//! Provides the new width setting aValue for the line in //! Provides the new width setting aValue for the line in
//! the drawing tool, or "Drawer". //! the drawing tool, or "Drawer".
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Removes the color setting and returns the original color. //! Removes the color setting and returns the original color.
Standard_EXPORT void UnsetColor() Standard_OVERRIDE; Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
@ -83,31 +86,28 @@ 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,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, Standard_EXPORT void ComputeInfiniteLine(const Handle(Prs3d_Presentation)& aPresentation);
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeInfiniteLine (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeSegmentLine(const Handle(Prs3d_Presentation)& aPresentation);
Standard_EXPORT void ComputeSegmentLine (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeInfiniteLineSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeInfiniteLineSelection (const Handle(SelectMgr_Selection)& aSelection); Standard_EXPORT void ComputeSegmentLineSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeSegmentLineSelection (const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value. //! Replace aspects of already computed groups with the new value.
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

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
NCOLLECTION_HSEQUENCE(AIS_ManipulatorObjectSequence, Handle(AIS_InteractiveObject)) NCOLLECTION_HSEQUENCE(AIS_ManipulatorObjectSequence, Handle(AIS_InteractiveObject))
DEFINE_STANDARD_HANDLE (AIS_Manipulator, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_Manipulator, AIS_InteractiveObject)
//! Interactive object class to manipulate local transformation of another interactive //! Interactive object class to manipulate local transformation of another interactive
//! object or a group of objects via mouse. //! object or a group of objects via mouse.
@ -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
Standard_EXPORT AIS_Manipulator (const gp_Ax2& thePosition); //! displayed.
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,32 +154,33 @@ 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.
//! If manipulator is not displayed, no mode will be activated. //! If manipulator is not displayed, no mode will be activated.
Standard_EXPORT void EnableMode (const AIS_ManipulatorMode theMode); Standard_EXPORT void EnableMode(const AIS_ManipulatorMode theMode);
//! Enables mode activation on detection (highlighting). //! Enables mode activation on detection (highlighting).
//! By default, mode is activated on selection of manipulator part. //! By default, mode is activated on selection of manipulator part.
//! @warning If this mode is enabled, selection of parts does nothing. //! @warning If this mode is enabled, selection of parts does nothing.
void SetModeActivationOnDetection (const Standard_Boolean theToEnable) void SetModeActivationOnDetection(const Standard_Boolean theToEnable)
{ {
myIsActivationOnDetection = theToEnable; myIsActivationOnDetection = theToEnable;
} }
//! @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,18 +191,22 @@ 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(V3d_View)& theView, const Handle(AIS_InteractiveContext)& theCtx,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theDragFrom, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragTo, const Graphic3d_Vec2i& theDragFrom,
const AIS_DragAction theAction) Standard_OVERRIDE; const Graphic3d_Vec2i& theDragTo,
const AIS_DragAction theAction) Standard_OVERRIDE;
//! 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.
@ -184,29 +215,32 @@ public:
//! @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. //! and is used only for custom transform set.
//! @warning It will does nothing if transformation is not initiated (with StartTransform() call). //! @warning It will does nothing if transformation is not initiated (with StartTransform() call).
Standard_EXPORT void Transform (const gp_Trsf& aTrsf); Standard_EXPORT void Transform(const gp_Trsf& aTrsf);
//! Reset start (reference) transformation. //! Reset start (reference) transformation.
//! @param[in] theToApply option to apply or to cancel the started transformation. //! @param[in] theToApply option to apply or to cancel the started 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. //! and is used only for custom transform set.
Standard_EXPORT void StopTransform (const Standard_Boolean theToApply = Standard_True); Standard_EXPORT void StopTransform(const Standard_Boolean theToApply = Standard_True);
//! 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 Handle(V3d_View)& theView); const Standard_Integer theY,
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();
@ -221,50 +255,55 @@ public:
//! @return one of the owning objects. //! @return one of the owning objects.
//! @warning raises program error if theIndex is more than owning objects count or less than 1. //! @warning raises program error if theIndex is more than owning objects count or less than 1.
Standard_EXPORT Handle(AIS_InteractiveObject) Object (const Standard_Integer theIndex) const; Standard_EXPORT Handle(AIS_InteractiveObject) Object(const Standard_Integer theIndex) const;
//! @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
gp_Trsf StartTransformation (Standard_Integer theIndex) const
{ {
Standard_ProgramError_Raise_if (theIndex < 1 || theIndex > Objects()->Upper(), return !myStartTrsfs.IsEmpty() ? myStartTrsfs.First() : gp_Trsf();
}
gp_Trsf StartTransformation(Standard_Integer theIndex) const
{
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
//! properties and local transformation to achieve necessary visual effect. //! properties and local transformation to achieve necessary visual effect.
//! @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 void SetZoomPersistence (const Standard_Boolean theToEnable); Standard_EXPORT void SetZoomPersistence(const Standard_Boolean theToEnable);
//! 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; }
@ -273,27 +312,47 @@ public: //! @name Setters for parameters
const gp_Ax2& Position() const { return myPosition; } const gp_Ax2& Position() const { return myPosition; }
//! Sets position of the manipulator object. //! Sets position of the manipulator object.
Standard_EXPORT void SetPosition (const gp_Ax2& thePosition); Standard_EXPORT void SetPosition(const gp_Ax2& thePosition);
Standard_ShortReal Size() const { return myAxes[0].Size(); } Standard_ShortReal Size() const { return myAxes[0].Size(); }
//! Sets size (length of side of the manipulator cubic bounding box. //! Sets size (length of side of the manipulator cubic bounding box.
Standard_EXPORT void SetSize (const Standard_ShortReal theSideLength); Standard_EXPORT void SetSize(const Standard_ShortReal theSideLength);
//! Sets gaps between translator, scaler and rotator sub-presentations. //! Sets gaps between translator, scaler and rotator sub-presentations.
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,52 +373,54 @@ 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
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, //! presentation.
const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode = 0) Standard_OVERRIDE; const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode = 0) Standard_OVERRIDE;
//! Computes selection sensitive zones (triangulation) for manipulator. //! Computes selection sensitive zones (triangulation) for manipulator.
//! @param[in] theNode Selection mode that is treated as transformation mode. //! @param[in] theNode Selection mode that is treated as transformation mode.
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(Prs3d_Drawer)& theStyle, const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; const Handle(Prs3d_Drawer)& theStyle,
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);
Standard_EXPORT void adjustSize (const Bnd_Box& theBox); Standard_EXPORT void adjustSize(const Bnd_Box& theBox);
Standard_EXPORT void setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers); Standard_EXPORT void setTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Redefines local transformation management method to inform user of improper use. //! Redefines local transformation management method to inform user of improper use.
//! @warning this interactive object does not support setting custom local transformation, //! @warning this interactive object does not support setting custom local transformation,
@ -364,52 +428,48 @@ 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;
}; };
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() {}
void Init (const Standard_ShortReal theInnerRadius, void Init(const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius, const Standard_ShortReal theOuterRadius,
const gp_Ax1& thePosition, const gp_Ax1& thePosition,
const Standard_Integer theSlicesNb = 20, const Standard_Integer theSlicesNb = 20,
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;
@ -419,55 +479,56 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
{ {
public: public:
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,
const Standard_Integer theSlicesNb = 20, const Standard_Integer theSlicesNb = 20,
const Standard_Integer theStacksNb = 20); const Standard_Integer theStacksNb = 20);
protected: protected:
gp_Pnt myPosition;
gp_Pnt myPosition;
Standard_ShortReal myRadius; Standard_ShortReal myRadius;
}; };
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);
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; }
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_Dir& theNormal); const gp_Pnt& theP2,
const gp_Pnt& theP3,
const gp_Dir& theNormal);
protected: protected:
Handle(Poly_Triangulation) myTriangulation;
Handle(Poly_Triangulation) myTriangulation;
Handle(Graphic3d_ArrayOfTriangles) myArray; Handle(Graphic3d_ArrayOfTriangles) myArray;
}; };
class Sector : public Quadric class Sector : public Quadric
{ {
public: public:
Sector() Sector()
: Quadric(), : Quadric(),
myRadius(0.0f) myRadius(0.0f)
{ } {
}
~Sector() { } ~Sector() {}
void Init(const Standard_ShortReal theRadius, void Init(const Standard_ShortReal theRadius,
const gp_Ax1& thePosition, const gp_Ax1& thePosition,
@ -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,36 +549,35 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Axis class Axis
{ {
public: public:
Axis(const gp_Ax1& theAxis = gp_Ax1(),
const Quantity_Color& theColor = Quantity_Color(),
const Standard_ShortReal theLength = 10.0f);
Axis (const gp_Ax1& theAxis = gp_Ax1(), void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Quantity_Color& theColor = Quantity_Color(), const Handle(Prs3d_Presentation)& thePrs,
const Standard_ShortReal theLength = 10.0f); const Handle(Prs3d_ShadingAspect)& theAspect);
void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Handle(Prs3d_ShadingAspect)& theAspect);
const gp_Ax1& ReferenceAxis() const { return myReferenceAxis; } const gp_Ax1& ReferenceAxis() const { return myReferenceAxis; }
void SetPosition (const gp_Ax1& thePosition) { myPosition = thePosition; } void SetPosition(const gp_Ax1& thePosition) { myPosition = thePosition; }
const gp_Ax1& Position() const { return myPosition; } const gp_Ax1& Position() const { return myPosition; }
void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) void SetTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
{ {
if (!myHighlightTranslator.IsNull()) if (!myHighlightTranslator.IsNull())
{ {
myHighlightTranslator->SetTransformPersistence (theTrsfPers); myHighlightTranslator->SetTransformPersistence(theTrsfPers);
} }
if (!myHighlightScaler.IsNull()) if (!myHighlightScaler.IsNull())
{ {
myHighlightScaler->SetTransformPersistence (theTrsfPers); myHighlightScaler->SetTransformPersistence(theTrsfPers);
} }
if (!myHighlightRotator.IsNull()) if (!myHighlightRotator.IsNull())
{ {
myHighlightRotator->SetTransformPersistence (theTrsfPers); myHighlightRotator->SetTransformPersistence(theTrsfPers);
} }
if (!myHighlightDragger.IsNull()) if (!myHighlightDragger.IsNull())
@ -527,21 +586,21 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
} }
} }
void Transform (const Handle(TopLoc_Datum3D)& theTransformation) void Transform(const Handle(TopLoc_Datum3D)& theTransformation)
{ {
if (!myHighlightTranslator.IsNull()) if (!myHighlightTranslator.IsNull())
{ {
myHighlightTranslator->SetTransformation (theTransformation); myHighlightTranslator->SetTransformation(theTransformation);
} }
if (!myHighlightScaler.IsNull()) if (!myHighlightScaler.IsNull())
{ {
myHighlightScaler->SetTransformation (theTransformation); myHighlightScaler->SetTransformation(theTransformation);
} }
if (!myHighlightRotator.IsNull()) if (!myHighlightRotator.IsNull())
{ {
myHighlightRotator->SetTransformation (theTransformation); myHighlightRotator->SetTransformation(theTransformation);
} }
if (!myHighlightDragger.IsNull()) if (!myHighlightDragger.IsNull())
@ -558,11 +617,11 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_Boolean HasDragging() const { return myHasDragging; } Standard_Boolean HasDragging() const { return myHasDragging; }
void SetTranslation (const Standard_Boolean theIsEnabled) { myHasTranslation = theIsEnabled; } void SetTranslation(const Standard_Boolean theIsEnabled) { myHasTranslation = theIsEnabled; }
void SetRotation (const Standard_Boolean theIsEnabled) { myHasRotation = theIsEnabled; } void SetRotation(const Standard_Boolean theIsEnabled) { myHasRotation = theIsEnabled; }
void SetScaling (const Standard_Boolean theIsEnabled) { myHasScaling = theIsEnabled; } void SetScaling(const Standard_Boolean theIsEnabled) { myHasScaling = theIsEnabled; }
void SetDragging(const Standard_Boolean theIsEnabled) { myHasDragging = theIsEnabled; } void SetDragging(const Standard_Boolean theIsEnabled) { myHasDragging = theIsEnabled; }
@ -572,9 +631,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_ShortReal AxisRadius() const { return myAxisRadius; } Standard_ShortReal AxisRadius() const { return myAxisRadius; }
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; }
@ -592,57 +654,67 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Handle(Graphic3d_ArrayOfTriangles)& TriangleArray() const { return myTriangleArray; } const Handle(Graphic3d_ArrayOfTriangles)& TriangleArray() const { return myTriangleArray; }
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)
{ {
if (myIndent > theValue * 0.1f) if (myIndent > theValue * 0.1f)
{ {
myLength = theValue * 0.7f; myLength = theValue * 0.7f;
myBoxSize = theValue * 0.15f; myBoxSize = theValue * 0.15f;
myDiskThickness = theValue * 0.05f; myDiskThickness = theValue * 0.05f;
myIndent = theValue * 0.05f; myIndent = theValue * 0.05f;
} }
else // use pre-set value of predent else // use pre-set value of predent
{ {
Standard_ShortReal aLength = theValue - 2 * myIndent; Standard_ShortReal aLength = theValue - 2 * myIndent;
myLength = aLength * 0.8f; myLength = aLength * 0.8f;
myBoxSize = aLength * 0.15f; myBoxSize = aLength * 0.15f;
myDiskThickness = aLength * 0.05f; myDiskThickness = aLength * 0.05f;
} }
myInnerRadius = myIndent * 2 + myBoxSize + myLength; myInnerRadius = myIndent * 2 + myBoxSize + myLength;
myAxisRadius = myBoxSize / 4.0f; myAxisRadius = myBoxSize / 4.0f;
} }
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;
Standard_Boolean myHasTranslation; Standard_Boolean myHasTranslation;
Standard_ShortReal myLength; //!< Length of translation axis. Standard_ShortReal myLength; //!< Length of translation axis.
Standard_ShortReal myAxisRadius; Standard_ShortReal myAxisRadius;
Standard_Boolean myHasScaling; Standard_Boolean myHasScaling;
Standard_ShortReal myBoxSize; //!< Size of scaling cube. Standard_ShortReal myBoxSize; //!< Size of scaling cube.
Standard_Boolean myHasRotation; Standard_Boolean myHasRotation;
Standard_ShortReal myInnerRadius; //!< Radius of rotation circle. Standard_ShortReal myInnerRadius; //!< Radius of rotation circle.
Standard_ShortReal myDiskThickness; Standard_ShortReal myDiskThickness;
Standard_ShortReal myIndent; //!< Gap between visual part of the manipulator. Standard_ShortReal myIndent; //!< Gap between visual part of the manipulator.
@ -650,15 +722,14 @@ 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;
Sector mySector; Sector mySector;
Disk myCircle; Disk myCircle;
float myCircleRadius; float myCircleRadius;
Cube myCube; Cube myCube;
gp_Pnt myCubePos; gp_Pnt myCubePos;
Handle(Graphic3d_Group) myTranslatorGroup; Handle(Graphic3d_Group) myTranslatorGroup;
Handle(Graphic3d_Group) myScalerGroup; Handle(Graphic3d_Group) myScalerGroup;
@ -671,14 +742,12 @@ 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
gp_Ax2 myPosition; //!< Position of the manipulator object. it displays its location and position of its axes. gp_Ax2 myPosition; //!< Position of the manipulator object. it displays its location and position of its axes.
Standard_Integer myCurrentIndex; //!< Index of active axis. Standard_Integer myCurrentIndex; //!< Index of active axis.
@ -692,18 +761,18 @@ protected: //! @name Fields for interactive transformation. Fields only for inte
NCollection_Sequence<gp_Trsf> myStartTrsfs; //!< Owning object transformation for start. It is used internally. NCollection_Sequence<gp_Trsf> myStartTrsfs; //!< Owning object transformation for start. It is used internally.
Standard_Boolean myHasStartedTransformation; //!< Shows if transformation is processed (sequential calls of Transform()). Standard_Boolean myHasStartedTransformation; //!< Shows if transformation is processed (sequential calls of Transform()).
// clang-format on // clang-format on
gp_Ax2 myStartPosition; //! Start position of manipulator. gp_Ax2 myStartPosition; //! Start position of manipulator.
gp_Pnt myStartPick; //! 3d point corresponding to start mouse pick. gp_Pnt myStartPick; //! 3d point corresponding to start mouse pick.
Standard_Real myPrevState; //! Previous value of angle during rotation. Standard_Real myPrevState; //! Previous value of angle during rotation.
//! Aspect used to color current detected part and current selected part. //! Aspect used to color current detected part and current selected part.
Handle(Prs3d_ShadingAspect) myHighlightAspect; Handle(Prs3d_ShadingAspect) myHighlightAspect;
//! 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

@ -19,7 +19,7 @@
//! Mode to make definite kind of transformations with AIS_Manipulator object. //! Mode to make definite kind of transformations with AIS_Manipulator object.
enum AIS_ManipulatorMode enum AIS_ManipulatorMode
{ {
AIS_MM_None = 0, AIS_MM_None = 0,
AIS_MM_Translation = 1, AIS_MM_Translation = 1,
AIS_MM_Rotation, AIS_MM_Rotation,
AIS_MM_Scaling, AIS_MM_Scaling,

View File

@ -15,65 +15,58 @@
#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, const Standard_Integer thePriority)
const Standard_Integer thePriority) : SelectMgr_EntityOwner(theSelObject, thePriority),
: SelectMgr_EntityOwner(theSelObject, thePriority), myIndex(theIndex),
myIndex (theIndex), myMode(theMode)
myMode (theMode)
{ {
// //
} }
//======================================================================= //=================================================================================================
//function : HilightWithColor
//purpose : void AIS_ManipulatorOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
//======================================================================= const Handle(Prs3d_Drawer)& theStyle,
void AIS_ManipulatorOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode)
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode)
{ {
if (theMode == 0) if (theMode == 0)
{ {
SelectMgr_EntityOwner::HilightWithColor (thePM, theStyle, theMode); SelectMgr_EntityOwner::HilightWithColor(thePM, theStyle, theMode);
return; return;
} }
Selectable()->HilightOwnerWithColor (thePM, theStyle, this); Selectable()->HilightOwnerWithColor(thePM, theStyle, this);
} }
//======================================================================= //=================================================================================================
//function : IsHilighted
//purpose : Standard_Boolean AIS_ManipulatorOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
//======================================================================= const Standard_Integer /*theMode*/) const
Standard_Boolean AIS_ManipulatorOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer /*theMode*/) const
{ {
if (!HasSelectable()) if (!HasSelectable())
{ {
return Standard_False; return Standard_False;
} }
return thePM->IsHighlighted (Selectable(), myMode); return thePM->IsHighlighted(Selectable(), myMode);
} }
//======================================================================= //=================================================================================================
//function : Unhilight
//purpose : void AIS_ManipulatorOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
//======================================================================= const Standard_Integer /*theMode*/)
void AIS_ManipulatorOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer /*theMode*/)
{ {
if (!HasSelectable()) if (!HasSelectable())
{ {
return; return;
} }
thePM->Unhighlight (Selectable()); thePM->Unhighlight(Selectable());
} }

View File

@ -27,22 +27,23 @@ 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,
const Standard_Integer theIndex, const Standard_Integer theIndex,
const AIS_ManipulatorMode theMode, const AIS_ManipulatorMode theMode,
const Standard_Integer thePriority = 0); const Standard_Integer thePriority = 0);
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM, Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
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
const Standard_Integer theMode) const Standard_OVERRIDE; IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const Standard_OVERRIDE;
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode) Standard_OVERRIDE; Standard_EXPORT virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) Standard_OVERRIDE;
AIS_ManipulatorMode Mode() const { return myMode; } AIS_ManipulatorMode Mode() const { return myMode; }
@ -50,9 +51,8 @@ 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.
}; };
#endif // _AIS_ManipulatorOwner_HeaderFile #endif // _AIS_ManipulatorOwner_HeaderFile

View File

@ -25,44 +25,46 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
//! Create an array of triangles defining a rectangle. //! Create an array of triangles defining a rectangle.
static Handle(Graphic3d_ArrayOfTriangles) createRectangleArray (const Graphic3d_Vec2i& theLower, static Handle(Graphic3d_ArrayOfTriangles) createRectangleArray(const Graphic3d_Vec2i& theLower,
const Graphic3d_Vec2i& theUpper, const Graphic3d_Vec2i& theUpper,
Graphic3d_ArrayFlags theFlags) Graphic3d_ArrayFlags theFlags)
{ {
Handle(Graphic3d_ArrayOfTriangles) aRectTris = new Graphic3d_ArrayOfTriangles (4, 6, theFlags); Handle(Graphic3d_ArrayOfTriangles) aRectTris = new Graphic3d_ArrayOfTriangles(4, 6, theFlags);
aRectTris->AddVertex (gp_Pnt (theLower.x(), theLower.y(), 0.0), gp_Pnt2d (0.0, 1.0)); aRectTris->AddVertex(gp_Pnt(theLower.x(), theLower.y(), 0.0), gp_Pnt2d(0.0, 1.0));
aRectTris->AddVertex (gp_Pnt (theLower.x(), theUpper.y(), 0.0), gp_Pnt2d (0.0, 0.0)); aRectTris->AddVertex(gp_Pnt(theLower.x(), theUpper.y(), 0.0), gp_Pnt2d(0.0, 0.0));
aRectTris->AddVertex (gp_Pnt (theUpper.x(), theUpper.y(), 0.0), gp_Pnt2d (1.0, 0.0)); aRectTris->AddVertex(gp_Pnt(theUpper.x(), theUpper.y(), 0.0), gp_Pnt2d(1.0, 0.0));
aRectTris->AddVertex (gp_Pnt (theUpper.x(), theLower.y(), 0.0), gp_Pnt2d (1.0, 1.0)); aRectTris->AddVertex(gp_Pnt(theUpper.x(), theLower.y(), 0.0), gp_Pnt2d(1.0, 1.0));
aRectTris->AddEdges (1, 2, 3); aRectTris->AddEdges(1, 2, 3);
aRectTris->AddEdges (1, 3, 4); aRectTris->AddEdges(1, 3, 4);
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),
myToClosePlayer (false) myToClosePlayer(false)
{ {
SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER)); SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer (Graphic3d_ZLayerId_TopOSD); SetZLayer(Graphic3d_ZLayerId_TopOSD);
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,
myFrameAspect->SetShadingModel (Graphic3d_TypeOfShadingModel_Unlit); Quantity_NOC_WHITE,
myFrameAspect->SetTextureMapOn (true); Quantity_NOC_BLACK,
myFrameAspect->SetTextureSet (myFramePair); Aspect_TOL_SOLID,
1.0f,
aMat,
aMat);
myFrameAspect->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
myFrameAspect->SetTextureMapOn(true);
myFrameAspect->SetTextureSet(myFramePair);
} }
//================================================================ //=================================================================================================
// Function : ~AIS_MediaPlayer
// Purpose :
//================================================================
AIS_MediaPlayer::~AIS_MediaPlayer() AIS_MediaPlayer::~AIS_MediaPlayer()
{ {
// stop threads // stop threads
@ -73,16 +75,14 @@ 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;
} }
myFramePair->OpenInput (thePath, theToWait); myFramePair->OpenInput(thePath, theToWait);
SynchronizeAspects(); SynchronizeAspects();
} }
@ -90,8 +90,8 @@ void AIS_MediaPlayer::OpenInput (const TCollection_AsciiString& thePath,
// function : PresentFrame // function : PresentFrame
// purpose : // purpose :
// ======================================================================= // =======================================================================
bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner, bool AIS_MediaPlayer::PresentFrame(const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize) const Graphic3d_Vec2i& theMaxSize)
{ {
if (myToClosePlayer) if (myToClosePlayer)
{ {
@ -106,9 +106,9 @@ bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
myFramePair->PlayerContext()->Pause(); myFramePair->PlayerContext()->Pause();
} }
Handle(AIS_InteractiveContext) aCtx = GetContext(); Handle(AIS_InteractiveContext) aCtx = GetContext();
Handle(AIS_InteractiveObject) aThis = this; Handle(AIS_InteractiveObject) aThis = this;
aCtx->Remove (aThis, false); aCtx->Remove(aThis, false);
aCtx->CurrentViewer()->Invalidate(); aCtx->CurrentViewer()->Invalidate();
return true; return true;
} }
@ -119,10 +119,10 @@ bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
} }
bool toRedraw = myFramePair->SwapFrames(); bool toRedraw = myFramePair->SwapFrames();
toRedraw = updateSize (theLeftCorner, theMaxSize) || toRedraw; toRedraw = updateSize(theLeftCorner, theMaxSize) || toRedraw;
if (toRedraw) if (toRedraw)
{ {
myFrameAspect->SetShaderProgram (myFramePair->ShaderProgram()); myFrameAspect->SetShaderProgram(myFramePair->ShaderProgram());
SynchronizeAspects(); SynchronizeAspects();
} }
return toRedraw; return toRedraw;
@ -132,18 +132,17 @@ bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
// function : updateSize // function : updateSize
// purpose : // purpose :
// ======================================================================= // =======================================================================
bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner, bool AIS_MediaPlayer::updateSize(const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize) const Graphic3d_Vec2i& theMaxSize)
{ {
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());
aNewSize = aFrameSize; aNewSize = aFrameSize;
if (aFitAspect >= anAspect) if (aFitAspect >= anAspect)
{ {
aNewSize.y() = int(double(aFrameSize.x()) / aFitAspect); aNewSize.y() = int(double(aFrameSize.x()) / aFitAspect);
@ -158,31 +157,29 @@ bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner,
if (aNewSize[aCoord] > theMaxSize[aCoord]) if (aNewSize[aCoord] > theMaxSize[aCoord])
{ {
const double aScale = double(theMaxSize[aCoord]) / double(aNewSize[aCoord]); const double aScale = double(theMaxSize[aCoord]) / double(aNewSize[aCoord]);
aNewSize.x() = int(double(aNewSize.x()) * aScale); aNewSize.x() = int(double(aNewSize.x()) * aScale);
aNewSize.y() = int(double(aNewSize.y()) * aScale); aNewSize.y() = int(double(aNewSize.y()) * aScale);
} }
} }
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;
} }
myFrameSize = aNewSize; myFrameSize = aNewSize;
myFrameBottomLeft = aNewPos; myFrameBottomLeft = aNewPos;
if (HasInteractiveContext()) if (HasInteractiveContext())
{ {
SetToUpdate(); SetToUpdate();
GetContext()->Redisplay (this, false); GetContext()->Redisplay(this, false);
GetContext()->CurrentViewer()->Invalidate(); GetContext()->CurrentViewer()->Invalidate();
} }
return true; return true;
@ -200,19 +197,19 @@ void AIS_MediaPlayer::PlayPause()
} }
Standard_Real aProgress = 0.0, aDuration = 0.0; Standard_Real aProgress = 0.0, aDuration = 0.0;
bool isPaused = false; bool isPaused = false;
myFramePair->PlayerContext()->PlayPause (isPaused, aProgress, aDuration); myFramePair->PlayerContext()->PlayPause(isPaused, aProgress, aDuration);
} }
// ======================================================================= // =======================================================================
// function : Compute // function : Compute
// purpose : // purpose :
// ======================================================================= // =======================================================================
void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& , void AIS_MediaPlayer::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
thePrs->SetInfiniteState (IsInfinite()); thePrs->SetInfiniteState(IsInfinite());
if (theMode != 0) if (theMode != 0)
{ {
return; return;
@ -220,10 +217,13 @@ 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);
} }
} }
@ -231,18 +231,20 @@ void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& ,
// function : ComputeSelection // function : ComputeSelection
// purpose : // purpose :
// ======================================================================= // =======================================================================
void AIS_MediaPlayer::ComputeSelection (const Handle(SelectMgr_Selection)& theSel, void AIS_MediaPlayer::ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
if (theMode != 0) if (theMode != 0)
{ {
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);
aSens->InitTriangulation (aTris->Attributes(), aTris->Indices(), TopLoc_Location()); aSens->InitTriangulation(aTris->Attributes(), aTris->Indices(), TopLoc_Location());
theSel->Add (aSens); theSel->Add(aSens);
} }

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,18 +32,19 @@ 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);
} }
//! Open specified file. //! Open specified file.
Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath, Standard_EXPORT void OpenInput(const TCollection_AsciiString& thePath,
Standard_Boolean theToWait); Standard_Boolean theToWait);
//! Display new frame. //! Display new frame.
Standard_EXPORT bool PresentFrame (const Graphic3d_Vec2i& theLeftCorner, Standard_EXPORT bool PresentFrame(const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize); const Graphic3d_Vec2i& theMaxSize);
//! Return player context. //! Return player context.
const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); } const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); }
@ -62,35 +62,34 @@ public:
//! Return duration. //! Return duration.
double Duration() const { return myFramePair->Duration(); } double Duration() const { return myFramePair->Duration(); }
//! @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,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection //! Compute selection
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;
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

@ -20,28 +20,32 @@
//! Mouse gesture - only one can be active at one moment. //! Mouse gesture - only one can be active at one moment.
enum AIS_MouseGesture 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
AIS_MouseGesture_Pan, //!< view panning gesture //! to finish
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture AIS_MouseGesture_Pan, //!< view panning gesture
AIS_MouseGesture_RotateView, //!< view rotation gesture AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
AIS_MouseGesture_Drag, //!< object dragging; AIS_MouseGesture_RotateView, //!< view rotation gesture
//! press button to start, move mouse to define rectangle, release to finish AIS_MouseGesture_Drag, //!< object dragging;
//! press button to start, move mouse to define rectangle, release to
//! finish
}; };
//! Map defining mouse gestures. //! Map defining mouse gestures.
typedef NCollection_DataMap<unsigned int, AIS_MouseGesture> AIS_MouseGestureMap; typedef NCollection_DataMap<unsigned int, AIS_MouseGesture> AIS_MouseGestureMap;
typedef NCollection_DataMap<unsigned int, AIS_SelectionScheme> AIS_MouseSelectionSchemeMap; typedef NCollection_DataMap<unsigned int, AIS_SelectionScheme> AIS_MouseSelectionSchemeMap;
#endif // _AIS_MouseGesture_HeaderFile #endif // _AIS_MouseGesture_HeaderFile

View File

@ -21,49 +21,49 @@
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
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)
{ {
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)
{ {
if (myAssemblyOwner.IsNull()) if (myAssemblyOwner.IsNull())
myAssemblyOwner = new SelectMgr_EntityOwner (this); myAssemblyOwner = new SelectMgr_EntityOwner(this);
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;
} }
aNewMultiConnected->Connect (anInteractive); aNewMultiConnected->Connect(anInteractive);
} }
anObjectToAdd = aNewMultiConnected; anObjectToAdd = aNewMultiConnected;
@ -71,81 +71,69 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const H
else else
{ {
Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive(); Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom()); aNewConnected->Connect(theAnotherObj, theAnotherObj->LocalTransformationGeom());
anObjectToAdd = aNewConnected; anObjectToAdd = aNewConnected;
} }
anObjectToAdd->SetLocalTransformation (theTrsf); anObjectToAdd->SetLocalTransformation(theTrsf);
if (!theTrsfPers.IsNull()) if (!theTrsfPers.IsNull())
{ {
anObjectToAdd->SetTransformPersistence (theTrsfPers); anObjectToAdd->SetTransformPersistence(theTrsfPers);
} }
AddChild (anObjectToAdd); AddChild(anObjectToAdd);
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()
{ {
Standard_Integer aNbItemsToRemove = Children().Size(); Standard_Integer aNbItemsToRemove = Children().Size();
for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter) for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter)
{ {
RemoveChild (Children().First()); RemoveChild(Children().First());
} }
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_MultipleConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)&,
void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer)
const Handle(Prs3d_Presentation)& ,
const Standard_Integer )
{ {
Handle(AIS_InteractiveContext) aCtx = GetContext(); Handle(AIS_InteractiveContext) aCtx = GetContext();
for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) for (PrsMgr_ListOfPresentableObjectsIter anIter(Children()); anIter.More(); anIter.Next())
{ {
Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast(anIter.Value());
if (!aChild.IsNull()) if (!aChild.IsNull())
{ {
aChild->SetContext (aCtx); aChild->SetContext(aCtx);
} }
} }
} }
//======================================================================= //=================================================================================================
//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())
{ {
Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast(anIter.Value());
if (aChild.IsNull()) if (aChild.IsNull())
{ {
continue; continue;
@ -159,49 +147,46 @@ 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)
{ {
return; return;
} }
for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) for (PrsMgr_ListOfPresentableObjectsIter anIter(Children()); anIter.More(); anIter.Next())
{ {
Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast(anIter.Value());
if (aChild.IsNull()) if (aChild.IsNull())
{ {
continue; continue;
} }
if (!aChild->HasSelection (theMode)) if (!aChild->HasSelection(theMode))
{ {
aChild->RecomputePrimitives (theMode); aChild->RecomputePrimitives(theMode);
} }
Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode); Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection(theMode);
aChild->ComputeSelection (aSelection, theMode); aChild->ComputeSelection(aSelection, theMode);
} }
} }
//======================================================================= //=================================================================================================
//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);
for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) for (PrsMgr_ListOfPresentableObjectsIter anIter(Children()); anIter.More(); anIter.Next())
{ {
Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast(anIter.Value());
if (!aChild.IsNull()) if (!aChild.IsNull())
{ {
aChild->SetContext (theCtx); aChild->SetContext(theCtx);
} }
} }
} }

View File

@ -29,22 +29,25 @@ 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,
const Handle(Graphic3d_TransformPers)& theTrsfPers) const Handle(Graphic3d_TransformPers)& theTrsfPers)
{ {
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; }
@ -52,7 +55,7 @@ public:
Standard_EXPORT Standard_Boolean HasConnection() const; Standard_EXPORT Standard_Boolean HasConnection() const;
//! Removes the connection with theInteractive. //! Removes the connection with theInteractive.
Standard_EXPORT void Disconnect (const Handle(AIS_InteractiveObject)& theInteractive); Standard_EXPORT void Disconnect(const Handle(AIS_InteractiveObject)& theInteractive);
//! Clears all the connections to objects. //! Clears all the connections to objects.
Standard_EXPORT void DisconnectAll(); Standard_EXPORT void DisconnectAll();
@ -62,71 +65,83 @@ 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,
const Handle(Graphic3d_TransformPers)& theTrsfPers) const Handle(Graphic3d_TransformPers)& theTrsfPers)
{ {
return connect (theAnotherObj, new TopLoc_Datum3D (theLocation), theTrsfPers); return connect(theAnotherObj, new TopLoc_Datum3D(theLocation), theTrsfPers);
} }
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
//! compute anything, but just uses the //! compute anything, but just uses the
//! presentation of this last object, with //! presentation of this last object, with
//! a transformation if there's one stored. //! a transformation if there's one stored.
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;
//! 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(TopLoc_Datum3D)& theLocation, const Handle(AIS_InteractiveObject)& theInteractive,
const Handle(Graphic3d_TransformPers)& theTrsfPers); const Handle(TopLoc_Datum3D)& theLocation,
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

@ -46,294 +46,270 @@
#include <StdPrs_Plane.hxx> #include <StdPrs_Plane.hxx>
#include <TColgp_Array1OfPnt.hxx> #include <TColgp_Array1OfPnt.hxx>
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, myCenter(gp_Pnt(0., 0., 0.)),
const Standard_Boolean aCurrentMode): myCurrentMode(aCurrentMode),
myComponent(aComponent), myAutomaticPosition(Standard_True),
myCenter(gp_Pnt(0.,0.,0.)), myTypeOfPlane(AIS_TOPL_Unknown),
myCurrentMode(aCurrentMode), myIsXYZPlane(Standard_False),
myAutomaticPosition(Standard_True), myTypeOfSensitivity(Select3D_TOS_BOUNDARY)
myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
{ {
InitDrawerAttributes(); InitDrawerAttributes();
} }
//======================================================================= //=======================================================================
//function : AIS_Plane // function : AIS_Plane
//purpose : avec une position // purpose : avec une position
//======================================================================= //=======================================================================
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),
myTypeOfPlane(AIS_TOPL_Unknown), myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False), myIsXYZPlane(Standard_False),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY) myTypeOfSensitivity(Select3D_TOS_BOUNDARY)
{
InitDrawerAttributes();
}
//=================================================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const gp_Pnt& aPmin,
const gp_Pnt& aPmax,
const Standard_Boolean aCurrentMode)
: myComponent(aComponent),
myCenter(aCenter),
myPmin(aPmin),
myPmax(aPmax),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_False),
myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False),
myTypeOfSensitivity(Select3D_TOS_BOUNDARY)
{ {
InitDrawerAttributes(); InitDrawerAttributes();
} }
//======================================================================= //=======================================================================
//function : AIS_Plane // function : AIS_Plane
//purpose : // purpose : XYPlane, XZPlane, YZPlane
//=======================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const gp_Pnt& aPmin,
const gp_Pnt& aPmax,
const Standard_Boolean aCurrentMode):
myComponent(aComponent),
myCenter(aCenter),
myPmin(aPmin),
myPmax(aPmax),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_False),
myTypeOfPlane(AIS_TOPL_Unknown),
myIsXYZPlane(Standard_False),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
{
InitDrawerAttributes();
}
//=======================================================================
//function : AIS_Plane
//purpose : XYPlane, XZPlane, YZPlane
//======================================================================= //=======================================================================
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),
myIsXYZPlane(Standard_True), myIsXYZPlane(Standard_True),
myTypeOfSensitivity (Select3D_TOS_BOUNDARY) myTypeOfSensitivity(Select3D_TOS_BOUNDARY)
{ {
InitDrawerAttributes(); InitDrawerAttributes();
ComputeFields(); ComputeFields();
} }
//=================================================================================================
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent) void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent)
{ {
myComponent = aComponent; myComponent = aComponent;
myTypeOfPlane = AIS_TOPL_Unknown; myTypeOfPlane = AIS_TOPL_Unknown;
myIsXYZPlane = Standard_False; myIsXYZPlane = Standard_False;
//myCenter = gp_Pnt(0.,0.,0.); // myCenter = gp_Pnt(0.,0.,0.);
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, //=================================================================================================
const AIS_TypeOfPlane aPlaneType)
void AIS_Plane::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfPlane aPlaneType)
{ {
myTypeOfPlane = aPlaneType; myTypeOfPlane = aPlaneType;
myIsXYZPlane = Standard_True; myIsXYZPlane = Standard_True;
myAx2= aComponent; myAx2 = aComponent;
myAutomaticPosition = Standard_True; myAutomaticPosition = Standard_True;
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;
aPmax = myPmax; aPmax = myPmax;
aStatus = Standard_True; aStatus = Standard_True;
} }
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,
const gp_Pnt& aPmax) const gp_Pnt& aPmax)
{ {
myAutomaticPosition = Standard_False; myAutomaticPosition = Standard_False;
myComponent = aComponent; myComponent = aComponent;
myCenter = aCenter; myCenter = aCenter;
myPmin = aPmin; myPmin = aPmin;
myPmax = aPmax; myPmax = aPmax;
myTypeOfPlane = AIS_TOPL_Unknown; myTypeOfPlane = AIS_TOPL_Unknown;
myIsXYZPlane = Standard_False; myIsXYZPlane = Standard_False;
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_Plane::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{ {
ComputeFields(); ComputeFields();
thePrs->SetInfiniteState (myInfiniteState); thePrs->SetInfiniteState(myInfiniteState);
myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0? 1 : 3); myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0 ? 1 : 3);
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);
} }
else else
{ {
DsgPrs_XYZPlanePresentation::Add (thePrs, myDrawer, myCenter, myPmin, myPmax); DsgPrs_XYZPlanePresentation::Add(thePrs, myDrawer, myCenter, myPmin, myPmax);
} }
break; break;
} }
case 1: case 1: {
{
if (!myIsXYZPlane) if (!myIsXYZPlane)
{ {
ComputeFrame(); ComputeFrame();
Handle(Prs3d_PlaneAspect) anAspect = myDrawer->PlaneAspect(); Handle(Prs3d_PlaneAspect) anAspect = myDrawer->PlaneAspect();
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup(); Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); aGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
gp_Pnt p1; gp_Pnt p1;
const Standard_Real Xmax = 0.5*Standard_Real(anAspect->PlaneXLength()); const Standard_Real Xmax = 0.5 * Standard_Real(anAspect->PlaneXLength());
const Standard_Real Ymax = 0.5*Standard_Real(anAspect->PlaneYLength()); const Standard_Real Ymax = 0.5 * Standard_Real(anAspect->PlaneYLength());
Handle(Graphic3d_ArrayOfQuadrangles) aQuads = new Graphic3d_ArrayOfQuadrangles(4); Handle(Graphic3d_ArrayOfQuadrangles) aQuads = new Graphic3d_ArrayOfQuadrangles(4);
myComponent->D0(-Xmax,Ymax,p1); myComponent->D0(-Xmax, Ymax, p1);
aQuads->AddVertex(p1); aQuads->AddVertex(p1);
myComponent->D0(Xmax,Ymax,p1); myComponent->D0(Xmax, Ymax, p1);
aQuads->AddVertex(p1); aQuads->AddVertex(p1);
myComponent->D0(Xmax,-Ymax,p1); myComponent->D0(Xmax, -Ymax, p1);
aQuads->AddVertex(p1); aQuads->AddVertex(p1);
myComponent->D0(-Xmax,-Ymax,p1); myComponent->D0(-Xmax, -Ymax, p1);
aQuads->AddVertex(p1); aQuads->AddVertex(p1);
aGroup->AddPrimitiveArray (aQuads); aGroup->AddPrimitiveArray(aQuads);
} }
else else
{ {
DsgPrs_ShadedPlanePresentation::Add (thePrs, myDrawer, myCenter, myPmin, myPmax); DsgPrs_ShadedPlanePresentation::Add(thePrs, myDrawer, myCenter, myPmin, myPmax);
} }
break; break;
} }
} }
} }
//======================================================================= //=================================================================================================
//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);
Handle(Poly_Triangulation) aSensitivePoly; Handle(Poly_Triangulation) aSensitivePoly;
if (!myIsXYZPlane) if (!myIsXYZPlane)
{ {
// plane representing rectangle // plane representing rectangle
Standard_Real aLengthX = myDrawer->PlaneAspect()->PlaneXLength() / 2.0; Standard_Real aLengthX = myDrawer->PlaneAspect()->PlaneXLength() / 2.0;
Standard_Real aLengthY = myDrawer->PlaneAspect()->PlaneYLength() / 2.0; Standard_Real aLengthY = myDrawer->PlaneAspect()->PlaneYLength() / 2.0;
Handle(Geom_Plane) aPlane = Handle(Geom_Plane) aPlane =
Handle(Geom_Plane)::DownCast (myComponent->Translated (myComponent->Location(), myCenter)); Handle(Geom_Plane)::DownCast(myComponent->Translated(myComponent->Location(), myCenter));
TColgp_Array1OfPnt aRectanglePoints (1, 4); TColgp_Array1OfPnt aRectanglePoints(1, 4);
aPlane->D0 ( aLengthX, aLengthY, aRectanglePoints.ChangeValue (1)); aPlane->D0(aLengthX, aLengthY, aRectanglePoints.ChangeValue(1));
aPlane->D0 ( aLengthX, -aLengthY, aRectanglePoints.ChangeValue (2)); aPlane->D0(aLengthX, -aLengthY, aRectanglePoints.ChangeValue(2));
aPlane->D0 (-aLengthX, -aLengthY, aRectanglePoints.ChangeValue (3)); aPlane->D0(-aLengthX, -aLengthY, aRectanglePoints.ChangeValue(3));
aPlane->D0 (-aLengthX, aLengthY, aRectanglePoints.ChangeValue (4)); aPlane->D0(-aLengthX, aLengthY, aRectanglePoints.ChangeValue(4));
Poly_Array1OfTriangle aTriangles (1, 2); Poly_Array1OfTriangle aTriangles(1, 2);
aTriangles.ChangeValue (1) = Poly_Triangle (1, 2, 3); aTriangles.ChangeValue(1) = Poly_Triangle(1, 2, 3);
aTriangles.ChangeValue (2) = Poly_Triangle (1, 3, 4); aTriangles.ChangeValue(2) = Poly_Triangle(1, 3, 4);
aSensitivePoly = new Poly_Triangulation (aRectanglePoints, aTriangles); aSensitivePoly = new Poly_Triangulation(aRectanglePoints, aTriangles);
} }
else else
{ {
// plane representing triangle // plane representing triangle
TColgp_Array1OfPnt aTrianglePoints (1, 3); TColgp_Array1OfPnt aTrianglePoints(1, 3);
aTrianglePoints.ChangeValue (1) = myCenter; aTrianglePoints.ChangeValue(1) = myCenter;
aTrianglePoints.ChangeValue (2) = myPmin; aTrianglePoints.ChangeValue(2) = myPmin;
aTrianglePoints.ChangeValue (3) = myPmax; aTrianglePoints.ChangeValue(3) = myPmax;
Poly_Array1OfTriangle aTriangles (1, 1); Poly_Array1OfTriangle aTriangles(1, 1);
aTriangles.ChangeValue (1) = Poly_Triangle(1, 2, 3); aTriangles.ChangeValue(1) = Poly_Triangle(1, 2, 3);
aSensitivePoly = new Poly_Triangulation (aTrianglePoints, aTriangles); aSensitivePoly = new Poly_Triangulation(aTrianglePoints, aTriangles);
} }
Standard_Boolean isSensitiveInterior = myTypeOfSensitivity == Select3D_TOS_INTERIOR; Standard_Boolean isSensitiveInterior = myTypeOfSensitivity == Select3D_TOS_INTERIOR;
Handle(Select3D_SensitiveTriangulation) aSensitive = Handle(Select3D_SensitiveTriangulation) aSensitive =
new Select3D_SensitiveTriangulation (aSensitiveOwner, new Select3D_SensitiveTriangulation(aSensitiveOwner,
aSensitivePoly, aSensitivePoly,
TopLoc_Location(), TopLoc_Location(),
isSensitiveInterior); isSensitiveInterior);
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
Handle(Prs3d_PlaneAspect) PA; Handle(Prs3d_PlaneAspect) PA;
Handle(Prs3d_DatumAspect) DA; Handle(Prs3d_DatumAspect) DA;
@ -341,80 +317,77 @@ void AIS_Plane::SetSize(const Standard_Real aXLength,
PA = myDrawer->PlaneAspect(); PA = myDrawer->PlaneAspect();
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();
} }
PA->SetPlaneLength(aXLength,aYLength); PA->SetPlaneLength(aXLength, aYLength);
DA->SetAxisLength(aXLength,aYLength,aXLength); DA->SetAxisLength(aXLength, aYLength, aXLength);
if(!yenavaitPA) if (!yenavaitPA)
myDrawer->SetPlaneAspect(PA); myDrawer->SetPlaneAspect(PA);
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...
//======================================================================= //=======================================================================
void AIS_Plane::UnsetSize() void AIS_Plane::UnsetSize()
{ {
if(!myHasOwnSize) return; if (!myHasOwnSize)
if(!hasOwnColor) return;
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),
DA->AxisLength(Prs3d_DatumParts_YAxis), DA->AxisLength(Prs3d_DatumParts_YAxis),
DA->AxisLength(Prs3d_DatumParts_ZAxis)); DA->AxisLength(Prs3d_DatumParts_ZAxis));
} }
myHasOwnSize = Standard_False; myHasOwnSize = Standard_False;
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
{ {
X = myDrawer->PlaneAspect()->PlaneXLength(); X = myDrawer->PlaneAspect()->PlaneXLength();
Y = myDrawer->PlaneAspect()->PlaneYLength(); Y = myDrawer->PlaneAspect()->PlaneYLength();
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)
{ {
@ -422,49 +395,47 @@ void AIS_Plane::SetMinimumSize (const Standard_Real theValue)
return; return;
} }
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
// Standard_Boolean yenadeja = hasOwnColor || myHasOwnSize; // Standard_Boolean yenadeja = hasOwnColor || myHasOwnSize;
Handle(Prs3d_PlaneAspect) PA; Handle(Prs3d_PlaneAspect) PA;
Handle(Prs3d_DatumAspect) DA; Handle(Prs3d_DatumAspect) DA;
PA = myDrawer->PlaneAspect(); PA = myDrawer->PlaneAspect();
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();
} }
PA->EdgesAspect()->SetColor(aCol); PA->EdgesAspect()->SetColor(aCol);
@ -472,31 +443,32 @@ void AIS_Plane::SetColor(const Quantity_Color &aCol)
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol); DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(aCol); DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(aCol);
if(!yenavaitPA) if (!yenavaitPA)
myDrawer->SetPlaneAspect(PA); myDrawer->SetPlaneAspect(PA);
if(!yenavaitDA) if (!yenavaitDA)
myDrawer->SetDatumAspect(DA); myDrawer->SetDatumAspect(DA);
myDrawer->ShadingAspect()->SetColor(aCol); myDrawer->ShadingAspect()->SetColor(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)
if(!myHasOwnSize) return;
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,100 +477,107 @@ 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); {
pl->D0 (U, V, myCenter); ElSLib::Parameters(pl->Pln(), myCenter, U, V);
pl->D0(U, V, myCenter);
} }
else { else
Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter))); {
ElSLib::Parameters(thegoodpl->Pln(),myPmin,U,V); Handle(Geom_Plane) thegoodpl(
Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(), myCenter)));
ElSLib::Parameters(thegoodpl->Pln(), myPmin, U, V);
U = 2.4*Abs(U); 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;
SetSize(U,V); if (V < 10 * Precision::Confusion())
myDrawer->PlaneAspect()->SetPlaneLength(U,V); V = 0.1;
SetSize(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();
gp_Dir oX = myAx2->Ax2().XDirection(); gp_Dir oX = myAx2->Ax2().XDirection();
gp_Dir oY = myAx2->Ax2().YDirection(); gp_Dir oY = myAx2->Ax2().YDirection();
gp_Dir oZ = myAx2->Ax2().Direction(); gp_Dir oZ = myAx2->Ax2().Direction();
myCenter = Orig; myCenter = Orig;
Standard_Real xo,yo,zo,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4=0,y4=0,z4=0; Standard_Real xo, yo, zo, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4 = 0, y4 = 0, z4 = 0;
Standard_Real x5=0,y5=0,z5=0; Standard_Real x5 = 0, y5 = 0, z5 = 0;
Orig.Coord(xo,yo,zo); Orig.Coord(xo, yo, zo);
oX.Coord(x1,y1,z1); oX.Coord(x1, y1, z1);
oY.Coord(x2,y2,z2); oY.Coord(x2, y2, z2);
oZ.Coord(x3,y3,z3); oZ.Coord(x3, y3, z3);
Standard_Real DS1 = DA->AxisLength(Prs3d_DatumParts_XAxis); Standard_Real DS1 = DA->AxisLength(Prs3d_DatumParts_XAxis);
Standard_Real DS2 = DA->AxisLength(Prs3d_DatumParts_YAxis); Standard_Real DS2 = DA->AxisLength(Prs3d_DatumParts_YAxis);
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;
break; z4 = zo + z1 * DS1;
x5 = xo + x2 * DS2;
y5 = yo + y2 * DS2;
z5 = zo + z2 * DS2;
break;
} }
case AIS_TOPL_XZPlane: case AIS_TOPL_XZPlane: {
{ gp_Pln XZP(0, 1, 0, 0);
gp_Pln XZP(0,1,0,0); myComponent = new Geom_Plane(XZP);
myComponent = new Geom_Plane(XZP); x4 = xo + x1 * DS1;
x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1; y4 = yo + y1 * DS1;
x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3; z4 = zo + z1 * DS1;
break; x5 = xo + x3 * DS3;
y5 = yo + y3 * DS3;
z5 = zo + z3 * DS3;
break;
} }
case AIS_TOPL_YZPlane: case AIS_TOPL_YZPlane: {
{ gp_Pln XZP(1, 0, 0, 0);
gp_Pln XZP(1,0,0,0); myComponent = new Geom_Plane(XZP);
myComponent = new Geom_Plane(XZP); x4 = xo + x2 * DS2;
x4=xo+x2*DS2; y4=yo+y2*DS2; z4=zo+z2*DS2; y4 = yo + y2 * DS2;
x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3; z4 = zo + z2 * DS2;
break; x5 = xo + x3 * DS3;
y5 = yo + y3 * DS3;
z5 = zo + z3 * DS3;
break;
} }
default: default:
break; break;
} }
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()
{ {
@ -607,30 +586,23 @@ void AIS_Plane::InitDrawerAttributes()
shasp->SetColor(Quantity_NOC_GRAY40); shasp->SetColor(Quantity_NOC_GRAY40);
myDrawer->SetShadingAspect(shasp); myDrawer->SetShadingAspect(shasp);
Handle(Graphic3d_AspectFillArea3d) asf = shasp->Aspect(); Handle(Graphic3d_AspectFillArea3d) asf = shasp->Aspect();
Graphic3d_MaterialAspect asp = asf->FrontMaterial(); Graphic3d_MaterialAspect asp = asf->FrontMaterial();
asp.SetTransparency (0.8f); asp.SetTransparency(0.8f);
asf->SetFrontMaterial(asp); asf->SetFrontMaterial(asp);
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,42 +31,50 @@ 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);
//! Sets the size defined by the length along the X axis //! Sets the size defined by the length along the X axis
//! XVal and the length along the Y axis YVal. //! XVal and the length along the Y axis YVal.
Standard_EXPORT void SetSize (const Standard_Real Xval, const Standard_Real YVal); Standard_EXPORT void SetSize(const Standard_Real Xval, const Standard_Real YVal);
Standard_EXPORT void UnsetSize(); Standard_EXPORT void UnsetSize();
Standard_EXPORT Standard_Boolean Size (Standard_Real& X, Standard_Real& Y) const; Standard_EXPORT Standard_Boolean Size(Standard_Real& X, Standard_Real& Y) const;
Standard_Boolean HasOwnSize() const { return myHasOwnSize; } Standard_Boolean HasOwnSize() const { return myHasOwnSize; }
//! Sets transform persistence for zoom with value of minimum size //! Sets transform persistence for zoom with value of minimum size
Standard_EXPORT void SetMinimumSize (const Standard_Real theValue); Standard_EXPORT void SetMinimumSize(const Standard_Real theValue);
//! Unsets transform persistence zoom //! Unsets transform persistence zoom
Standard_EXPORT void UnsetMinimumSize(); Standard_EXPORT void UnsetMinimumSize();
@ -76,29 +84,38 @@ 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; }
//! Creates an instance of the plane aComponent. //! Creates an instance of the plane aComponent.
Standard_EXPORT void SetComponent (const Handle(Geom_Plane)& aComponent); Standard_EXPORT void SetComponent(const Handle(Geom_Plane)& aComponent);
//! 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; }
//! Provides settings for the center theCenter other than (0, 0, 0). //! Provides settings for the center theCenter other than (0, 0, 0).
void SetCenter (const gp_Pnt& theCenter) { myCenter = theCenter; } void SetCenter(const gp_Pnt& theCenter) { myCenter = theCenter; }
//! Allows you to provide settings for the position and //! Allows you to provide settings for the position and
//! direction of one of the plane's axes, aComponent, in //! direction of one of the plane's axes, aComponent, in
@ -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
@ -126,31 +144,36 @@ public:
//! Allows you to provide settings for a non-default //! Allows you to provide settings for a non-default
//! current display mode. //! current display mode.
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;
Standard_EXPORT void ComputeFrame(); Standard_EXPORT void ComputeFrame();
@ -159,19 +182,17 @@ 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;
gp_Pnt myPmin; gp_Pnt myPmin;
gp_Pnt myPmax; gp_Pnt myPmax;
Standard_Boolean myCurrentMode; Standard_Boolean myCurrentMode;
Standard_Boolean myAutomaticPosition; Standard_Boolean myAutomaticPosition;
AIS_TypeOfPlane myTypeOfPlane; AIS_TypeOfPlane myTypeOfPlane;
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

@ -45,22 +45,22 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <UnitsAPI.hxx> #include <UnitsAPI.hxx>
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)
{ {
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); Handle(Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
//POP Standard_Real aLength = UnitsAPI::CurrentFromLS (100. ,"LENGTH"); // POP Standard_Real aLength = UnitsAPI::CurrentFromLS (100. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS (100. ,"mm"); Standard_Real aLength = UnitsAPI::AnyToLS(100., "mm");
DA->SetAxisLength(aLength,aLength,aLength); DA->SetAxisLength(aLength, aLength, aLength);
Quantity_Color col (Quantity_NOC_ROYALBLUE1); Quantity_Color col(Quantity_NOC_ROYALBLUE1);
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
DA->SetDrawDatumAxes(Prs3d_DatumAxes_XYAxes); DA->SetDrawDatumAxes(Prs3d_DatumAxes_XYAxes);
@ -69,165 +69,154 @@ AIS_PlaneTrihedron::AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane)
myShapes[1] = XAxis(); myShapes[1] = XAxis();
myShapes[2] = YAxis(); myShapes[2] = YAxis();
myXLabel = TCollection_AsciiString( "X" ); myXLabel = TCollection_AsciiString("X");
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;
} }
//=================================================================================================
//======================================================================= void AIS_PlaneTrihedron::SetComponent(const Handle(Geom_Plane)& aPlane)
//function : SetComponent
//purpose :
//=======================================================================
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());
Handle(AIS_Line) aLine = new AIS_Line (aGLine); Handle(AIS_Line) aLine = new AIS_Line(aGLine);
aLine->SetColor(Quantity_NOC_ROYALBLUE1); aLine->SetColor(Quantity_NOC_ROYALBLUE1);
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());
Handle(AIS_Line) aLine = new AIS_Line (aGLine); Handle(AIS_Line) aLine = new AIS_Line(aGLine);
aLine->SetColor(Quantity_NOC_ROYALBLUE1); aLine->SetColor(Quantity_NOC_ROYALBLUE1);
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();
Handle(Geom_Point) aPoint = new Geom_CartesianPoint(aPnt); Handle(Geom_Point) aPoint = new Geom_CartesianPoint(aPnt);
Handle(AIS_Point) aPt = new AIS_Point (aPoint); Handle(AIS_Point) aPt = new AIS_Point(aPoint);
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)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_PlaneTrihedron::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer )
{ {
// drawing axis in X direction // drawing axis in X direction
gp_Pnt first, last; gp_Pnt first, last;
Standard_Real value = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis); Standard_Real value = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
gp_Dir xDir = myPlane->Position().Ax2().XDirection(); gp_Dir xDir = myPlane->Position().Ax2().XDirection();
gp_Pnt orig = myPlane->Position().Ax2().Location(); gp_Pnt orig = myPlane->Position().Ax2().Location();
Standard_Real xo,yo,zo,x,y,z; Standard_Real xo, yo, zo, x, y, z;
orig.Coord( xo, yo, zo ); orig.Coord(xo, yo, zo);
xDir.Coord( x, y, z ); xDir.Coord(x, y, z);
first.SetCoord( xo, yo, zo ); first.SetCoord(xo, yo, zo);
last.SetCoord( xo + x * value, yo + y * value, zo + z * value ); last.SetCoord(xo + x * value, yo + y * value, zo + z * value);
DsgPrs_XYZAxisPresentation::Add (thePrs, DsgPrs_XYZAxisPresentation::Add(thePrs,
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);
gp_Dir yDir = myPlane->Position().Ax2().YDirection(); gp_Dir yDir = myPlane->Position().Ax2().YDirection();
yDir.Coord( x, y, z ); yDir.Coord(x, y, z);
last.SetCoord( xo + x * value, yo + y * value, zo + z * value ); last.SetCoord(xo + x * value, yo + y * value, zo + z * value);
DsgPrs_XYZAxisPresentation::Add (thePrs, DsgPrs_XYZAxisPresentation::Add(thePrs,
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)
{ {
Standard_Integer Prior; Standard_Integer Prior;
Handle(SelectMgr_EntityOwner) eown; Handle(SelectMgr_EntityOwner) eown;
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();
eown = new SelectMgr_EntityOwner(this,Prior); eown = new SelectMgr_EntityOwner(this, Prior);
for (Standard_Integer i=1; i<=2;i++) for (Standard_Integer i = 1; i <= 2; i++)
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: { // 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);
aSelection->Add(new Select3D_SensitivePoint(eown,myPlane->Location())); aSelection->Add(new Select3D_SensitivePoint(eown, myPlane->Location()));
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;
@ -235,28 +224,30 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
} }
} }
void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol) void AIS_PlaneTrihedron::SetColor(const Quantity_Color& aCol)
{ {
hasOwnColor=Standard_True; hasOwnColor = Standard_True;
myDrawer->SetColor (aCol); myDrawer->SetColor(aCol);
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol); myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol);
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol); myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=======================================================================
//function : ExtremityPoints // function : ExtremityPoints
//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());
PP(1) = theax.Location(); PP(1) = theax.Location();
Standard_Real len = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis); Standard_Real len = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
gp_Vec vec = theax.XDirection(); gp_Vec vec = theax.XDirection();
vec *= len; vec *= len;
PP(2) = PP(1).Translated(vec); PP(2) = PP(1).Translated(vec);
@ -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);
@ -54,7 +53,7 @@ public:
Standard_EXPORT Handle(Geom_Plane) Component(); Standard_EXPORT Handle(Geom_Plane) Component();
//! Creates an instance of the component object aPlane. //! Creates an instance of the component object aPlane.
Standard_EXPORT void SetComponent (const Handle(Geom_Plane)& aPlane); Standard_EXPORT void SetComponent(const Handle(Geom_Plane)& aPlane);
//! Returns the "XAxis". //! Returns the "XAxis".
Standard_EXPORT Handle(AIS_Line) XAxis() const; Standard_EXPORT Handle(AIS_Line) XAxis() const;
@ -66,44 +65,44 @@ public:
Standard_EXPORT Handle(AIS_Point) Position() const; Standard_EXPORT Handle(AIS_Point) Position() const;
//! Sets the length of the X and Y axes. //! Sets the length of the X and Y axes.
Standard_EXPORT void SetLength (const Standard_Real theLength); Standard_EXPORT void SetLength(const Standard_Real theLength);
//! Returns the length of X and Y axes. //! Returns the length of X and Y axes.
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;
void SetXLabel (const TCollection_AsciiString& theLabel) { myXLabel = theLabel; } void SetXLabel(const TCollection_AsciiString& theLabel) { myXLabel = theLabel; }
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

@ -30,190 +30,156 @@
#include <StdPrs_Point.hxx> #include <StdPrs_Point.hxx>
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
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): myHasTOM(Standard_False),
myComponent(aComponent), myTOM(Aspect_TOM_PLUS)
myHasTOM(Standard_False),
myTOM(Aspect_TOM_PLUS)
{ {
myHilightDrawer = new Prs3d_Drawer(); myHilightDrawer = new Prs3d_Drawer();
myHilightDrawer->SetDisplayMode (-99); myHilightDrawer->SetDisplayMode(-99);
myHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0)); myHilightDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0));
myHilightDrawer->SetColor (Quantity_NOC_GRAY80); myHilightDrawer->SetColor(Quantity_NOC_GRAY80);
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(
myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1); new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Top); myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1);
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)
{ {
thePrs->SetInfiniteState (myInfiniteState); thePrs->SetInfiniteState(myInfiniteState);
if (theMode == 0) if (theMode == 0)
{ {
StdPrs_Point::Add (thePrs, myComponent, myDrawer); StdPrs_Point::Add(thePrs, myComponent, myDrawer);
} }
else if (theMode == -99) else if (theMode == -99)
{ {
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup(); Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
aGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect()); aGroup->SetPrimitivesAspect(myHilightDrawer->PointAspect()->Aspect());
Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1); Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints(1);
aPoint->AddVertex (myComponent->X(), myComponent->Y(), myComponent->Z()); aPoint->AddVertex(myComponent->X(), myComponent->Y(), myComponent->Z());
aGroup->AddPrimitiveArray (aPoint); aGroup->AddPrimitiveArray(aPoint);
} }
} }
//======================================================================= //=================================================================================================
//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;
myDrawer->SetColor (theCol); myDrawer->SetColor(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)
{ {
myTOM = aTOM; myTOM = aTOM;
myHasTOM = Standard_True; myHasTOM = Standard_True;
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())
{ {
myDrawer->SetPointAspect (theAspect); myDrawer->SetPointAspect(theAspect);
return; return;
} }
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);
Graphic3d_MapOfAspectsToAspects aReplaceMap; Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew); aReplaceMap.Bind(anAspectOld, anAspectNew);
replaceAspects (aReplaceMap); replaceAspects(aReplaceMap);
} }
} }
//======================================================================= //=================================================================================================
//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;
} }
Quantity_Color aCol (Quantity_NOC_YELLOW); Quantity_Color aCol(Quantity_NOC_YELLOW);
Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS; Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
Standard_Real aScale = 1.0; Standard_Real aScale = 1.0;
if (myDrawer->HasLink()) if (myDrawer->HasLink())
{ {
@ -222,13 +188,16 @@ 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())
{ {
Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect(); Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
PA->SetColor(aCol); PA->SetColor(aCol);
PA->SetTypeOfMarker(aTOM); PA->SetTypeOfMarker(aTOM);
PA->SetScale(aScale); PA->SetScale(aScale);
@ -236,7 +205,6 @@ void AIS_Point::UpdatePointValues()
} }
else else
{ {
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,19 +36,23 @@ 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();
//! Constructs an instance of the point aComponent. //! Constructs an instance of the point aComponent.
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;
//! Allows you to remove color settings. //! Allows you to remove color settings.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
@ -58,7 +61,7 @@ public:
//! - type of marker, //! - type of marker,
//! - marker color, //! - marker color,
//! - scale factor. //! - scale factor.
Standard_EXPORT void SetMarker (const Aspect_TypeOfMarker aType); Standard_EXPORT void SetMarker(const Aspect_TypeOfMarker aType);
//! Removes the marker settings. //! Removes the marker settings.
Standard_EXPORT void UnsetMarker(); Standard_EXPORT void UnsetMarker();
@ -70,26 +73,23 @@ 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();
//! Replace aspects of already computed groups with the new value. //! Replace aspects of already computed groups with the new value.
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,74 +31,71 @@
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)
//======================================================================= : SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)theOrigin, 5),
AIS_PointCloudOwner::AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin) myDetPoints(new TColStd_HPackedMapOfInteger()),
: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theOrigin, 5), mySelPoints(new TColStd_HPackedMapOfInteger())
myDetPoints (new TColStd_HPackedMapOfInteger()),
mySelPoints (new TColStd_HPackedMapOfInteger())
{ {
// //
} }
//======================================================================= //=================================================================================================
//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,
//======================================================================= const Handle(Prs3d_Drawer)& theStyle,
void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer)
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer )
{ {
Handle(AIS_PointCloud) anObj = Handle(AIS_PointCloud)::DownCast (Selectable()); Handle(AIS_PointCloud) anObj = Handle(AIS_PointCloud)::DownCast(Selectable());
if (anObj.IsNull()) if (anObj.IsNull())
{ {
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() theStyle->ZLayer() != -1
: (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer()); ? theStyle->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)
{ {
aMap->ChangeMap().Add (aSensitive->LastDetectedElement()); aMap->ChangeMap().Add(aSensitive->LastDetectedElement());
} }
break; break;
} }
@ -109,7 +106,7 @@ void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
aPrs->Clear(); aPrs->Clear();
if (aPrs->GetZLayer() != aZLayer) if (aPrs->GetZLayer() != aZLayer)
{ {
aPrs->SetZLayer (aZLayer); aPrs->SetZLayer(aZLayer);
} }
if (aMap->Map().IsEmpty()) if (aMap->Map().IsEmpty())
{ {
@ -122,19 +119,19 @@ void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
return; return;
} }
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (aMap->Map().Extent()); Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints(aMap->Map().Extent());
for (TColStd_PackedMapOfInteger::Iterator aPntIter (aMap->Map()); aPntIter.More(); aPntIter.Next()) for (TColStd_PackedMapOfInteger::Iterator aPntIter(aMap->Map()); aPntIter.More(); aPntIter.Next())
{ {
const gp_Pnt aPnt = anAllPoints->Vertice (aPntIter.Key() + 1); const gp_Pnt aPnt = anAllPoints->Vertice(aPntIter.Key() + 1);
aPoints->AddVertex (aPnt); aPoints->AddVertex(aPnt);
} }
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup(); Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect(theStyle->PointAspect()->Aspect());
aGroup->AddPrimitiveArray (aPoints); aGroup->AddPrimitiveArray(aPoints);
if (thePrsMgr->IsImmediateModeOn()) if (thePrsMgr->IsImmediateModeOn())
{ {
thePrsMgr->AddToImmediateList (aPrs); thePrsMgr->AddToImmediateList(aPrs);
} }
else else
{ {
@ -142,62 +139,56 @@ 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();
myDrawer->ShadingAspect()->Aspect()->SetMarkerType (Aspect_TOM_POINT); myDrawer->ShadingAspect()->Aspect()->SetMarkerType(Aspect_TOM_POINT);
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;
} }
//! Auxiliary method //! Auxiliary method
static inline Bnd_Box getBoundingBox (const Handle(Graphic3d_ArrayOfPoints)& thePoints) static inline Bnd_Box getBoundingBox(const Handle(Graphic3d_ArrayOfPoints)& thePoints)
{ {
Bnd_Box aBndBox; Bnd_Box aBndBox;
if (thePoints.IsNull()) if (thePoints.IsNull())
@ -208,28 +199,24 @@ static inline Bnd_Box getBoundingBox (const Handle(Graphic3d_ArrayOfPoints)& the
const Standard_Integer aNbVertices = thePoints->VertexNumber(); const Standard_Integer aNbVertices = thePoints->VertexNumber();
for (Standard_Integer aVertIter = 1; aVertIter <= aNbVertices; ++aVertIter) for (Standard_Integer aVertIter = 1; aVertIter <= aNbVertices; ++aVertIter)
{ {
aBndBox.Add (thePoints->Vertice (aVertIter)); aBndBox.Add(thePoints->Vertice(aVertIter));
} }
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,
//======================================================================= const Handle(Quantity_HArray1OfColor)& theColors,
void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords, const Handle(TColgp_HArray1OfDir)& theNormals)
const Handle(Quantity_HArray1OfColor)& theColors,
const Handle(TColgp_HArray1OfDir)& theNormals)
{ {
myPoints.Nullify(); myPoints.Nullify();
myBndBox.SetVoid(); myBndBox.SetVoid();
@ -240,52 +227,47 @@ void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords
const Standard_Integer aNbPoints = theCoords->Length(); const Standard_Integer aNbPoints = theCoords->Length();
if ((!theNormals.IsNull() && theNormals->Length() != aNbPoints) if ((!theNormals.IsNull() && theNormals->Length() != aNbPoints)
|| (!theColors.IsNull() && theColors->Length() != aNbPoints)) || (!theColors.IsNull() && theColors->Length() != aNbPoints))
{ {
// invalid input // invalid input
return; return;
} }
const Standard_Boolean hasColors = !theColors.IsNull() && theColors->Length() == aNbPoints; const Standard_Boolean hasColors = !theColors.IsNull() && theColors->Length() == aNbPoints;
const Standard_Boolean hasNormals = !theNormals.IsNull() && theNormals->Length() == aNbPoints; const Standard_Boolean hasNormals = !theNormals.IsNull() && theNormals->Length() == aNbPoints;
const Standard_Integer aDiffColors = hasColors ? (theColors->Lower() - theCoords->Lower()) : 0; const Standard_Integer aDiffColors = hasColors ? (theColors->Lower() - theCoords->Lower()) : 0;
const Standard_Integer aDiffNormals = hasNormals ? (theNormals->Lower() - theCoords->Lower()) : 0; const Standard_Integer aDiffNormals = hasNormals ? (theNormals->Lower() - theCoords->Lower()) : 0;
myPoints = new Graphic3d_ArrayOfPoints (aNbPoints, hasColors, hasNormals); myPoints = new Graphic3d_ArrayOfPoints(aNbPoints, hasColors, hasNormals);
for (Standard_Integer aPntIter = theCoords->Lower(); aPntIter <= theCoords->Upper(); ++aPntIter) for (Standard_Integer aPntIter = theCoords->Lower(); aPntIter <= theCoords->Upper(); ++aPntIter)
{ {
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)
{ {
myPoints->SetVertexNormal (myPoints->VertexNumber(), myPoints->SetVertexNormal(myPoints->VertexNumber(),
theNormals->Value (aPntIter + aDiffNormals)); theNormals->Value(aPntIter + aDiffNormals));
} }
} }
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);
myDrawer->ShadingAspect()->SetColor (theColor); myDrawer->ShadingAspect()->SetColor(theColor);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_PointCloud::UnsetColor() void AIS_PointCloud::UnsetColor()
{ {
if (!HasColor()) if (!HasColor())
@ -295,54 +277,50 @@ void AIS_PointCloud::UnsetColor()
AIS_InteractiveObject::UnsetColor(); AIS_InteractiveObject::UnsetColor();
{ {
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NameOfMaterial_Brass); Graphic3d_MaterialAspect aDefaultMat(Graphic3d_NameOfMaterial_Brass);
Graphic3d_MaterialAspect aMat = aDefaultMat; Graphic3d_MaterialAspect aMat = aDefaultMat;
Quantity_Color aColor = aDefaultMat.Color(); Quantity_Color aColor = aDefaultMat.Color();
if (myDrawer->HasLink()) if (myDrawer->HasLink())
{ {
aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel); aColor = myDrawer->Link()->ShadingAspect()->Color(myCurrentFacingModel);
} }
if (HasMaterial() || myDrawer->HasLink()) if (HasMaterial() || myDrawer->HasLink())
{ {
aMat = AIS_GraphicTool::GetMaterial (HasMaterial() ? myDrawer : myDrawer->Link()); aMat = AIS_GraphicTool::GetMaterial(HasMaterial() ? myDrawer : myDrawer->Link());
} }
if (HasMaterial()) if (HasMaterial())
{ {
aMat.SetColor (aColor); aMat.SetColor(aColor);
} }
if (IsTransparent()) if (IsTransparent())
{ {
Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel); Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
aMat.SetTransparency (Standard_ShortReal(aTransp)); aMat.SetTransparency(Standard_ShortReal(aTransp));
} }
myDrawer->ShadingAspect()->SetMaterial (aMat, myCurrentFacingModel); myDrawer->ShadingAspect()->SetMaterial(aMat, myCurrentFacingModel);
myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor); myDrawer->ShadingAspect()->Aspect()->SetInteriorColor(aColor);
} }
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;
myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel); myDrawer->ShadingAspect()->SetMaterial(theMat, myCurrentFacingModel);
if (HasColor()) if (HasColor())
{ {
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel); myDrawer->ShadingAspect()->SetColor(myDrawer->Color(), myCurrentFacingModel);
} }
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel); myDrawer->ShadingAspect()->SetTransparency(myDrawer->Transparency(), myCurrentFacingModel);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
void AIS_PointCloud::UnsetMaterial() void AIS_PointCloud::UnsetMaterial()
{ {
if (!HasMaterial()) if (!HasMaterial())
@ -351,33 +329,30 @@ 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())
{ {
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel); myDrawer->ShadingAspect()->SetColor(myDrawer->Color(), myCurrentFacingModel);
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel); myDrawer->ShadingAspect()->SetTransparency(myDrawer->Transparency(), myCurrentFacingModel);
} }
} }
hasOwnMaterial = Standard_False; hasOwnMaterial = Standard_False;
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_PointCloud::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
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())
{ {
@ -385,65 +360,63 @@ void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager)& ,
} }
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
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())
{ {
return; return;
} }
Prs3d_BndBox::Add (thePrs, aBndBox, myDrawer); Prs3d_BndBox::Add(thePrs, aBndBox, myDrawer);
break; break;
} }
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_PointCloud::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
//======================================================================= const Standard_Integer theMode)
void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
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 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)
{ {
anOwner = new AIS_PointCloudOwner (this); anOwner = new AIS_PointCloudOwner(this);
} }
// 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 =
aSensitive->SetDetectElements (true); new Select3D_SensitivePrimitiveArray(anOwner);
aSensitive->SetDetectElementMap (theMode == SM_SubsetOfPoints); aSensitive->SetDetectElements(true);
aSensitive->SetSensitivityFactor (8); aSensitive->SetDetectElementMap(theMode == SM_SubsetOfPoints);
aSensitive->InitPoints (aPoints->Attributes(), aPoints->Indices(), TopLoc_Location(), true, aNbGroups); aSensitive->SetSensitivityFactor(8);
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;
} }
} }
@ -453,6 +426,6 @@ void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSel
{ {
return; return;
} }
Handle(Select3D_SensitiveBox) aSensBox = new Select3D_SensitiveBox (anOwner, aBndBox); Handle(Select3D_SensitiveBox) aSensBox = new Select3D_SensitiveBox(anOwner, aBndBox);
theSelection->Add (aSensBox); theSelection->Add(aSensBox);
} }

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,14 +58,13 @@ public:
}; };
public: public:
//! Constructor. //! Constructor.
Standard_EXPORT AIS_PointCloud(); Standard_EXPORT AIS_PointCloud();
//! Sets the points from array of points. //! Sets the points from array of points.
//! Method will not copy the input data - array will be stored as handle. //! Method will not copy the input data - array will be stored as handle.
//! @param[in] thePoints the array of points //! @param[in] thePoints the array of points
Standard_EXPORT virtual void SetPoints (const Handle(Graphic3d_ArrayOfPoints)& thePoints); Standard_EXPORT virtual void SetPoints(const Handle(Graphic3d_ArrayOfPoints)& thePoints);
//! Sets the points with optional colors. //! Sets the points with optional colors.
//! The input data will be copied into internal buffer. //! The input data will be copied into internal buffer.
@ -75,14 +73,14 @@ public:
//! @param[in] theCoords the array of coordinates //! @param[in] theCoords the array of coordinates
//! @param[in] theColors optional array of colors //! @param[in] theColors optional array of colors
//! @param[in] theNormals optional array of normals //! @param[in] theNormals optional array of normals
Standard_EXPORT virtual void SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords, Standard_EXPORT virtual void SetPoints(const Handle(TColgp_HArray1OfPnt)& theCoords,
const Handle(Quantity_HArray1OfColor)& theColors = NULL, const Handle(Quantity_HArray1OfColor)& theColors = NULL,
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,35 +88,33 @@ 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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Prepare selection for this object. //! Prepare selection for this object.
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;
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)
@ -129,32 +125,37 @@ class AIS_PointCloudOwner : public SelectMgr_EntityOwner
DEFINE_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner) DEFINE_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
public: public:
//! Main constructor. //! Main constructor.
Standard_EXPORT AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin); Standard_EXPORT AIS_PointCloudOwner(const Handle(AIS_PointCloud)& theOrigin);
//! Destructor. //! Destructor.
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.
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
//! Handle dynamic highlighting. //! Handle dynamic highlighting.
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;
//! 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,82 +26,74 @@
#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)
{ {
myDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0)); myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NameOfMaterial_Plastified); myDrawer->ShadingAspect()->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TypeOfShadingModel_Unlit); myDrawer->ShadingAspect()->Aspect()->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_EMPTY); myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle(Aspect_IS_EMPTY);
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend); myDrawer->ShadingAspect()->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_Blend);
myDrawer->ShadingAspect()->SetTransparency (1.0); myDrawer->ShadingAspect()->SetTransparency(1.0);
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE); myDrawer->ShadingAspect()->SetColor(Quantity_NOC_WHITE);
SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER)); SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer (Graphic3d_ZLayerId_TopOSD); SetZLayer(Graphic3d_ZLayerId_TopOSD);
} }
//======================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType,
const Standard_Real theWidth,
const Standard_Boolean theIsPolygonClosed)
: myIsPolygonClosed(theIsPolygonClosed)
{
myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theWidth));
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NameOfMaterial_Plastified);
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TypeOfShadingModel_Unlit);
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_EMPTY);
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
myDrawer->ShadingAspect()->SetTransparency (1.0);
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER)); AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor,
SetZLayer (Graphic3d_ZLayerId_TopOSD); const Aspect_TypeOfLine theLineType,
const Standard_Real theWidth,
const Standard_Boolean theIsPolygonClosed)
: myIsPolygonClosed(theIsPolygonClosed)
{
myDrawer->SetLineAspect(new Prs3d_LineAspect(theLineColor, theLineType, theWidth));
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
myDrawer->ShadingAspect()->Aspect()->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle(Aspect_IS_EMPTY);
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_Blend);
myDrawer->ShadingAspect()->SetTransparency(1.0);
myDrawer->ShadingAspect()->SetColor(Quantity_NOC_WHITE);
SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer(Graphic3d_ZLayerId_TopOSD);
} }
//======================================================================= //=================================================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType,
const Quantity_Color theFillColor,
const Standard_Real theTransparency,
const Standard_Real theLineWidth,
const Standard_Boolean theIsPolygonClosed)
: myIsPolygonClosed (theIsPolygonClosed)
{
myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theLineWidth));
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NameOfMaterial_Plastified);
myDrawer->ShadingAspect()->SetColor (theFillColor);
myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TypeOfShadingModel_Unlit);
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
myDrawer->ShadingAspect()->SetTransparency (theTransparency);
SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER)); AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor,
SetZLayer (Graphic3d_ZLayerId_TopOSD); const Aspect_TypeOfLine theLineType,
const Quantity_Color theFillColor,
const Standard_Real theTransparency,
const Standard_Real theLineWidth,
const Standard_Boolean theIsPolygonClosed)
: myIsPolygonClosed(theIsPolygonClosed)
{
myDrawer->SetLineAspect(new Prs3d_LineAspect(theLineColor, theLineType, theLineWidth));
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
myDrawer->ShadingAspect()->SetColor(theFillColor);
myDrawer->ShadingAspect()->Aspect()->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle(Aspect_IS_SOLID);
myDrawer->ShadingAspect()->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_Blend);
myDrawer->ShadingAspect()->SetTransparency(theTransparency);
SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer(Graphic3d_ZLayerId_TopOSD);
} }
//======================================================================= //=================================================================================================
//function : Destructor
//purpose :
//=======================================================================
AIS_RubberBand::~AIS_RubberBand() AIS_RubberBand::~AIS_RubberBand()
{ {
myPoints.Clear(); myPoints.Clear();
@ -109,254 +101,214 @@ 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));
myPoints.Append (Graphic3d_Vec2i (theMinX, theMaxY)); myPoints.Append(Graphic3d_Vec2i(theMinX, theMaxY));
myPoints.Append (Graphic3d_Vec2i (theMaxX, theMaxY)); myPoints.Append(Graphic3d_Vec2i(theMaxX, theMaxY));
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);
SetFillTransparency (theTransparency); SetFillTransparency(theTransparency);
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 =
Standard_Integer aPtsLower = myPoints.Lower(); new BRepMesh_DataStructureOfDelaun(anAllocator);
Standard_Integer aPtsUpper = myPoints.Upper(); Standard_Integer aPtsLower = myPoints.Lower();
IMeshData::VectorOfInteger anIndexes (myPoints.Length(), anAllocator); Standard_Integer aPtsUpper = myPoints.Upper();
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));
} }
Standard_Real aPtSum = 0; Standard_Real aPtSum = 0;
for (Standard_Integer aIdx = aPtsLower; aIdx <= aPtsUpper; ++aIdx) for (Standard_Integer aIdx = aPtsLower; aIdx <= aPtsUpper; ++aIdx)
{ {
Standard_Integer aNextIdx = (aIdx % myPoints.Length()) + 1; Standard_Integer aNextIdx = (aIdx % myPoints.Length()) + 1;
aPtSum += (Standard_Real)(myPoints.Value (aNextIdx).x() - myPoints.Value (aIdx).x()) aPtSum += (Standard_Real)(myPoints.Value(aNextIdx).x() - myPoints.Value(aIdx).x())
* (Standard_Real)(myPoints.Value (aNextIdx).y() + myPoints.Value (aIdx).y()); * (Standard_Real)(myPoints.Value(aNextIdx).y() + myPoints.Value(aIdx).y());
} }
Standard_Boolean isClockwiseOrdered = aPtSum < 0; Standard_Boolean isClockwiseOrdered = aPtSum < 0;
for (Standard_Integer aIdx = 0; aIdx < anIndexes.Length(); ++aIdx) for (Standard_Integer aIdx = 0; aIdx < anIndexes.Length(); ++aIdx)
{ {
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), aMeshStructure->AddLink(anEdge);
BRepMesh_Frontier);
aMeshStructure->AddLink (anEdge);
} }
BRepMesh_Delaun aTriangulation (aMeshStructure, anIndexes); BRepMesh_Delaun aTriangulation(aMeshStructure, anIndexes);
const IMeshData::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain(); const IMeshData::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain();
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)
{ {
toFill = Standard_True; toFill = Standard_True;
myTriangles = new Graphic3d_ArrayOfTriangles (aTriangles.Extent() * 3, 0, Standard_True); myTriangles = new Graphic3d_ArrayOfTriangles(aTriangles.Extent() * 3, 0, Standard_True);
} }
Standard_Integer aVertexIndex = 1; Standard_Integer aVertexIndex = 1;
IMeshData::IteratorOfMapOfInteger aTriangleIt (aTriangles); IMeshData::IteratorOfMapOfInteger aTriangleIt(aTriangles);
for (; aTriangleIt.More(); aTriangleIt.Next()) for (; aTriangleIt.More(); aTriangleIt.Next())
{ {
const Standard_Integer aTriangleId = aTriangleIt.Key(); const Standard_Integer aTriangleId = aTriangleIt.Key();
const BRepMesh_Triangle& aCurrentTriangle = aMeshStructure->GetElement (aTriangleId); const BRepMesh_Triangle& aCurrentTriangle = aMeshStructure->GetElement(aTriangleId);
if (aCurrentTriangle.Movability() == BRepMesh_Deleted) if (aCurrentTriangle.Movability() == BRepMesh_Deleted)
continue; continue;
Standard_Integer aTriangleVerts[3]; Standard_Integer aTriangleVerts[3];
aMeshStructure->ElementNodes (aCurrentTriangle, aTriangleVerts); aMeshStructure->ElementNodes(aCurrentTriangle, aTriangleVerts);
gp_Pnt2d aPts[3]; gp_Pnt2d aPts[3];
for (Standard_Integer aVertIdx = 0; aVertIdx < 3; ++aVertIdx) for (Standard_Integer aVertIdx = 0; aVertIdx < 3; ++aVertIdx)
{ {
const BRepMesh_Vertex& aVertex = aMeshStructure->GetNode (aTriangleVerts[aVertIdx]); const BRepMesh_Vertex& aVertex = aMeshStructure->GetNode(aTriangleVerts[aVertIdx]);
aPts[aVertIdx] = aVertex.Coord(); aPts[aVertIdx] = aVertex.Coord();
} }
if (toFill) if (toFill)
@ -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,13 +338,11 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
return Standard_True; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_RubberBand::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePresentation,
void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{ {
if (theMode != 0) if (theMode != 0)
{ {
@ -400,43 +353,49 @@ void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager)& ,
if (IsFilling() && fillTriangles()) if (IsFilling() && fillTriangles())
{ {
Handle(Graphic3d_Group) aGroup1 = thePresentation->NewGroup(); Handle(Graphic3d_Group) aGroup1 = thePresentation->NewGroup();
aGroup1->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); aGroup1->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
aGroup1->AddPrimitiveArray (myTriangles); aGroup1->AddPrimitiveArray(myTriangles);
} }
// 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)
{
myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(),
(Standard_Real)myPoints.Value(1).y(), 0.0);
}
if (myIsPolygonClosed)
{
myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(),
(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);
} }
} }
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup(); Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders); aGroup->AddPrimitiveArray(myBorders);
} }

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.
@ -45,34 +44,37 @@ public:
//! @param[in] theType type of rubber band lines //! @param[in] theType type of rubber band lines
//! @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,
const Aspect_TypeOfLine theType, const Aspect_TypeOfLine theType,
const Standard_Real theLineWidth = 1.0, const Standard_Real theLineWidth = 1.0,
const Standard_Boolean theIsPolygonClosed = Standard_True); const Standard_Boolean theIsPolygonClosed = Standard_True);
//! Constructs the rubber band with defined filling and line parameters. //! Constructs the rubber band with defined filling and line parameters.
//! @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,
const Aspect_TypeOfLine theType, const Aspect_TypeOfLine theType,
const Quantity_Color theFillColor, const Quantity_Color theFillColor,
const Standard_Real theTransparency = 1.0, const Standard_Real theTransparency = 1.0,
const Standard_Real theLineWidth = 1.0, const Standard_Real theLineWidth = 1.0,
const Standard_Boolean theIsPolygonClosed = Standard_True); const Standard_Boolean theIsPolygonClosed = Standard_True);
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()
Standard_EXPORT void AddPoint (const Graphic3d_Vec2i& thePoint); Standard_EXPORT void AddPoint(const Graphic3d_Vec2i& thePoint);
//! Remove last point from the list of points for the rubber band polygon. //! Remove last point from the list of points for the rubber band polygon.
//! @sa AddPoint(), GetPoints() //! @sa AddPoint(), GetPoints()
@ -88,40 +90,41 @@ public:
Standard_EXPORT Quantity_Color LineColor() const; Standard_EXPORT Quantity_Color LineColor() const;
//! Sets color of lines for rubber band presentation. //! Sets color of lines for rubber band presentation.
Standard_EXPORT void SetLineColor (const Quantity_Color& theColor); Standard_EXPORT void SetLineColor(const Quantity_Color& theColor);
//! @return the color of rubber band filling. //! @return the color of rubber band filling.
Standard_EXPORT Quantity_Color FillColor() const; Standard_EXPORT Quantity_Color FillColor() const;
//! Sets color of rubber band filling. //! Sets color of rubber band filling.
Standard_EXPORT void SetFillColor (const Quantity_Color& theColor); Standard_EXPORT void SetFillColor(const Quantity_Color& theColor);
//! Sets width of line for rubber band presentation. //! Sets width of line for rubber band presentation.
Standard_EXPORT void SetLineWidth (const Standard_Real theWidth) const; Standard_EXPORT void SetLineWidth(const Standard_Real theWidth) const;
//! @return width of lines. //! @return width of lines.
Standard_EXPORT Standard_Real LineWidth() const; Standard_EXPORT Standard_Real LineWidth() const;
//! Sets type of line for rubber band presentation. //! Sets type of line for rubber band presentation.
Standard_EXPORT void SetLineType (const Aspect_TypeOfLine theType); Standard_EXPORT void SetLineType(const Aspect_TypeOfLine theType);
//! @return type of lines. //! @return type of lines.
Standard_EXPORT Aspect_TypeOfLine LineType() const; Standard_EXPORT Aspect_TypeOfLine LineType() const;
//! Sets fill transparency. //! Sets fill transparency.
//! @param[in] theValue the transparency value. 1.0 is for transparent background //! @param[in] theValue the transparency value. 1.0 is for transparent background
Standard_EXPORT void SetFillTransparency (const Standard_Real theValue) const; Standard_EXPORT void SetFillTransparency(const Standard_Real theValue) const;
//! @return fill transparency. //! @return fill transparency.
Standard_EXPORT Standard_Real FillTransparency() const; Standard_EXPORT Standard_Real FillTransparency() const;
//! Enable or disable filling of rubber band. //! Enable or disable filling of rubber band.
Standard_EXPORT void SetFilling (const Standard_Boolean theIsFilling); Standard_EXPORT void SetFilling(const Standard_Boolean theIsFilling);
//! 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,21 +137,20 @@ 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
{ {
return theMode == 0; return theMode == 0;
} }
//! Computes presentation of rubber band. //! Computes presentation of rubber band.
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;
//! Does not fill selection primitives for rubber band. //! Does not fill selection primitives for rubber band.
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 {};
//! Fills triangles primitive array for rubber band filling. //! Fills triangles primitive array for rubber band filling.
//! It uses Delaunay triangulation. //! It uses Delaunay triangulation.
@ -156,12 +158,11 @@ 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
Handle(Graphic3d_ArrayOfPolylines) myBorders; //!< Polylines for rubber band borders Handle(Graphic3d_ArrayOfPolylines) myBorders; //!< Polylines for rubber band borders
Standard_Boolean myIsPolygonClosed; //!< automatic closing of rubber-band flag Standard_Boolean myIsPolygonClosed; //!< automatic closing of rubber-band flag
}; };
#endif #endif

View File

@ -17,12 +17,11 @@
#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,
AIS_SS_Removed, AIS_SS_Removed,
AIS_SS_NotDone AIS_SS_NotDone
}; };
#endif // _AIS_SelectStatus_HeaderFile #endif // _AIS_SelectStatus_HeaderFile

View File

@ -22,62 +22,55 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
namespace 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())
{ {
const Handle(SelectMgr_EntityOwner) anObject = aSelIter.Value(); const Handle(SelectMgr_EntityOwner) anObject = aSelIter.Value();
anObject->SetSelected (Standard_False); anObject->SetSelected(Standard_False);
} }
myresult.Clear(); myresult.Clear();
myResultMap.Clear(); myResultMap.Clear();
myIterator = AIS_NListOfEntityOwner::Iterator(); myIterator = AIS_NListOfEntityOwner::Iterator();
} }
//======================================================================= //=================================================================================================
//function : Select
//purpose : AIS_SelectStatus AIS_Selection::Select(const Handle(SelectMgr_EntityOwner)& theOwner,
//======================================================================= const Handle(SelectMgr_Filter)& theFilter,
AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& theOwner, const AIS_SelectionScheme theSelScheme,
const Handle(SelectMgr_Filter)& theFilter, const Standard_Boolean theIsDetected)
const AIS_SelectionScheme theSelScheme,
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);
if (toSelect && !wasSelected) if (toSelect && !wasSelected)
{ {
AIS_NListOfEntityOwner::Iterator aListIter; AIS_NListOfEntityOwner::Iterator aListIter;
myresult.Append (theOwner, aListIter); myresult.Append(theOwner, aListIter);
myResultMap.Bind (theOwner, aListIter); myResultMap.Bind(theOwner, aListIter);
theOwner->SetSelected (Standard_True); theOwner->SetSelected(Standard_True);
return AIS_SS_Added; return AIS_SS_Added;
} }
@ -86,7 +79,7 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
return AIS_SS_NotDone; return AIS_SS_NotDone;
} }
AIS_NListOfEntityOwner::Iterator aListIter = myResultMap.Find (theOwner); AIS_NListOfEntityOwner::Iterator aListIter = myResultMap.Find(theOwner);
if (myIterator == aListIter) if (myIterator == aListIter)
{ {
if (myIterator.More()) if (myIterator.More())
@ -101,71 +94,66 @@ 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;
} }
myresult.Remove (aListIter); myresult.Remove(aListIter);
myResultMap.UnBind (theOwner); myResultMap.UnBind(theOwner);
theOwner->SetSelected (Standard_False); theOwner->SetSelected(Standard_False);
// update list iterator for next object in <myresult> list if any // update list iterator for next object in <myresult> list if any
if (aListIter.More()) if (aListIter.More())
{ {
const Handle(SelectMgr_EntityOwner)& aNextObject = aListIter.Value(); const Handle(SelectMgr_EntityOwner)& aNextObject = aListIter.Value();
if (myResultMap.IsBound (aNextObject)) if (myResultMap.IsBound(aNextObject))
{ {
myResultMap (aNextObject) = aListIter; myResultMap(aNextObject) = aListIter;
} }
else else
{ {
myResultMap.Bind (aNextObject, aListIter); myResultMap.Bind(aNextObject, aListIter);
} }
} }
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;
} }
AIS_NListOfEntityOwner::Iterator aListIter; AIS_NListOfEntityOwner::Iterator aListIter;
myresult.Append (theObject, aListIter); myresult.Append(theObject, aListIter);
myResultMap.Bind (theObject, aListIter); myResultMap.Bind(theObject, aListIter);
theObject->SetSelected (Standard_True); theObject->SetSelected(Standard_True);
return AIS_SS_Added; return AIS_SS_Added;
} }
//======================================================================= //=================================================================================================
//function : SelectOwners
//purpose : void AIS_Selection::SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners,
//======================================================================= const AIS_SelectionScheme theSelScheme,
void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners, const Standard_Boolean theToAllowSelOverlap,
const AIS_SelectionScheme theSelScheme, const Handle(SelectMgr_Filter)& theFilter)
const Standard_Boolean theToAllowSelOverlap,
const Handle(SelectMgr_Filter)& theFilter)
{ {
(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()))
{ {
isTheSame = Standard_False; isTheSame = Standard_False;
break; break;
@ -173,38 +161,35 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
} }
if (isTheSame) if (isTheSame)
{ {
Clear(); Clear();
return; return;
} }
} }
if (theSelScheme == AIS_SelectionScheme_Replace if (theSelScheme == AIS_SelectionScheme_Replace
|| theSelScheme == AIS_SelectionScheme_ReplaceExtra || theSelScheme == AIS_SelectionScheme_ReplaceExtra
|| theSelScheme == AIS_SelectionScheme_Clear) || theSelScheme == AIS_SelectionScheme_Clear)
{ {
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,
//======================================================================= const Handle(SelectMgr_Filter)& theFilter)
AIS_SelectStatus AIS_Selection::appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
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;
} }
return AddSelect (theOwner); return AddSelect(theOwner);
} }

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();
@ -45,29 +44,33 @@ public:
//! @param[in] theSelScheme selection scheme //! @param[in] theSelScheme selection scheme
//! @param[in] theIsDetected flag of object detection //! @param[in] theIsDetected flag of object detection
//! @return result of selection //! @return result of selection
Standard_EXPORT virtual AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theOwner, Standard_EXPORT virtual AIS_SelectStatus 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);
//! 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
//! @param[in] theFilter context filter //! @param[in] theFilter context filter
//! @param[in] theIsDetected flag of object detection //! @param[in] theIsDetected flag of object detection
virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject, virtual void ClearAndSelect(const Handle(SelectMgr_EntityOwner)& theObject,
const Handle(SelectMgr_Filter)& theFilter, const Handle(SelectMgr_Filter)& theFilter,
const Standard_Boolean theIsDetected) const Standard_Boolean theIsDetected)
{ {
Clear(); Clear();
Select (theObject, theFilter, AIS_SelectionScheme_Add, theIsDetected); Select(theObject, theFilter, AIS_SelectionScheme_Add, theIsDetected);
} }
//! 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); }
@ -97,26 +99,24 @@ public:
//! @param[in] theSelScheme selection scheme, defines how owner is selected //! @param[in] theSelScheme selection scheme, defines how owner is selected
//! @param[in] theToAllowSelOverlap selection flag, if true - overlapped entities are allowed //! @param[in] theToAllowSelOverlap selection flag, if true - overlapped entities are allowed
//! @param[in] theFilter context filter to skip not acceptable owners //! @param[in] theFilter context filter to skip not acceptable owners
Standard_EXPORT virtual void SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners, Standard_EXPORT virtual void SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners,
const AIS_SelectionScheme theSelScheme, const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theToAllowSelOverlap, const Standard_Boolean theToAllowSelOverlap,
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_Filter)& theFilter); const Handle(SelectMgr_EntityOwner)& theOwner,
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,12 +14,17 @@
#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_Multiple, //!< any combination of selection modes can be activated 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
}; };
#endif // _AIS_SelectionModesConcurrency_HeaderFile #endif // _AIS_SelectionModesConcurrency_HeaderFile

View File

@ -21,10 +21,11 @@ enum AIS_SelectionScheme
AIS_SelectionScheme_Replace = 0, //!< clears current selection and select detected objects AIS_SelectionScheme_Replace = 0, //!< clears current selection and select detected objects
AIS_SelectionScheme_Add, //!< adds detected object to current selection AIS_SelectionScheme_Add, //!< adds detected object to current selection
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

File diff suppressed because it is too large Load Diff

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,26 +71,35 @@ 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; }
//! Constructs an instance of the shape object theShape. //! Constructs an instance of the shape object theShape.
void SetShape (const TopoDS_Shape& theShape) void SetShape(const TopoDS_Shape& theShape)
{ {
myshape = theShape; myshape = theShape;
myCompBB = Standard_True; myCompBB = Standard_True;
} }
//! Alias for ::SetShape(). //! Alias for ::SetShape().
void Set (const TopoDS_Shape& theShape) { SetShape (theShape); } void Set(const TopoDS_Shape& theShape) { SetShape(theShape); }
//! Sets a local value for deviation coefficient for this specific shape. //! Sets a local value for deviation coefficient for this specific shape.
Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient(); Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient();
@ -98,31 +108,33 @@ public:
Standard_EXPORT Standard_Boolean SetOwnDeviationAngle(); Standard_EXPORT Standard_Boolean SetOwnDeviationAngle();
//! Sets a local value for deviation coefficient for this specific shape. //! Sets a local value for deviation coefficient for this specific shape.
Standard_EXPORT void SetOwnDeviationCoefficient (const Standard_Real aCoefficient); Standard_EXPORT void SetOwnDeviationCoefficient(const Standard_Real aCoefficient);
//! this compute a new angle and Deviation from the value anAngle //! this compute a new angle and Deviation from the value anAngle
//! and set the values stored in myDrawer with these that become local to the shape //! and set the values stored in myDrawer with these that become local to the shape
Standard_EXPORT void SetAngleAndDeviation (const Standard_Real anAngle); Standard_EXPORT void SetAngleAndDeviation(const Standard_Real anAngle);
//! gives back the angle initial value put by the User. //! gives back the angle initial value put by the User.
Standard_EXPORT Standard_Real UserAngle() const; Standard_EXPORT Standard_Real UserAngle() const;
//! sets myOwnDeviationAngle field in Prs3d_Drawer & recomputes presentation //! sets myOwnDeviationAngle field in Prs3d_Drawer & recomputes presentation
Standard_EXPORT void SetOwnDeviationAngle (const Standard_Real anAngle); Standard_EXPORT void SetOwnDeviationAngle(const Standard_Real anAngle);
//! Returns true and the values of the deviation //! Returns true and the values of the deviation
//! 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); }
//! Gets the type of HLR algorithm //! Gets the type of HLR algorithm
Prs3d_TypeOfHLR TypeOfHLR() const { return myDrawer->TypeOfHLR(); } Prs3d_TypeOfHLR TypeOfHLR() const { return myDrawer->TypeOfHLR(); }
@ -140,27 +152,27 @@ public:
//! Prs3d_Drawer_SeenLineAspect //! Prs3d_Drawer_SeenLineAspect
//! - hidden line color in hidden line mode: //! - hidden line color in hidden line mode:
//! Prs3d_Drawer_HiddenLineAspect. //! Prs3d_Drawer_HiddenLineAspect.
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
//! Removes settings for color in the reconstructed compound shape. //! Removes settings for color in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
//! Sets the value aValue for line width in the reconstructed compound shape. //! Sets the value aValue for line width in the reconstructed compound shape.
//! Changes line aspects for lines presentation. //! Changes line aspects for lines presentation.
Standard_EXPORT virtual void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT virtual void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Removes the setting for line width in the reconstructed compound shape. //! Removes the setting for line width in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
//! Allows you to provide settings for the material aName //! Allows you to provide settings for the material aName
//! in the reconstructed compound shape. //! in the reconstructed compound shape.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName) Standard_OVERRIDE; Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& aName) Standard_OVERRIDE;
//! Removes settings for material in the reconstructed compound shape. //! Removes settings for material in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
//! Sets the value aValue for transparency in the reconstructed compound shape. //! Sets the value aValue for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE; Standard_EXPORT virtual void SetTransparency(const Standard_Real aValue = 0.6) Standard_OVERRIDE;
//! 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;
@ -175,7 +187,7 @@ public:
//! Returns the Color attributes of the shape accordingly to //! Returns the Color attributes of the shape accordingly to
//! the current facing model; //! the current facing model;
Standard_EXPORT virtual void Color (Quantity_Color& aColor) const Standard_OVERRIDE; Standard_EXPORT virtual void Color(Quantity_Color& aColor) const Standard_OVERRIDE;
//! Returns the NameOfMaterial attributes of the shape accordingly to //! Returns the NameOfMaterial attributes of the shape accordingly to
//! the current facing model; //! the current facing model;
@ -186,56 +198,74 @@ public:
Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
//! Return shape type for specified selection mode. //! Return shape type for specified selection mode.
static TopAbs_ShapeEnum SelectionType (const Standard_Integer theSelMode) static TopAbs_ShapeEnum SelectionType(const Standard_Integer theSelMode)
{ {
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;
} }
//! Return selection mode for specified shape type. //! Return selection mode for specified shape type.
static Standard_Integer SelectionMode (const TopAbs_ShapeEnum theShapeType) static Standard_Integer SelectionMode(const TopAbs_ShapeEnum theShapeType)
{ {
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
void SetTextureRepeatUV (const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; } //! space (Umin,Umax) by (Vmin,Vmax).
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.
const gp_Pnt2d& TextureOriginUV() const { return myUVOrigin; } const gp_Pnt2d& TextureOriginUV() const { return myUVOrigin; }
//! Use this method to change the origin of the texture. //! Use this method to change the origin of the texture.
//! The texel (0,0) will be mapped to the surface (myUVOrigin.X(), myUVOrigin.Y()). //! The texel (0,0) will be mapped to the surface (myUVOrigin.X(), myUVOrigin.Y()).
void SetTextureOriginUV (const gp_Pnt2d& theOriginUV) { myUVOrigin = theOriginUV; } void SetTextureOriginUV(const gp_Pnt2d& theOriginUV) { myUVOrigin = theOriginUV; }
//! Return scale factor for UV coordinates; (1, 1) by default. //! Return scale factor for UV coordinates; (1, 1) by default.
const gp_Pnt2d& TextureScaleUV() const { return myUVScale; } const gp_Pnt2d& TextureScaleUV() const { return myUVScale; }
@ -244,73 +274,75 @@ public: //! @name methods to alter texture mapping properties
//! You can specify a scale factor for both U and V. //! You can specify a scale factor for both U and V.
//! Example: if you set ScaleU and ScaleV to 0.5 and you enable texture repeat, //! Example: if you set ScaleU and ScaleV to 0.5 and you enable texture repeat,
//! the texture will appear twice on the face in each direction. //! the texture will appear twice on the face in each direction.
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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute projected presentation. //! Compute projected presentation.
virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector, 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
{ {
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);
computeHlrPresentation (theProjector, thePrs, aShape, myDrawer); computeHlrPresentation(theProjector, thePrs, aShape, myDrawer);
} }
else else
{ {
computeHlrPresentation (theProjector, thePrs, myshape, myDrawer); computeHlrPresentation(theProjector, thePrs, myshape, myDrawer);
} }
} }
//! Compute selection. //! Compute selection.
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;
//! 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,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
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
gp_Pnt2d myUVRepeat; //!< UV repeat vector for generating texture coordinates gp_Pnt2d myUVRepeat; //!< UV repeat vector for generating texture coordinates
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,26 +14,25 @@
// 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>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
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
{ {
Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable()); Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable());
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,16 +17,15 @@
#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,
AIS_SOD_Nothing, AIS_SOD_Nothing,
AIS_SOD_AllBad, AIS_SOD_AllBad,
AIS_SOD_Selected, AIS_SOD_Selected,
AIS_SOD_OnlyOneDetected, AIS_SOD_OnlyOneDetected,
AIS_SOD_OnlyOneGood, AIS_SOD_OnlyOneGood,
AIS_SOD_SeveralGood AIS_SOD_SeveralGood
}; };
#endif // _AIS_StatusOfDetection_HeaderFile #endif // _AIS_StatusOfDetection_HeaderFile

View File

@ -17,14 +17,13 @@
#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,
AIS_SOP_NothingSelected, AIS_SOP_NothingSelected,
AIS_SOP_Removed, AIS_SOP_Removed,
AIS_SOP_OneSelected, AIS_SOP_OneSelected,
AIS_SOP_SeveralSelected AIS_SOP_SeveralSelected
}; };
#endif // _AIS_StatusOfPick_HeaderFile #endif // _AIS_StatusOfPick_HeaderFile

View File

@ -32,310 +32,265 @@
#include <V3d_Viewer.hxx> #include <V3d_Viewer.hxx>
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),
myHasOwnAnchorPoint (Standard_True), myHasOwnAnchorPoint(Standard_True),
myHasFlipping (Standard_False) myHasFlipping(Standard_False)
{ {
myDrawer->SetTextAspect (new Prs3d_TextAspect()); myDrawer->SetTextAspect(new Prs3d_TextAspect());
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;
myDrawer->SetColor (theColor); myDrawer->SetColor(theColor);
myDrawer->TextAspect()->SetColor (theColor); myDrawer->TextAspect()->SetColor(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());
aTextColor.SetAlpha (Standard_ShortReal(1.0 - theValue)); aTextColor.SetAlpha(Standard_ShortReal(1.0 - theValue));
Quantity_ColorRGBA aSubColor (myDrawer->TextAspect()->Aspect()->ColorSubTitle()); Quantity_ColorRGBA aSubColor(myDrawer->TextAspect()->Aspect()->ColorSubTitle());
aSubColor.SetAlpha (aTextColor.Alpha()); aSubColor.SetAlpha(aTextColor.Alpha());
myDrawer->TextAspect()->Aspect()->SetColor (aTextColor); myDrawer->TextAspect()->Aspect()->SetColor(aTextColor);
myDrawer->TextAspect()->Aspect()->SetColorSubTitle (aSubColor); myDrawer->TextAspect()->Aspect()->SetColorSubTitle(aSubColor);
myDrawer->SetTransparency (Standard_ShortReal(theValue)); myDrawer->SetTransparency(Standard_ShortReal(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);
}
//=================================================================================================
void AIS_TextLabel::SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust)
{
myDrawer->TextAspect()->SetHorizontalJustification(theHJust);
} }
//======================================================================= //=======================================================================
//function : SetHJustification // function : SetVJustification
//purpose : // purpose : Setup vertical justification.
//======================================================================= //=======================================================================
void AIS_TextLabel::SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust) void AIS_TextLabel::SetVJustification(const Graphic3d_VerticalTextAlignment theVJust)
{ {
myDrawer->TextAspect()->SetHorizontalJustification (theHJust); myDrawer->TextAspect()->SetVerticalJustification(theVJust);
} }
//======================================================================= //=================================================================================================
//function : SetVJustification
//purpose : Setup vertical justification. void AIS_TextLabel::SetAngle(const Standard_Real theAngle)
//=======================================================================
void AIS_TextLabel::SetVJustification (const Graphic3d_VerticalTextAlignment theVJust)
{ {
myDrawer->TextAspect()->SetVerticalJustification (theVJust); myDrawer->TextAspect()->Aspect()->SetTextAngle(theAngle * 180.0 / M_PI);
} }
//======================================================================= //=================================================================================================
//function : SetAngle
//purpose : void AIS_TextLabel::SetZoomable(const Standard_Boolean theIsZoomable)
//=======================================================================
void AIS_TextLabel::SetAngle (const Standard_Real theAngle)
{ {
myDrawer->TextAspect()->Aspect()->SetTextAngle (theAngle * 180.0 / M_PI); myDrawer->TextAspect()->Aspect()->SetTextZoomable(theIsZoomable == Standard_True);
} }
//======================================================================= //=================================================================================================
//function : SetZoom
//purpose : void AIS_TextLabel::SetHeight(const Standard_Real theHeight)
//=======================================================================
void AIS_TextLabel::SetZoomable (const Standard_Boolean theIsZoomable)
{ {
myDrawer->TextAspect()->Aspect()->SetTextZoomable (theIsZoomable == Standard_True); myDrawer->TextAspect()->SetHeight(theHeight);
} }
//======================================================================= //=================================================================================================
//function : SetHeight
//purpose : void AIS_TextLabel::SetFontAspect(const Font_FontAspect theFontAspect)
//=======================================================================
void AIS_TextLabel::SetHeight (const Standard_Real theHeight)
{ {
myDrawer->TextAspect()->SetHeight (theHeight); myDrawer->TextAspect()->Aspect()->SetTextFontAspect(theFontAspect);
} }
//======================================================================= //=================================================================================================
//function : SetAngle
//purpose : void AIS_TextLabel::SetFont(Standard_CString theFont)
//=======================================================================
void AIS_TextLabel::SetFontAspect (const Font_FontAspect theFontAspect)
{ {
myDrawer->TextAspect()->Aspect()->SetTextFontAspect (theFontAspect); myDrawer->TextAspect()->SetFont(theFont);
} }
//======================================================================= //=================================================================================================
//function : SetFont
//purpose :
//=======================================================================
void AIS_TextLabel::SetFont (Standard_CString theFont)
{
myDrawer->TextAspect()->SetFont (theFont);
}
//======================================================================= void AIS_TextLabel::SetOrientation3D(const gp_Ax2& theOrientation)
//function : SetOrientation3D
//purpose :
//=======================================================================
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)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
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();
const Standard_Boolean isTextZoomable = anAsp->Aspect()->GetTextZoomable(); const Standard_Boolean isTextZoomable = anAsp->Aspect()->GetTextZoomable();
if (myHasOrientation3D) if (myHasOrientation3D)
{ {
anAsp->Aspect()->SetTextZoomable (myHasFlipping ? Standard_True : Standard_False); anAsp->Aspect()->SetTextZoomable(myHasFlipping ? Standard_True : Standard_False);
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,
SetTransformPersistence (aTrsfPers); aPosition);
SetTransformPersistence(aTrsfPers);
aPosition = gp::Origin(); aPosition = gp::Origin();
} }
gp_Pnt aCenterOfLabel; gp_Pnt aCenterOfLabel;
Standard_Real aWidth, aHeight; Standard_Real aWidth, aHeight;
Standard_Boolean isInit = calculateLabelParams (aPosition, aCenterOfLabel, aWidth, aHeight); Standard_Boolean isInit = calculateLabelParams(aPosition, aCenterOfLabel, aWidth, aHeight);
if (myHasOrientation3D) if (myHasOrientation3D)
{ {
if (myHasFlipping) if (myHasFlipping)
{ {
gp_Ax2 aFlippingAxes (aCenterOfLabel, myOrientation3D.Direction(), myOrientation3D.XDirection()); gp_Ax2 aFlippingAxes(aCenterOfLabel,
thePrs->CurrentGroup()->SetFlippingOptions (Standard_True, aFlippingAxes); myOrientation3D.Direction(),
myOrientation3D.XDirection());
thePrs->CurrentGroup()->SetFlippingOptions(Standard_True, aFlippingAxes);
} }
gp_Ax2 anOrientation = myOrientation3D; gp_Ax2 anOrientation = myOrientation3D;
anOrientation.SetLocation (aPosition); anOrientation.SetLocation(aPosition);
Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint(); Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint();
if (myHasFlipping) if (myHasFlipping)
{ {
aHasOwnAnchor = Standard_False; // always not using own anchor if flipping aHasOwnAnchor = Standard_False; // always not using own anchor if flipping
} }
Handle(Graphic3d_Text) aText = Handle(Graphic3d_Text) aText =
Prs3d_Text::Draw (thePrs->CurrentGroup(), anAsp, myText, anOrientation, aHasOwnAnchor); Prs3d_Text::Draw(thePrs->CurrentGroup(), anAsp, myText, anOrientation, aHasOwnAnchor);
aText->SetTextFormatter (myFormatter); aText->SetTextFormatter(myFormatter);
if (myHasFlipping && isInit) if (myHasFlipping && isInit)
{ {
thePrs->CurrentGroup()->SetFlippingOptions (Standard_False, gp_Ax2()); thePrs->CurrentGroup()->SetFlippingOptions(Standard_False, gp_Ax2());
} }
} }
else else
{ {
Handle(Graphic3d_Text) aText = Handle(Graphic3d_Text) aText =
Prs3d_Text::Draw (thePrs->CurrentGroup(), anAsp, myText, aPosition); Prs3d_Text::Draw(thePrs->CurrentGroup(), anAsp, myText, aPosition);
aText->SetTextFormatter (myFormatter); aText->SetTextFormatter(myFormatter);
} }
if (isInit) if (isInit)
{ {
const Standard_Real aDx = aWidth * 0.5; const Standard_Real aDx = aWidth * 0.5;
const Standard_Real aDy = aHeight * 0.5; const Standard_Real aDy = aHeight * 0.5;
gp_Trsf aLabelPlane = calculateLabelTrsf (aPosition, aCenterOfLabel); gp_Trsf aLabelPlane = calculateLabelTrsf(aPosition, aCenterOfLabel);
gp_Pnt aMinPnt = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane); gp_Pnt aMinPnt = gp_Pnt(-aDx, -aDy, 0.0).Transformed(aLabelPlane);
gp_Pnt aMaxPnt = gp_Pnt ( aDx, aDy, 0.0).Transformed (aLabelPlane); gp_Pnt aMaxPnt = gp_Pnt(aDx, aDy, 0.0).Transformed(aLabelPlane);
Graphic3d_BndBox4f& aBox = thePrs->CurrentGroup()->ChangeBoundingBox(); Graphic3d_BndBox4f& aBox = thePrs->CurrentGroup()->ChangeBoundingBox();
aBox.Add (Graphic3d_Vec4 ((float) aMinPnt.X(), (float) aMinPnt.Y(), (float) aMinPnt.Z(), 1.0)); aBox.Add(Graphic3d_Vec4((float)aMinPnt.X(), (float)aMinPnt.Y(), (float)aMinPnt.Z(), 1.0));
aBox.Add (Graphic3d_Vec4 ((float) aMaxPnt.X(), (float) aMaxPnt.Y(), (float) aMaxPnt.Z(), 1.0)); aBox.Add(Graphic3d_Vec4((float)aMaxPnt.X(), (float)aMaxPnt.Y(), (float)aMaxPnt.Z(), 1.0));
} }
break; break;
@ -343,18 +298,15 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_TextLabel::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
//======================================================================= const Standard_Integer theMode)
void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
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();
if (!TransformPersistence().IsNull() && TransformPersistence()->Mode() != Graphic3d_TMF_2d) if (!TransformPersistence().IsNull() && TransformPersistence()->Mode() != Graphic3d_TMF_2d)
@ -362,66 +314,67 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
aPosition = gp::Origin(); aPosition = gp::Origin();
} }
gp_Pnt aCenterOfLabel; gp_Pnt aCenterOfLabel;
Standard_Real aWidth, aHeight; Standard_Real aWidth, aHeight;
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 =
theSelection->Add (aTextSensitive); new Select3D_SensitivePoint(anEntityOwner, aPosition);
theSelection->Add(aTextSensitive);
break; break;
} }
const Standard_Real aDx = aWidth * 0.5; const Standard_Real aDx = aWidth * 0.5;
const Standard_Real aDy = aHeight * 0.5; const Standard_Real aDy = aHeight * 0.5;
gp_Trsf aLabelPlane = calculateLabelTrsf (aPosition, aCenterOfLabel); gp_Trsf aLabelPlane = calculateLabelTrsf(aPosition, aCenterOfLabel);
// sensitive planar rectangle for text // sensitive planar rectangle for text
TColgp_Array1OfPnt aRectanglePoints (1, 5); TColgp_Array1OfPnt aRectanglePoints(1, 5);
aRectanglePoints.ChangeValue (1) = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane); aRectanglePoints.ChangeValue(1) = gp_Pnt(-aDx, -aDy, 0.0).Transformed(aLabelPlane);
aRectanglePoints.ChangeValue (2) = gp_Pnt (-aDx, aDy, 0.0).Transformed (aLabelPlane); aRectanglePoints.ChangeValue(2) = gp_Pnt(-aDx, aDy, 0.0).Transformed(aLabelPlane);
aRectanglePoints.ChangeValue (3) = gp_Pnt ( aDx, aDy, 0.0).Transformed (aLabelPlane); aRectanglePoints.ChangeValue(3) = gp_Pnt(aDx, aDy, 0.0).Transformed(aLabelPlane);
aRectanglePoints.ChangeValue (4) = gp_Pnt ( aDx, -aDy, 0.0).Transformed (aLabelPlane); aRectanglePoints.ChangeValue(4) = gp_Pnt(aDx, -aDy, 0.0).Transformed(aLabelPlane);
aRectanglePoints.ChangeValue (5) = aRectanglePoints.Value (1); aRectanglePoints.ChangeValue(5) = aRectanglePoints.Value(1);
Handle(Select3D_SensitiveFace) aTextSensitive = Handle(Select3D_SensitiveFace) aTextSensitive =
new Select3D_SensitiveFace (anEntityOwner, aRectanglePoints, Select3D_TOS_INTERIOR); new Select3D_SensitiveFace(anEntityOwner, aRectanglePoints, Select3D_TOS_INTERIOR);
theSelection->Add (aTextSensitive); theSelection->Add(aTextSensitive);
break; break;
} }
} }
} }
//======================================================================= //=================================================================================================
//function : calculateLabelParams
//purpose : Standard_Boolean AIS_TextLabel::calculateLabelParams(const gp_Pnt& thePosition,
//======================================================================= gp_Pnt& theCenterOfLabel,
Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition, Standard_Real& theWidth,
gp_Pnt& theCenterOfLabel, Standard_Real& theHeight) const
Standard_Real& theWidth,
Standard_Real& theHeight) const
{ {
// 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;
aFontParams.FontHinting = aRendParams.FontHinting; aFontParams.FontHinting = aRendParams.FontHinting;
Handle(Font_FTFont) aFont = Font_FTFont::FindAndCreate (anAsp->Aspect()->Font(), Handle(Font_FTFont) aFont = Font_FTFont::FindAndCreate(anAsp->Aspect()->Font(),
anAsp->Aspect()->GetTextFontAspect(), anAsp->Aspect()->GetTextFontAspect(),
aFontParams); aFontParams);
if (aFont.IsNull()) if (aFont.IsNull())
{ {
return Standard_False; return Standard_False;
} }
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 =
theWidth = Abs (aBndBox.Width()); aFont->BoundingBox(aText, anAsp->HorizontalJustification(), anAsp->VerticalJustification());
theHeight = Abs (aBndBox.Height()); theWidth = Abs(aBndBox.Width());
theHeight = Abs(aBndBox.Height());
theCenterOfLabel = thePosition; theCenterOfLabel = thePosition;
if (anAsp->VerticalJustification() == Graphic3d_VTA_BOTTOM) if (anAsp->VerticalJustification() == Graphic3d_VTA_BOTTOM)
@ -444,22 +397,20 @@ 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;
const gp_Ax1 aRotAxis (thePosition, gp_Dir (0.0, 0.0, 1.0)); const gp_Ax1 aRotAxis(thePosition, gp_Dir(0.0, 0.0, 1.0));
gp_Ax2 anOrientation = myOrientation3D; gp_Ax2 anOrientation = myOrientation3D;
anOrientation.Rotate (aRotAxis, anAngle); anOrientation.Rotate(aRotAxis, anAngle);
theCenterOfLabel.Rotate (aRotAxis, anAngle); theCenterOfLabel.Rotate(aRotAxis, anAngle);
gp_Trsf aLabelPlane; gp_Trsf aLabelPlane;
aLabelPlane.SetTransformation (anOrientation, gp::XOY()); aLabelPlane.SetTransformation(anOrientation, gp::XOY());
aLabelPlane.SetTranslationPart (theCenterOfLabel.XYZ()); aLabelPlane.SetTranslationPart(theCenterOfLabel.XYZ());
return aLabelPlane; return aLabelPlane;
} }

View File

@ -30,57 +30,59 @@ 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;
//! Setup transparency within [0, 1] range. //! Setup transparency within [0, 1] range.
Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE; Standard_EXPORT virtual void SetTransparency(const Standard_Real theValue) Standard_OVERRIDE;
//! Removes the transparency setting. //! Removes the transparency setting.
virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency (0.0); } virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency(0.0); }
//! Material has no effect for text label. //! Material has no effect for text label.
virtual void SetMaterial (const Graphic3d_MaterialAspect& ) Standard_OVERRIDE {} virtual void SetMaterial(const Graphic3d_MaterialAspect&) Standard_OVERRIDE {}
//! Setup text. //! Setup text.
Standard_EXPORT void SetText (const TCollection_ExtendedString& theText); Standard_EXPORT void SetText(const TCollection_ExtendedString& theText);
//! Setup position. //! Setup position.
Standard_EXPORT void SetPosition (const gp_Pnt& thePosition); Standard_EXPORT void SetPosition(const gp_Pnt& thePosition);
//! Setup horizontal justification. //! Setup horizontal justification.
Standard_EXPORT void SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust); Standard_EXPORT void SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust);
//! Setup vertical justification. //! Setup vertical justification.
Standard_EXPORT void SetVJustification (const Graphic3d_VerticalTextAlignment theVJust); Standard_EXPORT void SetVJustification(const Graphic3d_VerticalTextAlignment theVJust);
//! Setup angle. //! Setup angle.
Standard_EXPORT void SetAngle (const Standard_Real theAngle); Standard_EXPORT void SetAngle(const Standard_Real theAngle);
//! Setup zoomable property. //! Setup zoomable property.
Standard_EXPORT void SetZoomable (const Standard_Boolean theIsZoomable); Standard_EXPORT void SetZoomable(const Standard_Boolean theIsZoomable);
//! Setup height. //! Setup height.
Standard_EXPORT void SetHeight (const Standard_Real theHeight); Standard_EXPORT void SetHeight(const Standard_Real theHeight);
//! Setup font aspect. //! Setup font aspect.
Standard_EXPORT void SetFontAspect (const Font_FontAspect theFontAspect); Standard_EXPORT void SetFontAspect(const Font_FontAspect theFontAspect);
//! Setup font. //! Setup font.
Standard_EXPORT void SetFont (Standard_CString theFont); Standard_EXPORT void SetFont(Standard_CString theFont);
//! Setup label orientation in the model 3D space. //! Setup label orientation in the model 3D space.
Standard_EXPORT void SetOrientation3D (const gp_Ax2& theOrientation); Standard_EXPORT void SetOrientation3D(const gp_Ax2& theOrientation);
//! Reset label orientation in the model 3D space. //! Reset label orientation in the model 3D space.
Standard_EXPORT void UnsetOrientation3D (); Standard_EXPORT void UnsetOrientation3D();
//! Returns position. //! Returns position.
Standard_EXPORT const gp_Pnt& Position() const; Standard_EXPORT const gp_Pnt& Position() const;
@ -100,7 +102,7 @@ public:
//! Returns true if the current text placement mode uses text orientation in the model 3D space. //! Returns true if the current text placement mode uses text orientation in the model 3D space.
Standard_EXPORT Standard_Boolean HasOrientation3D() const; Standard_EXPORT Standard_Boolean HasOrientation3D() const;
Standard_EXPORT void SetFlipping (const Standard_Boolean theIsFlipping); Standard_EXPORT void SetFlipping(const Standard_Boolean theIsFlipping);
Standard_EXPORT Standard_Boolean HasFlipping() const; Standard_EXPORT Standard_Boolean HasFlipping() const;
@ -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.
//! //!
@ -117,41 +122,43 @@ public:
//! TODT_DEKALE The text is displayed with a 3D style. //! TODT_DEKALE The text is displayed with a 3D style.
//! TODT_BLEND The text is displayed in XOR. //! TODT_BLEND The text is displayed in XOR.
//! TODT_DIMENSION Dimension line under text will be invisible. //! TODT_DIMENSION Dimension line under text will be invisible.
Standard_EXPORT void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType); Standard_EXPORT void SetDisplayType(const Aspect_TypeOfDisplayText theDisplayType);
//! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType //! Modifies the colour of the subtitle for the TODT_SUBTITLE TextDisplayType
//! 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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection //! Compute selection
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;
//! Calculate label center, width and height //! Calculate label center, width and height
Standard_EXPORT Standard_Boolean calculateLabelParams (const gp_Pnt& thePosition, Standard_EXPORT Standard_Boolean calculateLabelParams(const gp_Pnt& thePosition,
gp_Pnt& theCenterOfLabel, gp_Pnt& theCenterOfLabel,
Standard_Real& theWidth, Standard_Real& theWidth,
Standard_Real& theHeight) const; Standard_Real& theHeight) const;
//! Calculate label transformation //! Calculate label transformation
Standard_EXPORT gp_Trsf calculateLabelTrsf (const gp_Pnt& thePosition, Standard_EXPORT gp_Trsf calculateLabelTrsf(const gp_Pnt& thePosition,
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,46 +35,40 @@
#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) //=================================================================================================
//======================================================================= AIS_TexturedShape::AIS_TexturedShape(const TopoDS_Shape& theShape)
//function : AIS_TexturedShape : AIS_Shape(theShape),
//purpose : myPredefTexture(Graphic3d_NameOfTexture2D(0)),
//======================================================================= myToMapTexture(Standard_True),
AIS_TexturedShape::AIS_TexturedShape (const TopoDS_Shape& theShape) myModulate(Standard_True),
: AIS_Shape (theShape), myIsCustomOrigin(Standard_True),
myPredefTexture (Graphic3d_NameOfTexture2D(0)), myToRepeat(Standard_True),
myToMapTexture (Standard_True), myToScale(Standard_True),
myModulate (Standard_True), myToShowTriangles(Standard_False)
myIsCustomOrigin (Standard_True),
myToRepeat (Standard_True),
myToScale (Standard_True),
myToShowTriangles (Standard_False)
{ {
} }
//======================================================================= //=================================================================================================
//function : SetTextureFileName
//purpose : void AIS_TexturedShape::SetTextureFileName(const TCollection_AsciiString& theTextureFileName)
//=======================================================================
void AIS_TexturedShape::SetTextureFileName (const TCollection_AsciiString& theTextureFileName)
{ {
myTexturePixMap.Nullify(); myTexturePixMap.Nullify();
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);
} }
else else
{ {
Message::SendFail (TCollection_AsciiString ("Error: texture with ID ") + theTextureFileName Message::SendFail(TCollection_AsciiString("Error: texture with ID ") + theTextureFileName
+ " is undefined. Texture 0 will be used instead."); + " is undefined. Texture 0 will be used instead.");
myPredefTexture = Graphic3d_NameOfTexture2D (0); myPredefTexture = Graphic3d_NameOfTexture2D(0);
} }
myTextureFile = ""; myTextureFile = "";
} }
@ -85,191 +79,148 @@ 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 = "";
myPredefTexture = Graphic3d_NOT_2D_UNKNOWN; myPredefTexture = Graphic3d_NOT_2D_UNKNOWN;
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,
const Standard_Real theVRepeat) const Standard_Real theVRepeat)
{ {
myToRepeat = theToRepeat; myToRepeat = 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,
const Standard_Real theVOrigin) const Standard_Real theVOrigin)
{ {
myIsCustomOrigin = theToSetTextureOrigin; myIsCustomOrigin = theToSetTextureOrigin;
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,
const Standard_Real theScaleV) const Standard_Real theScaleV)
{ {
myToScale = theToSetTextureScale; myToScale = theToSetTextureScale;
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)
{ {
AIS_Shape::SetColor (theColor); AIS_Shape::SetColor(theColor);
for (PrsMgr_Presentations::Iterator aPrsIter (Presentations()); aPrsIter.More(); aPrsIter.Next()) for (PrsMgr_Presentations::Iterator aPrsIter(Presentations()); aPrsIter.More(); aPrsIter.Next())
{ {
if (aPrsIter.Value()->Mode() == 3) if (aPrsIter.Value()->Mode() == 3)
{ {
updateAttributes (aPrsIter.Value()); updateAttributes(aPrsIter.Value());
} }
} }
} }
//======================================================================= //=================================================================================================
//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)
{ {
AIS_Shape::SetMaterial (theMat); AIS_Shape::SetMaterial(theMat);
for (PrsMgr_Presentations::Iterator aPrsIter (Presentations()); aPrsIter.More(); aPrsIter.Next()) for (PrsMgr_Presentations::Iterator aPrsIter(Presentations()); aPrsIter.More(); aPrsIter.Next())
{ {
if (aPrsIter.Value()->Mode() == 3) if (aPrsIter.Value()->Mode() == 3)
{ {
updateAttributes (aPrsIter.Value()); updateAttributes(aPrsIter.Value());
} }
} }
} }
//======================================================================= //=================================================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
void AIS_TexturedShape::UnsetMaterial() void AIS_TexturedShape::UnsetMaterial()
{ {
AIS_Shape::UnsetMaterial(); AIS_Shape::UnsetMaterial();
for (PrsMgr_Presentations::Iterator aPrsIter (Presentations()); aPrsIter.More(); aPrsIter.Next()) for (PrsMgr_Presentations::Iterator aPrsIter(Presentations()); aPrsIter.More(); aPrsIter.Next())
{ {
if (aPrsIter.Value()->Mode() == 3) if (aPrsIter.Value()->Mode() == 3)
{ {
updateAttributes (aPrsIter.Value()); updateAttributes(aPrsIter.Value());
} }
} }
} }
//======================================================================= //=================================================================================================
//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)
{ {
myAspect = new Graphic3d_AspectFillArea3d (*myDrawer->ShadingAspect()->Aspect()); myAspect = new Graphic3d_AspectFillArea3d(*myDrawer->ShadingAspect()->Aspect());
if (HasPolygonOffsets()) if (HasPolygonOffsets())
{ {
Standard_Integer aMode; Standard_Integer aMode;
Standard_ShortReal aFactor, aUnits; Standard_ShortReal aFactor, aUnits;
PolygonOffsets (aMode, aFactor, aUnits); PolygonOffsets(aMode, aFactor, aUnits);
myAspect->SetPolygonOffsets (aMode, aFactor, aUnits); myAspect->SetPolygonOffsets(aMode, aFactor, aUnits);
} }
Standard_Boolean hasTexture = Standard_False; Standard_Boolean hasTexture = Standard_False;
@ -278,17 +229,17 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
TCollection_AsciiString aTextureDesc; TCollection_AsciiString aTextureDesc;
if (!myTexturePixMap.IsNull()) if (!myTexturePixMap.IsNull())
{ {
myTexture = new Graphic3d_Texture2D (myTexturePixMap); myTexture = new Graphic3d_Texture2D(myTexturePixMap);
aTextureDesc = " (custom image)"; aTextureDesc = " (custom image)";
} }
else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN) else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
{ {
myTexture = new Graphic3d_Texture2D (myPredefTexture); myTexture = new Graphic3d_Texture2D(myPredefTexture);
aTextureDesc = TCollection_AsciiString(" (predefined texture ") + myTexture->GetId() + ")"; aTextureDesc = TCollection_AsciiString(" (predefined texture ") + myTexture->GetId() + ")";
} }
else else
{ {
myTexture = new Graphic3d_Texture2D (myTextureFile.ToCString()); myTexture = new Graphic3d_Texture2D(myTextureFile.ToCString());
aTextureDesc = TCollection_AsciiString(" (") + myTextureFile + ")"; aTextureDesc = TCollection_AsciiString(" (") + myTextureFile + ")";
} }
@ -307,11 +258,12 @@ 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);
} }
} }
myAspect->SetTextureMap (myTexture); myAspect->SetTextureMap(myTexture);
if (hasTexture) if (hasTexture)
{ {
myAspect->SetTextureMapOn(); myAspect->SetTextureMapOn();
@ -331,63 +283,59 @@ 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)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
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
+ (Standard_Integer )myshape.ShapeType() - TopAbs_WIRE; + (Standard_Integer)myshape.ShapeType() - TopAbs_WIRE;
thePrs->SetVisual (Graphic3d_TOS_ALL); thePrs->SetVisual(Graphic3d_TOS_ALL);
thePrs->SetDisplayPriority ((Graphic3d_DisplayPriority )aPrior); thePrs->SetDisplayPriority((Graphic3d_DisplayPriority)aPrior);
} }
if (IsInfinite()) if (IsInfinite())
{ {
thePrs->SetInfiniteState (Standard_True); thePrs->SetInfiniteState(Standard_True);
} }
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;
} }
case AIS_Shaded: case AIS_Shaded:
case 3: // texture mapping on triangulation case 3: // texture mapping on triangulation
{ {
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True); StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
if (myshape.ShapeType() > TopAbs_FACE) if (myshape.ShapeType() > TopAbs_FACE)
{ {
StdPrs_WFShape::Add (thePrs, myshape, myDrawer); StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
break; break;
} }
if (IsInfinite()) if (IsInfinite())
{ {
StdPrs_WFShape::Add (thePrs, myshape, myDrawer); StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
break; break;
} }
try try
@ -395,16 +343,18 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
if (theMode == AIS_Shaded) if (theMode == AIS_Shaded)
{ {
StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer); StdPrs_ShadedShape::Add(thePrs, myshape, myDrawer);
} }
else else
{ {
StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer, StdPrs_ShadedShape::Add(thePrs,
Standard_True, myshape,
myIsCustomOrigin ? myUVOrigin : gp_Pnt2d (0.0, 0.0), myDrawer,
myUVRepeat, Standard_True,
myToScale ? myUVScale : gp_Pnt2d (1.0, 1.0)); myIsCustomOrigin ? myUVOrigin : gp_Pnt2d(0.0, 0.0),
updateAttributes (thePrs); myUVRepeat,
myToScale ? myUVScale : gp_Pnt2d(1.0, 1.0));
updateAttributes(thePrs);
} }
} }
catch (Standard_Failure const&) catch (Standard_Failure const&)
@ -412,7 +362,7 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed \n"; std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed \n";
#endif #endif
StdPrs_WFShape::Add (thePrs, myshape, myDrawer); StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
} }
break; break;
} }
@ -420,11 +370,11 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
{ {
if (IsInfinite()) if (IsInfinite())
{ {
StdPrs_WFShape::Add (thePrs, myshape, myDrawer); StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
} }
else else
{ {
Prs3d_BndBox::Add (thePrs, BoundingBox(), myDrawer); Prs3d_BndBox::Add(thePrs, BoundingBox(), myDrawer);
} }
break; break;
} }

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,20 +49,22 @@ 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
Standard_EXPORT virtual void SetTexturePixMap (const Handle(Image_PixMap)& theTexturePixMap); //! by filename (if was set previously).
Standard_EXPORT virtual void SetTexturePixMap(const Handle(Image_PixMap)& theTexturePixMap);
//! @return flag to control texture mapping (for presentation mode 3) //! @return flag to control texture mapping (for presentation mode 3)
Standard_Boolean TextureMapState() const { return myToMapTexture; } Standard_Boolean TextureMapState() const { return myToMapTexture; }
@ -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)
//! { //! {
@ -98,13 +100,14 @@ public: //! @name methods to alter texture mapping properties
Standard_EXPORT void UpdateAttributes(); Standard_EXPORT void UpdateAttributes();
//! Sets the color. //! Sets the color.
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
//! Removes settings for the color. //! Removes settings for the color.
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,12 +127,13 @@ 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
Standard_EXPORT void SetTextureRepeat (const Standard_Boolean theToRepeat, //! in the range (0,1)x(0,1) of the face.
const Standard_Real theURepeat = 1.0, Standard_EXPORT void SetTextureRepeat(const Standard_Boolean theToRepeat,
const Standard_Real theVRepeat = 1.0); const Standard_Real theURepeat = 1.0,
const Standard_Real theVRepeat = 1.0);
//! @return true if texture UV origin has been modified //! @return true if texture UV origin has been modified
Standard_Boolean TextureOrigin() const { return myIsCustomOrigin; } Standard_Boolean TextureOrigin() const { return myIsCustomOrigin; }
@ -140,10 +144,11 @@ 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
Standard_EXPORT void SetTextureOrigin (const Standard_Boolean theToSetTextureOrigin, //! surface (UOrigin,VOrigin)
const Standard_Real theUOrigin = 0.0, Standard_EXPORT void SetTextureOrigin(const Standard_Boolean theToSetTextureOrigin,
const Standard_Real theVOrigin = 0.0); const Standard_Real theUOrigin = 0.0,
const Standard_Real theVOrigin = 0.0);
//! @return true if scale factor should be applied to texture mapping //! @return true if scale factor should be applied to texture mapping
Standard_Boolean TextureScale() const { return myToScale; } Standard_Boolean TextureScale() const { return myToScale; }
@ -158,57 +163,54 @@ public: //! @name methods to alter texture mapping properties
//! You can specify a scale factor for both U and V. //! You can specify a scale factor for both U and V.
//! Example: if you set ScaleU and ScaleV to 0.5 and you enable texture repeat, //! Example: if you set ScaleU and ScaleV to 0.5 and you enable texture repeat,
//! the texture will appear twice on the face in each direction. //! the texture will appear twice on the face in each direction.
Standard_EXPORT void SetTextureScale (const Standard_Boolean theToSetTextureScale, Standard_EXPORT void SetTextureScale(const Standard_Boolean theToSetTextureScale,
const Standard_Real theScaleU = 1.0, const Standard_Real theScaleU = 1.0,
const Standard_Real theScaleV = 1.0); const Standard_Real theScaleV = 1.0);
//! @return true if displaying of triangles is requested //! @return true if displaying of triangles is requested
Standard_Boolean ShowTriangles() const { return myToShowTriangles; } Standard_Boolean ShowTriangles() const { return myToShowTriangles; }
//! Use this method to show the triangulation of the shape (for debugging etc.). //! Use this method to show the triangulation of the shape (for debugging etc.).
Standard_EXPORT void ShowTriangles (const Standard_Boolean theToShowTriangles); Standard_EXPORT void ShowTriangles(const Standard_Boolean theToShowTriangles);
//! @return true if texture color modulation is turned on //! @return true if texture color modulation is turned on
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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
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; Standard_Boolean myToRepeat;
Standard_Boolean myToRepeat; Standard_Boolean myToScale;
Standard_Boolean myToScale; 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)
#endif // _AIS_TexturedShape_HeaderFile #endif // _AIS_TexturedShape_HeaderFile

View File

@ -24,8 +24,7 @@
#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,15 +34,13 @@ 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())
{ {
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
if (myDrawer->HasLink()) if (myDrawer->HasLink())
{ {
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect(); *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
@ -51,47 +48,43 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
} }
// override transparency // override transparency
myDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel); myDrawer->ShadingAspect()->SetTransparency(theValue, myCurrentFacingModel);
myDrawer->SetTransparency ((Standard_ShortReal )theValue); myDrawer->SetTransparency((Standard_ShortReal)theValue);
updatePresentation(); updatePresentation();
} }
//======================================================================= //=================================================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
void AIS_Triangulation::UnsetTransparency() void AIS_Triangulation::UnsetTransparency()
{ {
myDrawer->SetTransparency (0.0f); myDrawer->SetTransparency(0.0f);
if (!myDrawer->HasOwnShadingAspect()) if (!myDrawer->HasOwnShadingAspect())
{ {
return; return;
} }
else if (HasColor() || HasMaterial()) else if (HasColor() || HasMaterial())
{ {
myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel); myDrawer->ShadingAspect()->SetTransparency(0.0, myCurrentFacingModel);
} }
updatePresentation(); updatePresentation();
} }
//======================================================================= //=================================================================================================
//function : updatePresentation
//purpose :
//=======================================================================
void AIS_Triangulation::updatePresentation() void AIS_Triangulation::updatePresentation()
{ {
if (HasVertexColors()) if (HasVertexColors())
{ {
SetToUpdate (AIS_WireFrame); SetToUpdate(AIS_WireFrame);
} }
else else
{ {
// modify shading presentation without re-computation // modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations(); const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect(); Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next()) for (PrsMgr_Presentations::Iterator aPrsIter(aPrsList); aPrsIter.More(); aPrsIter.Next())
{ {
if (aPrsIter.Value()->Mode() != AIS_WireFrame) if (aPrsIter.Value()->Mode() != AIS_WireFrame)
{ {
@ -99,22 +92,21 @@ 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);
} }
} }
} }
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{ {
if (theMode != 0) if (theMode != 0)
{ {
@ -124,9 +116,12 @@ 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,
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup(); hasVNormals,
hasVColors,
Standard_False);
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
Handle(Graphic3d_AspectFillArea3d) anAspect = myDrawer->ShadingAspect()->Aspect(); Handle(Graphic3d_AspectFillArea3d) anAspect = myDrawer->ShadingAspect()->Aspect();
const Standard_Real anAmbient = 1.0; const Standard_Real anAmbient = 1.0;
@ -138,17 +133,18 @@ 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),
myTriangulation->Normal (aNodeIter, aNormal); attenuateColor(colors[aNodeIter], anAmbient));
anArray->SetVertexNormal (aNodeIter, aNormal.x(), aNormal.y(), aNormal.z()); myTriangulation->Normal(aNodeIter, aNormal);
anArray->SetVertexNormal(aNodeIter, aNormal.x(), aNormal.y(), aNormal.z());
} }
} }
else // !hasVColors else // !hasVColors
{ {
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter) for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter)
{ {
anArray->AddVertex (myTriangulation->Node (aNodeIter)); anArray->AddVertex(myTriangulation->Node(aNodeIter));
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,55 +156,53 @@ 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
{ {
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter) for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter)
{ {
anArray->AddVertex (myTriangulation->Node (aNodeIter)); anArray->AddVertex(myTriangulation->Node(aNodeIter));
} }
} }
} }
Standard_Integer aTriIndices[3] = {0,0,0}; Standard_Integer aTriIndices[3] = {0, 0, 0};
for (Standard_Integer aTriIter = 1; aTriIter <= myTriangulation->NbTriangles(); ++aTriIter) for (Standard_Integer aTriIter = 1; aTriIter <= myTriangulation->NbTriangles(); ++aTriIter)
{ {
myTriangulation->Triangle (aTriIter).Get (aTriIndices[0], aTriIndices[1], aTriIndices[2]); myTriangulation->Triangle(aTriIter).Get(aTriIndices[0], aTriIndices[1], aTriIndices[2]);
anArray->AddEdge (aTriIndices[0]); anArray->AddEdge(aTriIndices[0]);
anArray->AddEdge (aTriIndices[1]); anArray->AddEdge(aTriIndices[1]);
anArray->AddEdge (aTriIndices[2]); anArray->AddEdge(aTriIndices[2]);
} }
aGroup->SetPrimitivesAspect (anAspect); aGroup->SetPrimitivesAspect(anAspect);
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*/)
{ {
} }
//======================================================================= //=======================================================================
//function : SetColor // function : SetColor
//purpose : Set the color for each node. // purpose : 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
//======================================================================= //=======================================================================
void AIS_Triangulation::SetColors(const Handle(TColStd_HArray1OfInteger)& aColor) void AIS_Triangulation::SetColors(const Handle(TColStd_HArray1OfInteger)& aColor)
{ {
myFlagColor = 1; myFlagColor = 1;
myColor = aColor; myColor = aColor;
} }
//======================================================================= //=======================================================================
//function : GetColor // function : GetColor
//purpose : Get the color for each node. // purpose : 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
// Order of color components is essential for further usage by OpenGL // Order of color components is essential for further usage by OpenGL
//======================================================================= //=======================================================================
@ -218,39 +212,36 @@ 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,
//======================================================================= const Standard_Real theComposition)
Graphic3d_Vec4ub AIS_Triangulation::attenuateColor (const Standard_Integer theColor,
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 =
: 255; IsTransparent()
? static_cast<Standard_Byte>(
255.0 - myDrawer->ShadingAspect()->Aspect()->FrontMaterial().Transparency() * 255.0)
: 255;
return Graphic3d_Vec4ub ((Standard_Byte)(theComposition * anRgbx[0]), return Graphic3d_Vec4ub((Standard_Byte)(theComposition * anRgbx[0]),
(Standard_Byte)(theComposition * anRgbx[1]), (Standard_Byte)(theComposition * anRgbx[1]),
(Standard_Byte)(theComposition * anRgbx[2]), (Standard_Byte)(theComposition * anRgbx[2]),
anAlpha); anAlpha);
} }

View File

@ -31,64 +31,57 @@ 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);
//! Returns Poly_Triangulation . //! Returns Poly_Triangulation .
Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const; Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const;
//! Sets the value aValue for transparency in the reconstructed compound shape. //! Sets the value aValue for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE; Standard_EXPORT virtual void SetTransparency(const Standard_Real aValue = 0.6) Standard_OVERRIDE;
//! 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;
protected: protected:
Standard_EXPORT void updatePresentation(); Standard_EXPORT void updatePresentation();
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE;
//! 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

File diff suppressed because it is too large Load Diff

View File

@ -52,21 +52,20 @@ 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);
//! Returns datum display mode. //! Returns datum display mode.
Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; } Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; }
//! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively. //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively.
void SetDatumDisplayMode (Prs3d_DatumMode theMode) { myTrihDispMode = theMode; } void SetDatumDisplayMode(Prs3d_DatumMode theMode) { myTrihDispMode = theMode; }
//! Returns the right-handed coordinate system set in SetComponent. //! Returns the right-handed coordinate system set in SetComponent.
const Handle(Geom_Axis2Placement)& Component() const { return myComponent; } const Handle(Geom_Axis2Placement)& Component() const { return myComponent; }
//! Constructs the right-handed coordinate system aComponent. //! Constructs the right-handed coordinate system aComponent.
Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& theComponent); Standard_EXPORT void SetComponent(const Handle(Geom_Axis2Placement)& theComponent);
//! Returns true if the trihedron object has a size other //! Returns true if the trihedron object has a size other
//! than the default size of 100 mm. along each axis. //! than the default size of 100 mm. along each axis.
@ -76,7 +75,7 @@ public:
Standard_EXPORT Standard_Real Size() const; Standard_EXPORT Standard_Real Size() const;
//! Sets the size of trihedron object. //! Sets the size of trihedron object.
Standard_EXPORT void SetSize (const Standard_Real theValue); Standard_EXPORT void SetSize(const Standard_Real theValue);
//! Removes any non-default settings for size of this trihedron object. //! Removes any non-default settings for size of this trihedron object.
//! If the object has 1 color, the default size of the //! If the object has 1 color, the default size of the
@ -90,11 +89,10 @@ public:
Standard_EXPORT Quantity_Color TextColor() const; Standard_EXPORT Quantity_Color TextColor() const;
//! Sets color of label of trihedron axes. //! Sets color of label of trihedron axes.
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; }
@ -103,68 +101,68 @@ public:
Standard_EXPORT Quantity_Color ArrowColor() const; Standard_EXPORT Quantity_Color ArrowColor() const;
//! Sets color of arrow of trihedron axes. //! Sets color of arrow of trihedron axes.
Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor); Standard_EXPORT void SetArrowColor(const Quantity_Color& theColor);
//! Sets color of arrow of trihedron axes. //! Sets color of arrow of trihedron axes.
Standard_EXPORT void SetArrowColor (const Prs3d_DatumParts thePart, Standard_EXPORT void SetArrowColor(const Prs3d_DatumParts thePart,
const Quantity_Color& theColor); const Quantity_Color& theColor);
//! Returns color of datum part: origin or some of trihedron axes. //! Returns color of datum part: origin or some of trihedron axes.
Standard_EXPORT Quantity_Color DatumPartColor (Prs3d_DatumParts thePart); Standard_EXPORT Quantity_Color DatumPartColor(Prs3d_DatumParts thePart);
//! Sets color of datum part: origin or some of trihedron axes. //! Sets color of datum part: origin or some of trihedron axes.
//! If presentation is shading mode, this color is set for both sides of facing model //! If presentation is shading mode, this color is set for both sides of facing model
Standard_EXPORT void SetDatumPartColor (const Prs3d_DatumParts thePart, Standard_EXPORT void SetDatumPartColor(const Prs3d_DatumParts thePart,
const Quantity_Color& theColor); const Quantity_Color& theColor);
//! Sets color of origin. //! Sets color of origin.
//! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor); Standard_EXPORT void SetOriginColor(const Quantity_Color& theColor);
//! Sets color of x-axis. //! Sets color of x-axis.
//! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor); Standard_EXPORT void SetXAxisColor(const Quantity_Color& theColor);
//! Sets color of y-axis. //! Sets color of y-axis.
//! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor); Standard_EXPORT void SetYAxisColor(const Quantity_Color& theColor);
//! Sets color of z-axis. //! Sets color of z-axis.
//! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead") //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor); Standard_EXPORT void SetAxisColor(const Quantity_Color& theColor);
//! Returns true if arrows are to be drawn //! Returns true if arrows are to be drawn
Standard_EXPORT Standard_Boolean ToDrawArrows() const; Standard_EXPORT Standard_Boolean ToDrawArrows() const;
//! Sets whether to draw the arrows in visualization //! Sets whether to draw the arrows in visualization
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;
} }
//! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis
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;
//! Returns true if the display mode selected, aMode, is valid for trihedron datums. //! Returns true if the display mode selected, aMode, is valid for trihedron datums.
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;
} }
@ -173,79 +171,86 @@ 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(Prs3d_Drawer)& theStyle, const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; const Handle(Prs3d_Drawer)& theStyle,
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,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection. //! Compute selection.
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;
//! 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 Handle(SelectMgr_EntityOwner)& theOwner) const; const Prs3d_DatumParts thePart,
const Handle(SelectMgr_EntityOwner)& theOwner) const;
//! Computes presentation for display mode equal 1. //! Computes presentation for display mode equal 1.
Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT void computePresentation(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs); const Handle(Prs3d_Presentation)& thePrs);
//! Returns own datum aspect of trihedron, create this aspect if it was not created yet. //! Returns own datum aspect of trihedron, create this aspect if it was not created yet.
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
Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect, Standard_EXPORT void updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
Prs3d_DatumMode theMode, Prs3d_DatumMode theMode,
const gp_Pnt& theOrigin, const gp_Pnt& theOrigin,
const gp_Dir& theXDir, const gp_Dir& theXDir,
const gp_Dir& theYDir, const gp_Dir& theYDir,
const gp_Dir& theZDir); const gp_Dir& theZDir);
protected: protected:
Handle(Geom_Axis2Placement) myComponent; Handle(Geom_Axis2Placement) myComponent;
Prs3d_DatumMode myTrihDispMode; Prs3d_DatumMode myTrihDispMode;
Standard_Boolean myHasOwnSize; Standard_Boolean myHasOwnSize;
Standard_Boolean myHasOwnTextColor; Standard_Boolean myHasOwnTextColor;
Standard_Boolean myHasOwnArrowColor; Standard_Boolean myHasOwnArrowColor;
TCollection_ExtendedString myLabels[Prs3d_DatumParts_NB]; TCollection_ExtendedString myLabels[Prs3d_DatumParts_NB];
Standard_Integer mySelectionPriority[Prs3d_DatumParts_NB]; Standard_Integer mySelectionPriority[Prs3d_DatumParts_NB];
Handle(Graphic3d_Group) myPartToGroup[Prs3d_DatumParts_NB]; Handle(Graphic3d_Group) myPartToGroup[Prs3d_DatumParts_NB];
NCollection_List<Prs3d_DatumParts> mySelectedParts; NCollection_List<Prs3d_DatumParts> mySelectedParts;
Handle(Graphic3d_AspectLine3d) myHiddenLineAspect; Handle(Graphic3d_AspectLine3d) myHiddenLineAspect;
Handle(Graphic3d_ArrayOfPrimitives) myPrimitives[Prs3d_DatumParts_NB]; Handle(Graphic3d_ArrayOfPrimitives) myPrimitives[Prs3d_DatumParts_NB];
}; };

View File

@ -14,17 +14,17 @@
#include <AIS_TrihedronOwner.hxx> #include <AIS_TrihedronOwner.hxx>
IMPLEMENT_STANDARD_RTTIEXT (AIS_TrihedronOwner, SelectMgr_EntityOwner) IMPLEMENT_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner)
// ======================================================================= // =======================================================================
// function : AIS_TrihedronOwner // function : AIS_TrihedronOwner
// purpose : // purpose :
// ======================================================================= // =======================================================================
AIS_TrihedronOwner::AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, AIS_TrihedronOwner::AIS_TrihedronOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
const Prs3d_DatumParts thePart, const Prs3d_DatumParts thePart,
const Standard_Integer thePriority) const Standard_Integer thePriority)
: SelectMgr_EntityOwner (theSelObject, thePriority), : SelectMgr_EntityOwner(theSelObject, thePriority),
myDatumPart (thePart) myDatumPart(thePart)
{ {
} }
@ -32,40 +32,40 @@ AIS_TrihedronOwner::AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)
// function : HilightWithColor // function : HilightWithColor
// purpose : // purpose :
// ======================================================================= // =======================================================================
void AIS_TrihedronOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM, void AIS_TrihedronOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer /*theMode*/) const Standard_Integer /*theMode*/)
{ {
Selectable()->HilightOwnerWithColor (thePM, theStyle, this); Selectable()->HilightOwnerWithColor(thePM, theStyle, this);
} }
// ======================================================================= // =======================================================================
// function : IsHilighted // function : IsHilighted
// purpose : // purpose :
// ======================================================================= // =======================================================================
Standard_Boolean AIS_TrihedronOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, Standard_Boolean AIS_TrihedronOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const const Standard_Integer theMode) const
{ {
if (!HasSelectable()) if (!HasSelectable())
{ {
return Standard_False; return Standard_False;
} }
return thePM->IsHighlighted (Selectable(), theMode); return thePM->IsHighlighted(Selectable(), theMode);
} }
// ======================================================================= // =======================================================================
// function : Unhilight // function : Unhilight
// purpose : // purpose :
// ======================================================================= // =======================================================================
void AIS_TrihedronOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, void AIS_TrihedronOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const Standard_Integer theMode)
{ {
(void )theMode; (void)theMode;
if (!HasSelectable()) if (!HasSelectable())
{ {
return; return;
} }
thePM->Unhighlight (Selectable()); thePM->Unhighlight(Selectable());
} }

View File

@ -24,34 +24,34 @@ 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,
const Standard_Integer thePriority); const Standard_Integer thePriority);
//! Returns the datum part identifier. //! Returns the datum part identifier.
Prs3d_DatumParts DatumPart() const { return myDatumPart; } Prs3d_DatumParts DatumPart() const { return myDatumPart; }
//! Highlights selectable object's presentation. //! Highlights selectable object's presentation.
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM, Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle, const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! 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
const Standard_Integer theMode) const Standard_OVERRIDE; IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const Standard_OVERRIDE;
//! Removes highlighting from the owner of a detected //! Removes highlighting from the owner of a detected
//! selectable object in the presentation manager thePM. //! selectable object in the presentation manager thePM.
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, Standard_EXPORT virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
protected: protected:
Prs3d_DatumParts myDatumPart; //!< part of datum selected Prs3d_DatumParts myDatumPart; //!< part of datum selected
}; };
DEFINE_STANDARD_HANDLE (AIS_TrihedronOwner, SelectMgr_EntityOwner) DEFINE_STANDARD_HANDLE(AIS_TrihedronOwner, SelectMgr_EntityOwner)
#endif // _AIS_TrihedronOwner_HeaderFile #endif // _AIS_TrihedronOwner_HeaderFile

View File

@ -14,20 +14,21 @@
// 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>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
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
{ {
Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject) anObject =
Handle(AIS_InteractiveObject)::DownCast (anObj->Selectable()); Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable());
return ! anObject.IsNull() && anObject->Type()== myKind; return !anObject.IsNull() && anObject->Type() == myKind;
} }

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,25 +17,24 @@
#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,
AIS_TOA_Dimension, AIS_TOA_Dimension,
AIS_TOA_Wire, AIS_TOA_Wire,
AIS_TOA_Plane, AIS_TOA_Plane,
AIS_TOA_Vector, AIS_TOA_Vector,
AIS_TOA_UIso, AIS_TOA_UIso,
AIS_TOA_VIso, AIS_TOA_VIso,
AIS_TOA_Free, AIS_TOA_Free,
AIS_TOA_UnFree, AIS_TOA_UnFree,
AIS_TOA_Section, AIS_TOA_Section,
AIS_TOA_Hidden, AIS_TOA_Hidden,
AIS_TOA_Seen, AIS_TOA_Seen,
AIS_TOA_FaceBoundary, AIS_TOA_FaceBoundary,
AIS_TOA_FirstAxis, AIS_TOA_FirstAxis,
AIS_TOA_SecondAxis, AIS_TOA_SecondAxis,
AIS_TOA_ThirdAxis AIS_TOA_ThirdAxis
}; };
#endif // _AIS_TypeOfAttribute_HeaderFile #endif // _AIS_TypeOfAttribute_HeaderFile

View File

@ -20,10 +20,10 @@
//! Declares the type of axis. //! Declares the type of axis.
enum AIS_TypeOfAxis enum AIS_TypeOfAxis
{ {
AIS_TOAX_Unknown, AIS_TOAX_Unknown,
AIS_TOAX_XAxis, AIS_TOAX_XAxis,
AIS_TOAX_YAxis, AIS_TOAX_YAxis,
AIS_TOAX_ZAxis AIS_TOAX_ZAxis
}; };
#endif // _AIS_TypeOfAxis_HeaderFile #endif // _AIS_TypeOfAxis_HeaderFile

View File

@ -20,9 +20,9 @@
//! Declares the type of isoparameter displayed. //! Declares the type of isoparameter displayed.
enum AIS_TypeOfIso enum AIS_TypeOfIso
{ {
AIS_TOI_IsoU, AIS_TOI_IsoU,
AIS_TOI_IsoV, AIS_TOI_IsoV,
AIS_TOI_Both AIS_TOI_Both
}; };
#endif // _AIS_TypeOfIso_HeaderFile #endif // _AIS_TypeOfIso_HeaderFile

View File

@ -20,10 +20,10 @@
//! Declares the type of plane. //! Declares the type of plane.
enum AIS_TypeOfPlane enum AIS_TypeOfPlane
{ {
AIS_TOPL_Unknown, AIS_TOPL_Unknown,
AIS_TOPL_XYPlane, AIS_TOPL_XYPlane,
AIS_TOPL_XZPlane, AIS_TOPL_XZPlane,
AIS_TOPL_YZPlane AIS_TOPL_YZPlane
}; };
#endif // _AIS_TypeOfPlane_HeaderFile #endif // _AIS_TypeOfPlane_HeaderFile

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