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:
parent
dbba6f1289
commit
a5a7b3185b
@ -30,11 +30,12 @@ PackConstructorInitializers: Never
|
||||
PointerAlignment: Left
|
||||
ReferenceAlignment: Left
|
||||
SeparateDefinitionBlocks: Always
|
||||
SortIncludes: true
|
||||
SortIncludes: false
|
||||
UseTab: Never
|
||||
#
|
||||
# OCCT specific settings
|
||||
StatementMacros:
|
||||
- Standard_FALLTHROUGH
|
||||
- Standard_DEPRECATED
|
||||
TypenameMacros:
|
||||
- Handle
|
||||
|
84
.github/workflows/clang-format-check.yml
vendored
Normal file
84
.github/workflows/clang-format-check.yml
vendored
Normal 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
|
@ -21,58 +21,64 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
//! Application Interactive Services provide the means to create links between an application GUI viewer and
|
||||
//! the packages which are used to manage selection and presentation.
|
||||
//! The tools AIS defined in order to do this include different sorts of entities:
|
||||
//! both the selectable viewable objects themselves and the context and attribute managers to define their selection and display.
|
||||
//! To orient the user as he works in a modeling environment, views and selections must be comprehensible.
|
||||
//! There must be several different sorts of selectable and viewable object defined.
|
||||
//! These must also be interactive, that is, connecting graphic representation and the underlying reference geometry.
|
||||
//! These entities are called Interactive Objects, and are divided into four types:
|
||||
//! Application Interactive Services provide the means to create links between an application GUI
|
||||
//! viewer and the packages which are used to manage selection and presentation. The tools AIS
|
||||
//! defined in order to do this include different sorts of entities: both the selectable viewable
|
||||
//! objects themselves and the context and attribute managers to define their selection and display.
|
||||
//! To orient the user as he works in a modeling environment, views and selections must be
|
||||
//! comprehensible. There must be several different sorts of selectable and viewable object defined.
|
||||
//! These must also be interactive, that is, connecting graphic representation and the underlying
|
||||
//! reference geometry. These entities are called Interactive Objects, and are divided into four
|
||||
//! types:
|
||||
//! - the Datum
|
||||
//! - the Relation
|
||||
//! - the Object
|
||||
//! - None.
|
||||
//! The Datum groups together the construction elements such as lines, circles, points, trihedra, plane trihedra, planes and axes.
|
||||
//! The Relation is made up of constraints on one or more interactive shapes and the corresponding reference geometry.
|
||||
//! For example, you might want to constrain two edges in a parallel relation.
|
||||
//! This constraint is considered as an object in its own right, and is shown as a sensitive primitive.
|
||||
//! This takes the graphic form of a perpendicular arrow marked with the || symbol and lying between the two edges.
|
||||
//! The Object type includes topological shapes, and connections between shapes.
|
||||
//! None, in order not to eliminate the object, tells the application to look further until it finds an object definition in its generation which is accepted.
|
||||
//! Inside these categories, you have the possibility of an additional characterization by means of a signature.
|
||||
//! The signature provides an index to the further characterization.
|
||||
//! By default, the Interactive Object has a None type and a signature of 0 (equivalent to None.)
|
||||
//! If you want to give a particular type and signature to your interactive object, you must redefine the two virtual methods: Type and Signature.
|
||||
//! In the C++ inheritance structure of the package, each class representing a specific Interactive Object inherits AIS_InteractiveObject.
|
||||
//! Among these inheriting classes, AIS_Relation functions as the abstract mother class for tinheriting classes defining display of specific relational constraints and types of dimension.
|
||||
//! Some of these include:
|
||||
//! - display of constraints based on relations of symmetry, tangency, parallelism and concentricity
|
||||
//! The Datum groups together the construction elements such as lines, circles, points, trihedra,
|
||||
//! plane trihedra, planes and axes. The Relation is made up of constraints on one or more
|
||||
//! interactive shapes and the corresponding reference geometry. For example, you might want to
|
||||
//! constrain two edges in a parallel relation. This constraint is considered as an object in its
|
||||
//! own right, and is shown as a sensitive primitive. This takes the graphic form of a perpendicular
|
||||
//! arrow marked with the || symbol and lying between the two edges. The Object type includes
|
||||
//! topological shapes, and connections between shapes. None, in order not to eliminate the object,
|
||||
//! tells the application to look further until it finds an object definition in its generation
|
||||
//! which is accepted. Inside these categories, you have the possibility of an additional
|
||||
//! characterization by means of a signature. The signature provides an index to the further
|
||||
//! characterization. By default, the Interactive Object has a None type and a signature of 0
|
||||
//! (equivalent to None.) If you want to give a particular type and signature to your interactive
|
||||
//! object, you must redefine the two virtual methods: Type and Signature. In the C++ inheritance
|
||||
//! structure of the package, each class representing a specific Interactive Object inherits
|
||||
//! AIS_InteractiveObject. Among these inheriting classes, AIS_Relation functions as the abstract
|
||||
//! mother class for tinheriting classes defining display of specific relational constraints and
|
||||
//! types of dimension. Some of these include:
|
||||
//! - display of constraints based on relations of symmetry, tangency, parallelism and
|
||||
//! concentricity
|
||||
//! - display of dimensions for angles, offsets, diameters, radii and chamfers.
|
||||
//! No viewer can show everything at once with any coherence or clarity.
|
||||
//! Views must be managed carefully both sequentially and at any given instant.
|
||||
//! Another function of the view is that of a context to carry out design in.
|
||||
//! The design changes are applied to the objects in the view and then extended to the underlying reference geometry by a solver.
|
||||
//! To make sense of this complicated visual data, several display and selection tools are required.
|
||||
//! To facilitate management, each object and each construction element has a selection priority.
|
||||
//! There are also means to modify the default priority.
|
||||
//! To define an environment of dynamic detection, you can use standard filter classes or create your own.
|
||||
//! A filter questions the owner of the sensitive primitive to determine if it has the desired qualities.
|
||||
//! If it answers positively, it is kept. If not, it is rejected.
|
||||
//! The standard filters supplied in AIS include:
|
||||
//! The design changes are applied to the objects in the view and then extended to the underlying
|
||||
//! reference geometry by a solver. To make sense of this complicated visual data, several display
|
||||
//! and selection tools are required. To facilitate management, each object and each construction
|
||||
//! element has a selection priority. There are also means to modify the default priority. To define
|
||||
//! an environment of dynamic detection, you can use standard filter classes or create your own. A
|
||||
//! filter questions the owner of the sensitive primitive to determine if it has the desired
|
||||
//! qualities. If it answers positively, it is kept. If not, it is rejected. The standard filters
|
||||
//! supplied in AIS include:
|
||||
//! - AIS_AttributeFilter
|
||||
//! - AIS_SignatureFilter
|
||||
//! - AIS_TypeFilter.
|
||||
//! A set of functions allows you to choose the interactive objects which you want to act on, the selection modes which you want to activate.
|
||||
//! An interactive object can have a certain number of graphic attributes which are specific to it, such as visualization mode, color, and material.
|
||||
//! By the same token, the interactive context has a set of graphic attributes, the Drawer which is valid by default for the objects it controls.
|
||||
//! When an interactive object is visualized, the required graphic attributes are first taken from the object's own Drawer if one exists, or from the context drawer for the others.
|
||||
class AIS
|
||||
//! A set of functions allows you to choose the interactive objects which you want to act on, the
|
||||
//! selection modes which you want to activate. An interactive object can have a certain number of
|
||||
//! graphic attributes which are specific to it, such as visualization mode, color, and material. By
|
||||
//! the same token, the interactive context has a set of graphic attributes, the Drawer which is
|
||||
//! valid by default for the objects it controls. When an interactive object is visualized, the
|
||||
//! required graphic attributes are first taken from the object's own Drawer if one exists, or from
|
||||
//! the context drawer for the others.
|
||||
class AIS
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_HeaderFile
|
||||
|
@ -18,51 +18,44 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
|
||||
|
||||
//=============================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
AIS_Animation::AIS_Animation (const TCollection_AsciiString& theAnimationName)
|
||||
: myName (theAnimationName),
|
||||
myState (AnimationState_Stopped),
|
||||
myPtsStart (0.0),
|
||||
myOwnDuration (0.0),
|
||||
myChildrenDuration (0.0)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Animation::AIS_Animation(const TCollection_AsciiString& theAnimationName)
|
||||
: myName(theAnimationName),
|
||||
myState(AnimationState_Stopped),
|
||||
myPtsStart(0.0),
|
||||
myOwnDuration(0.0),
|
||||
myChildrenDuration(0.0)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ~AIS_Animation
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Animation::~AIS_Animation()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::Clear()
|
||||
{
|
||||
myAnimations.Clear();
|
||||
myOwnDuration = 0.0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::Add(const Handle(AIS_Animation)& theAnimation)
|
||||
{
|
||||
if (theAnimation.IsNull())
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -71,17 +64,16 @@ void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
|
||||
}
|
||||
}
|
||||
|
||||
myAnimations.Append (theAnimation);
|
||||
myAnimations.Append(theAnimation);
|
||||
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)
|
||||
{
|
||||
@ -91,17 +83,16 @@ Handle(AIS_Animation) AIS_Animation::Find (const TCollection_AsciiString& theAni
|
||||
return Handle(AIS_Animation)();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Remove
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean AIS_Animation::Remove (const Handle(AIS_Animation)& theAnimation)
|
||||
//=================================================================================================
|
||||
|
||||
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)
|
||||
{
|
||||
myAnimations.Remove (anIter);
|
||||
myAnimations.Remove(anIter);
|
||||
UpdateTotalDuration();
|
||||
return Standard_True;
|
||||
}
|
||||
@ -109,14 +100,13 @@ Standard_Boolean AIS_Animation::Remove (const Handle(AIS_Animation)& theAnimatio
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Replace
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean AIS_Animation::Replace (const Handle(AIS_Animation)& theAnimationOld,
|
||||
const Handle(AIS_Animation)& theAnimationNew)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_Animation::Replace(const Handle(AIS_Animation)& theAnimationOld,
|
||||
const Handle(AIS_Animation)& theAnimationNew)
|
||||
{
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
if (anIter.Value() == theAnimationOld)
|
||||
{
|
||||
@ -128,63 +118,59 @@ Standard_Boolean AIS_Animation::Replace (const Handle(AIS_Animation)& theAnimati
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : CopyFrom
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void AIS_Animation::CopyFrom (const Handle(AIS_Animation)& theOther)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::CopyFrom(const Handle(AIS_Animation)& theOther)
|
||||
{
|
||||
myAnimations.Clear();
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (theOther->myAnimations); anIter.More(); anIter.Next())
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(theOther->myAnimations);
|
||||
anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
myAnimations.Append (anIter.Value());
|
||||
myAnimations.Append(anIter.Value());
|
||||
}
|
||||
UpdateTotalDuration();
|
||||
myPtsStart = theOther->myPtsStart;
|
||||
myOwnDuration = theOther->myOwnDuration;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : UpdateTotalDuration
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::UpdateTotalDuration()
|
||||
{
|
||||
myChildrenDuration = 0.0;
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
myChildrenDuration = Max (myChildrenDuration, anIter.Value()->StartPts() + anIter.Value()->Duration());
|
||||
myChildrenDuration =
|
||||
Max(myChildrenDuration, anIter.Value()->StartPts() + anIter.Value()->Duration());
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : StartTimer
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void AIS_Animation::StartTimer (const Standard_Real theStartPts,
|
||||
const Standard_Real thePlaySpeed,
|
||||
const Standard_Boolean theToUpdate,
|
||||
const Standard_Boolean theToStopTimer)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::StartTimer(const Standard_Real theStartPts,
|
||||
const Standard_Real thePlaySpeed,
|
||||
const Standard_Boolean theToUpdate,
|
||||
const Standard_Boolean theToStopTimer)
|
||||
{
|
||||
if (myTimer.IsNull())
|
||||
{
|
||||
myTimer = new Media_Timer();
|
||||
}
|
||||
myTimer->Stop();
|
||||
myTimer->Seek (theStartPts);
|
||||
myTimer->SetPlaybackSpeed (thePlaySpeed);
|
||||
Start (theToUpdate);
|
||||
myTimer->Seek(theStartPts);
|
||||
myTimer->SetPlaybackSpeed(thePlaySpeed);
|
||||
Start(theToUpdate);
|
||||
if (theToStopTimer)
|
||||
{
|
||||
myTimer->Stop();
|
||||
myTimer->Seek (theStartPts);
|
||||
myTimer->Seek(theStartPts);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : UpdateTimer
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Real AIS_Animation::UpdateTimer()
|
||||
{
|
||||
if (myTimer.IsNull())
|
||||
@ -193,29 +179,26 @@ Standard_Real AIS_Animation::UpdateTimer()
|
||||
}
|
||||
|
||||
const Standard_Real anElapsedTime = myTimer->ElapsedTime();
|
||||
Update (anElapsedTime);
|
||||
Update(anElapsedTime);
|
||||
return anElapsedTime;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Start
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void AIS_Animation::Start (const Standard_Boolean theToUpdate)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::Start(const Standard_Boolean theToUpdate)
|
||||
{
|
||||
UpdateTotalDuration();
|
||||
myState = AnimationState_Started;
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
anIter.ChangeValue()->Start (Standard_False);
|
||||
anIter.ChangeValue()->Start(Standard_False);
|
||||
}
|
||||
|
||||
if (theToUpdate)
|
||||
{
|
||||
const Standard_Real anElapsedTime = !myTimer.IsNull()
|
||||
? myTimer->ElapsedTime()
|
||||
: 0.0;
|
||||
Update (anElapsedTime);
|
||||
const Standard_Real anElapsedTime = !myTimer.IsNull() ? myTimer->ElapsedTime() : 0.0;
|
||||
Update(anElapsedTime);
|
||||
}
|
||||
|
||||
if (!myTimer.IsNull())
|
||||
@ -224,10 +207,8 @@ void AIS_Animation::Start (const Standard_Boolean theToUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Pause
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::Pause()
|
||||
{
|
||||
myState = AnimationState_Paused;
|
||||
@ -236,16 +217,15 @@ void AIS_Animation::Pause()
|
||||
myTimer->Pause();
|
||||
}
|
||||
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
anIter.ChangeValue()->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Stop
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::Stop()
|
||||
{
|
||||
myState = AnimationState_Stopped;
|
||||
@ -253,56 +233,50 @@ void AIS_Animation::Stop()
|
||||
{
|
||||
const Standard_Real anElapsedTime = ElapsedTime();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : Update
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
Standard_Boolean AIS_Animation::Update (const Standard_Real thePts)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_Animation::Update(const Standard_Real thePts)
|
||||
{
|
||||
AIS_AnimationProgress aPosition;
|
||||
aPosition.Pts = thePts;
|
||||
aPosition.LocalPts = thePts - myPtsStart;
|
||||
aPosition.LocalNormalized = HasOwnDuration()
|
||||
? (aPosition.LocalPts / myOwnDuration)
|
||||
: 0.0;
|
||||
aPosition.LocalNormalized = Max (0.0, aPosition.LocalNormalized);
|
||||
aPosition.LocalNormalized = Min (1.0, aPosition.LocalNormalized);
|
||||
updateWithChildren (aPosition);
|
||||
aPosition.LocalNormalized = HasOwnDuration() ? (aPosition.LocalPts / myOwnDuration) : 0.0;
|
||||
aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
|
||||
aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
|
||||
updateWithChildren(aPosition);
|
||||
return thePts < myPtsStart + Duration();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : updateWithChildren
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void AIS_Animation::updateWithChildren (const AIS_AnimationProgress& thePosition)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Animation::updateWithChildren(const AIS_AnimationProgress& thePosition)
|
||||
{
|
||||
if (thePosition.LocalPts < 0.0
|
||||
|| IsStopped())
|
||||
if (thePosition.LocalPts < 0.0 || IsStopped())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
const Handle(AIS_Animation)& anAnim = anIter.Value();
|
||||
AIS_AnimationProgress aPosition = thePosition;
|
||||
aPosition.LocalPts = aPosition.LocalPts - anAnim->StartPts();
|
||||
aPosition.LocalNormalized = anAnim->HasOwnDuration()
|
||||
? (aPosition.LocalPts / anAnim->OwnDuration())
|
||||
: 0.0;
|
||||
aPosition.LocalNormalized = Max (0.0, aPosition.LocalNormalized);
|
||||
aPosition.LocalNormalized = Min (1.0, aPosition.LocalNormalized);
|
||||
anAnim->updateWithChildren (aPosition);
|
||||
const Handle(AIS_Animation)& anAnim = anIter.Value();
|
||||
AIS_AnimationProgress aPosition = thePosition;
|
||||
aPosition.LocalPts = aPosition.LocalPts - anAnim->StartPts();
|
||||
aPosition.LocalNormalized =
|
||||
anAnim->HasOwnDuration() ? (aPosition.LocalPts / anAnim->OwnDuration()) : 0.0;
|
||||
aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
|
||||
aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
|
||||
anAnim->updateWithChildren(aPosition);
|
||||
}
|
||||
|
||||
if (thePosition.LocalPts >= Duration())
|
||||
@ -310,5 +284,5 @@ void AIS_Animation::updateWithChildren (const AIS_AnimationProgress& thePosition
|
||||
Stop();
|
||||
}
|
||||
|
||||
update (thePosition);
|
||||
update(thePosition);
|
||||
}
|
||||
|
@ -22,13 +22,18 @@
|
||||
//! Structure defining current animation progress.
|
||||
struct AIS_AnimationProgress
|
||||
{
|
||||
Standard_Real Pts; //!< global presentation timestamp
|
||||
Standard_Real LocalPts; //!< presentation within current animation
|
||||
// clang-format off
|
||||
Standard_Real Pts; //!< global presentation timestamp
|
||||
Standard_Real LocalPts; //!< presentation within current animation
|
||||
// clang-format off
|
||||
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)
|
||||
@ -38,38 +43,43 @@ DEFINE_STANDARD_HANDLE(AIS_Animation, Standard_Transient)
|
||||
//!
|
||||
//! - Animation Implementor
|
||||
//! Sub-classes should override method AIS_Animation::update() to perform specific animation.
|
||||
//! AIS package provides limited number of such animation atoms - classes AIS_AnimationObject and AIS_AnimationCamera, which could be enough for defining a simple animation.
|
||||
//! In general case, application is expected defining own AIS_Animation sub-classes implementing application-specific animation logic
|
||||
//! (e.g. another interpolation or another kind of transformations - like color transition and others).
|
||||
//! The basic conception of AIS_Animation::update() is defining an exact scene state for the current presentation timestamp,
|
||||
//! providing a smooth and continuous animation well defined at any time step and in any direction.
|
||||
//! So that a time difference between two sequential drawn Viewer frames can vary from frame to frame without visual artifacts,
|
||||
//! increasing rendering framerate would not lead to animation being executed too fast
|
||||
//! and low framerate (on slow hardware) would not lead to animation played longer than defined duration.
|
||||
//! Hence, implementation should avoid usage of incremental step logic or should apply it very carefully.
|
||||
//! AIS package provides limited number of such animation atoms - classes AIS_AnimationObject and
|
||||
//! AIS_AnimationCamera, which could be enough for defining a simple animation. In general case,
|
||||
//! application is expected defining own AIS_Animation sub-classes implementing
|
||||
//! application-specific animation logic (e.g. another interpolation or another kind of
|
||||
//! transformations - like color transition and others). The basic conception of
|
||||
//! AIS_Animation::update() is defining an exact scene state for the current presentation
|
||||
//! timestamp, providing a smooth and continuous animation well defined at any time step and in
|
||||
//! any direction. So that a time difference between two sequential drawn Viewer frames can vary
|
||||
//! from frame to frame without visual artifacts, increasing rendering framerate would not lead to
|
||||
//! animation being executed too fast and low framerate (on slow hardware) would not lead to
|
||||
//! animation played longer than defined duration. Hence, implementation should avoid usage of
|
||||
//! incremental step logic or should apply it very carefully.
|
||||
//!
|
||||
//! - Animation Container
|
||||
//! AIS_Animation (no sub-classing) can be used to aggregate a sequence of Animation items (children).
|
||||
//! Each children should be defined with its own duration and start time (presentation timestamp).
|
||||
//! It is possible defining collection of nested AIS_Animation items, so that within each container level
|
||||
//! children define start playback time relative to its holder.
|
||||
//! AIS_Animation (no sub-classing) can be used to aggregate a sequence of Animation items
|
||||
//! (children). Each children should be defined with its own duration and start time (presentation
|
||||
//! timestamp). It is possible defining collection of nested AIS_Animation items, so that within
|
||||
//! each container level children define start playback time relative to its holder.
|
||||
//!
|
||||
//! - Animation playback Controller
|
||||
//! It is suggested that application would define a single AIS_Animation instance (optional sub-classing) for controlling animation playback as whole.
|
||||
//! Such controller should be filled in by other AIS_Animation as children objects,
|
||||
//! and will be managed by application by calling StartTimer(), UpdateTimer() and IsStopped() methods.
|
||||
//! It is suggested that application would define a single AIS_Animation instance (optional
|
||||
//! sub-classing) for controlling animation playback as whole. Such controller should be filled in
|
||||
//! by other AIS_Animation as children objects, and will be managed by application by calling
|
||||
//! StartTimer(), UpdateTimer() and IsStopped() methods.
|
||||
//!
|
||||
//! Note, that AIS_Animation::StartTimer() defines a timer calculating an elapsed time, not a multimedia timer executing Viewer updates at specific intervals!
|
||||
//! Application should avoid using implicit and immediate Viewer updates to ensure that AIS_Animation::UpdateTimer() is called before each redrawing of a Viewer content.
|
||||
//! Redrawing logic should be also managed at application level for managing a smooth animation
|
||||
//! (by defining a multimedia timer provided by used GUI framework executing updates at desired framerate, or as continuous redraws in loop).
|
||||
//! Note, that AIS_Animation::StartTimer() defines a timer calculating an elapsed time, not a
|
||||
//! multimedia timer executing Viewer updates at specific intervals! Application should avoid using
|
||||
//! implicit and immediate Viewer updates to ensure that AIS_Animation::UpdateTimer() is called
|
||||
//! before each redrawing of a Viewer content. Redrawing logic should be also managed at application
|
||||
//! level for managing a smooth animation (by defining a multimedia timer provided by used GUI
|
||||
//! framework executing updates at desired framerate, or as continuous redraws in loop).
|
||||
class AIS_Animation : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Creates empty animation.
|
||||
Standard_EXPORT AIS_Animation (const TCollection_AsciiString& theAnimationName);
|
||||
Standard_EXPORT AIS_Animation(const TCollection_AsciiString& theAnimationName);
|
||||
|
||||
//! Destruct object, clear arguments
|
||||
Standard_EXPORT virtual ~AIS_Animation();
|
||||
@ -78,15 +88,14 @@ public:
|
||||
const TCollection_AsciiString& Name() const { return myName; }
|
||||
|
||||
public:
|
||||
|
||||
//! @return start time of the animation in the timeline
|
||||
Standard_Real StartPts() const { return myPtsStart; }
|
||||
|
||||
//! 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
|
||||
Standard_Real Duration() const { return Max (myOwnDuration, myChildrenDuration); }
|
||||
Standard_Real Duration() const { return Max(myOwnDuration, myChildrenDuration); }
|
||||
|
||||
//! Update total duration considering all animations on timeline.
|
||||
Standard_EXPORT void UpdateTotalDuration();
|
||||
@ -98,49 +107,50 @@ public:
|
||||
Standard_Real OwnDuration() const { return myOwnDuration; }
|
||||
|
||||
//! 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.
|
||||
//! @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.
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT Standard_Boolean Remove (const Handle(AIS_Animation)& theAnimation);
|
||||
Standard_EXPORT Standard_Boolean Remove(const Handle(AIS_Animation)& theAnimation);
|
||||
|
||||
//! Replace the child animation.
|
||||
Standard_EXPORT Standard_Boolean Replace (const Handle(AIS_Animation)& theAnimationOld,
|
||||
const Handle(AIS_Animation)& theAnimationNew);
|
||||
Standard_EXPORT Standard_Boolean Replace(const Handle(AIS_Animation)& theAnimationOld,
|
||||
const Handle(AIS_Animation)& theAnimationNew);
|
||||
|
||||
//! Clears own children and then copy child animations from another object.
|
||||
//! 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.
|
||||
const NCollection_Sequence<Handle(AIS_Animation)>& Children() const { return myAnimations; }
|
||||
|
||||
public:
|
||||
|
||||
//! Start animation with internally defined timer instance.
|
||||
//! Calls ::Start() internally.
|
||||
//!
|
||||
//! Note, that this method initializes a timer calculating an elapsed time (presentation timestamps within AIS_Animation::UpdateTimer()),
|
||||
//! not a multimedia timer executing Viewer updates at specific intervals!
|
||||
//! Viewer redrawing should be managed at application level, so that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer content.
|
||||
//! Note, that this method initializes a timer calculating an elapsed time (presentation
|
||||
//! timestamps within AIS_Animation::UpdateTimer()), not a multimedia timer executing Viewer
|
||||
//! updates at specific intervals! Viewer redrawing should be managed at application level, so
|
||||
//! that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer
|
||||
//! content.
|
||||
//!
|
||||
//! @param theStartPts starting timer position (presentation timestamp)
|
||||
//! @param thePlaySpeed playback speed (1.0 means normal speed)
|
||||
//! @param theToUpdate flag to update defined animations to specified start position
|
||||
//! @param theToStopTimer flag to pause timer at the starting position
|
||||
Standard_EXPORT virtual void StartTimer (const Standard_Real theStartPts,
|
||||
const Standard_Real thePlaySpeed,
|
||||
const Standard_Boolean theToUpdate,
|
||||
const Standard_Boolean theToStopTimer = Standard_False);
|
||||
Standard_EXPORT virtual void StartTimer(const Standard_Real theStartPts,
|
||||
const Standard_Real thePlaySpeed,
|
||||
const Standard_Boolean theToUpdate,
|
||||
const Standard_Boolean theToStopTimer = Standard_False);
|
||||
|
||||
//! Update single frame of animation, update timer state
|
||||
//! @return current time of timeline progress.
|
||||
@ -153,14 +163,13 @@ public:
|
||||
const Handle(Media_Timer)& Timer() const { return myTimer; }
|
||||
|
||||
//! Set playback timer.
|
||||
void SetTimer (const Handle(Media_Timer)& theTimer) { myTimer = theTimer; }
|
||||
void SetTimer(const Handle(Media_Timer)& theTimer) { myTimer = theTimer; }
|
||||
|
||||
public:
|
||||
|
||||
//! Start animation. This method changes status of the animation to Started.
|
||||
//! This status defines whether animation is to be performed in the timeline or not.
|
||||
//! @param theToUpdate call Update() method
|
||||
Standard_EXPORT virtual void Start (const Standard_Boolean theToUpdate);
|
||||
Standard_EXPORT virtual void Start(const Standard_Boolean theToUpdate);
|
||||
|
||||
//! Pause the process timeline.
|
||||
Standard_EXPORT virtual void Pause();
|
||||
@ -176,19 +185,17 @@ public:
|
||||
//! Update single frame of animation, update timer state
|
||||
//! @param[in] thePts the time moment within [0; Duration()]
|
||||
//! @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:
|
||||
|
||||
//! Process one step of the animation according to the input time progress, including all children.
|
||||
//! Calls also ::update() to update own animation.
|
||||
Standard_EXPORT virtual void updateWithChildren (const AIS_AnimationProgress& thePosition);
|
||||
//! Process one step of the animation according to the input time progress, including all
|
||||
//! children. Calls also ::update() to update own animation.
|
||||
Standard_EXPORT virtual void updateWithChildren(const AIS_AnimationProgress& thePosition);
|
||||
|
||||
//! Update the own animation to specified position - should be overridden by sub-class.
|
||||
virtual void update (const AIS_AnimationProgress& theProgress) { (void )theProgress; }
|
||||
virtual void update(const AIS_AnimationProgress& theProgress) { (void)theProgress; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Defines animation state.
|
||||
enum AnimationState
|
||||
{
|
||||
@ -198,18 +205,15 @@ protected:
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Media_Timer) myTimer;
|
||||
|
||||
TCollection_AsciiString myName; //!< animation name
|
||||
NCollection_Sequence<Handle(AIS_Animation)>
|
||||
myAnimations; //!< sequence of child animations
|
||||
|
||||
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
|
||||
TCollection_AsciiString myName; //!< animation name
|
||||
NCollection_Sequence<Handle(AIS_Animation)> myAnimations; //!< sequence of child animations
|
||||
|
||||
AnimationState myState; //!< animation state - started, stopped of paused
|
||||
Standard_Real myPtsStart; //!< time of start in the timeline
|
||||
Standard_Real myOwnDuration; //!< duration of animation excluding children
|
||||
Standard_Real myChildrenDuration; //!< duration of animation including children
|
||||
};
|
||||
|
||||
#endif // _AIS_Animation_HeaderFile
|
||||
|
@ -15,37 +15,35 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
|
||||
|
||||
//=============================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Ax1& theAxis,
|
||||
const Standard_Real theAngleStart,
|
||||
const Standard_Real theAngleEnd)
|
||||
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject),
|
||||
myRotAxis (theAxis),
|
||||
myAngleStart (theAngleStart),
|
||||
myAngleEnd (theAngleEnd)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation(
|
||||
const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Ax1& theAxis,
|
||||
const Standard_Real theAngleStart,
|
||||
const Standard_Real theAngleEnd)
|
||||
: AIS_BaseAnimationObject(theAnimationName, theContext, theObject),
|
||||
myRotAxis(theAxis),
|
||||
myAngleStart(theAngleStart),
|
||||
myAngleEnd(theAngleEnd)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : update
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void AIS_AnimationAxisRotation::update (const AIS_AnimationProgress& theProgress)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_AnimationAxisRotation::update(const AIS_AnimationProgress& theProgress)
|
||||
{
|
||||
if (myObject.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf;
|
||||
Standard_Real aCurrentAngle = (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
|
||||
aTrsf.SetRotation (myRotAxis, aCurrentAngle);
|
||||
updateTrsf (aTrsf);
|
||||
gp_Trsf aTrsf;
|
||||
Standard_Real aCurrentAngle =
|
||||
(1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
|
||||
aTrsf.SetRotation(myRotAxis, aCurrentAngle);
|
||||
updateTrsf(aTrsf);
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ class AIS_AnimationAxisRotation : public AIS_BaseAnimationObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
|
||||
public:
|
||||
|
||||
//! Constructor with initialization.
|
||||
//! @param[in] theAnimationName animation identifier
|
||||
//! @param[in] theContext interactive context where object have been displayed
|
||||
@ -30,24 +29,21 @@ public:
|
||||
//! @param[in] theAxis rotation axis
|
||||
//! @param[in] theAngleStart rotation angle at the start of animation
|
||||
//! @param[in] theAngleEnd rotation angle at the end of animation
|
||||
Standard_EXPORT AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Ax1& theAxis,
|
||||
const Standard_Real theAngleStart,
|
||||
const Standard_Real theAngleEnd);
|
||||
Standard_EXPORT AIS_AnimationAxisRotation(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Ax1& theAxis,
|
||||
const Standard_Real theAngleStart,
|
||||
const Standard_Real theAngleEnd);
|
||||
|
||||
protected:
|
||||
|
||||
//! 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:
|
||||
|
||||
gp_Ax1 myRotAxis; //!< rotation axis
|
||||
Standard_Real myAngleStart; //!< start angle for rotation
|
||||
Standard_Real myAngleEnd; //!< end angle for rotation
|
||||
|
||||
gp_Ax1 myRotAxis; //!< rotation axis
|
||||
Standard_Real myAngleStart; //!< start angle for rotation
|
||||
Standard_Real myAngleEnd; //!< end angle for rotation
|
||||
};
|
||||
|
||||
#endif // _AIS_AnimationAxisRotation_HeaderFile
|
||||
|
@ -18,38 +18,32 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
|
||||
|
||||
//=============================================================================
|
||||
//function : AIS_AnimationCamera
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
AIS_AnimationCamera::AIS_AnimationCamera (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(V3d_View)& theView)
|
||||
: AIS_Animation (theAnimationName),
|
||||
myView (theView)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_AnimationCamera::AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(V3d_View)& 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()
|
||||
|| myCamStart.IsNull()
|
||||
|| myCamEnd.IsNull())
|
||||
if (myView.IsNull() || myCamStart.IsNull() || myCamEnd.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Camera) aCamera = myView->Camera();
|
||||
|
||||
Graphic3d_CameraLerp aCamLerp (myCamStart, myCamEnd);
|
||||
aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
|
||||
Graphic3d_CameraLerp aCamLerp(myCamStart, myCamEnd);
|
||||
aCamLerp.Interpolate(HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
|
||||
|
||||
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False);
|
||||
myView->SetCamera (aCamera);
|
||||
myView->SetImmediateUpdate (aPrevImmUpdate);
|
||||
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate(Standard_False);
|
||||
myView->SetCamera(aCamera);
|
||||
myView->SetImmediateUpdate(aPrevImmUpdate);
|
||||
myView->Invalidate();
|
||||
}
|
||||
|
@ -25,40 +25,39 @@ class AIS_AnimationCamera : public AIS_Animation
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT AIS_AnimationCamera (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(V3d_View)& theView);
|
||||
Standard_EXPORT AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Return the target view.
|
||||
const Handle(V3d_View)& View() const { return myView; }
|
||||
|
||||
//! 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.
|
||||
const Handle(Graphic3d_Camera)& CameraStart() const { return myCamStart; }
|
||||
|
||||
//! Define camera start position.
|
||||
void SetCameraStart (const Handle(Graphic3d_Camera)& theCameraStart) { myCamStart = theCameraStart; }
|
||||
void SetCameraStart(const Handle(Graphic3d_Camera)& theCameraStart)
|
||||
{
|
||||
myCamStart = theCameraStart;
|
||||
}
|
||||
|
||||
//! Return camera end position.
|
||||
const Handle(Graphic3d_Camera)& CameraEnd() const { return myCamEnd; }
|
||||
|
||||
//! Define camera end position.
|
||||
void SetCameraEnd (const Handle(Graphic3d_Camera)& theCameraEnd) { myCamEnd = theCameraEnd; }
|
||||
void SetCameraEnd(const Handle(Graphic3d_Camera)& theCameraEnd) { myCamEnd = theCameraEnd; }
|
||||
|
||||
protected:
|
||||
|
||||
//! 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:
|
||||
|
||||
Handle(V3d_View) myView; //!< view to setup camera
|
||||
Handle(Graphic3d_Camera) myCamStart; //!< starting camera position
|
||||
Handle(Graphic3d_Camera) myCamEnd; //!< end camera position
|
||||
|
||||
Handle(V3d_View) myView; //!< view to setup camera
|
||||
Handle(Graphic3d_Camera) myCamStart; //!< starting camera position
|
||||
Handle(Graphic3d_Camera) myCamEnd; //!< end camera position
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_AnimationCamera, AIS_Animation)
|
||||
|
@ -16,26 +16,22 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
|
||||
|
||||
//=============================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
AIS_AnimationObject::AIS_AnimationObject (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Trsf& theTrsfStart,
|
||||
const gp_Trsf& theTrsfEnd)
|
||||
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject),
|
||||
myTrsfLerp (theTrsfStart, theTrsfEnd)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_AnimationObject::AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Trsf& theTrsfStart,
|
||||
const gp_Trsf& 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())
|
||||
{
|
||||
@ -43,6 +39,6 @@ void AIS_AnimationObject::update (const AIS_AnimationProgress& theProgress)
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf;
|
||||
myTrsfLerp.Interpolate (theProgress.LocalNormalized, aTrsf);
|
||||
updateTrsf (aTrsf);
|
||||
myTrsfLerp.Interpolate(theProgress.LocalNormalized, aTrsf);
|
||||
updateTrsf(aTrsf);
|
||||
}
|
||||
|
@ -23,30 +23,27 @@ class AIS_AnimationObject : public AIS_BaseAnimationObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
|
||||
public:
|
||||
|
||||
//! Constructor with initialization.
|
||||
//! Note that start/end transformations specify exactly local transformation of the object,
|
||||
//! not the transformation to be applied to existing local transformation.
|
||||
//! @param[in] theAnimationName animation identifier
|
||||
//! @param[in] theContext interactive context where object have been displayed
|
||||
//! @param[in] theObject object to apply local transformation
|
||||
//! @param[in] theTrsfStart local transformation at the start of animation (e.g. theObject->LocalTransformation())
|
||||
//! @param[in] theTrsfStart local transformation at the start of animation (e.g.
|
||||
//! theObject->LocalTransformation())
|
||||
//! @param[in] theTrsfEnd local transformation at the end of animation
|
||||
Standard_EXPORT AIS_AnimationObject (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Trsf& theTrsfStart,
|
||||
const gp_Trsf& theTrsfEnd);
|
||||
Standard_EXPORT AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject,
|
||||
const gp_Trsf& theTrsfStart,
|
||||
const gp_Trsf& theTrsfEnd);
|
||||
|
||||
protected:
|
||||
|
||||
//! 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:
|
||||
|
||||
gp_TrsfNLerp myTrsfLerp; //!< interpolation tool
|
||||
|
||||
gp_TrsfNLerp myTrsfLerp; //!< interpolation tool
|
||||
};
|
||||
|
||||
#endif // _AIS_AnimationObject_HeaderFile
|
||||
|
@ -14,46 +14,49 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AIS_AttributeFilter.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_AttributeFilter,SelectMgr_Filter)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
|
||||
|
||||
AIS_AttributeFilter::AIS_AttributeFilter():
|
||||
hasC(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 Standard_Real aWid):
|
||||
myWid(aWid),
|
||||
hasC(Standard_False),
|
||||
hasW(Standard_True){}
|
||||
|
||||
|
||||
Standard_Boolean AIS_AttributeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
|
||||
AIS_AttributeFilter::AIS_AttributeFilter()
|
||||
: hasC(Standard_False),
|
||||
hasW(Standard_False)
|
||||
{
|
||||
Handle(AIS_InteractiveObject) aSelectable (Handle(AIS_InteractiveObject)::DownCast (anObj->Selectable()));
|
||||
}
|
||||
|
||||
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol)
|
||||
: myCol(aCol),
|
||||
hasC(Standard_True),
|
||||
hasW(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
Handle(AIS_InteractiveObject) aSelectable(
|
||||
Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable()));
|
||||
if (aSelectable.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
|
||||
Standard_Boolean okstat = Standard_True;
|
||||
if( hasC && aSelectable->HasColor() )
|
||||
if (hasC && aSelectable->HasColor())
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
aSelectable->Color (aColor);
|
||||
aSelectable->Color(aColor);
|
||||
okstat = (myCol == aColor.Name());
|
||||
}
|
||||
|
||||
if( hasW && aSelectable->HasWidth() )
|
||||
if (hasW && aSelectable->HasWidth())
|
||||
okstat = (myWid == aSelectable->Width()) && okstat;
|
||||
|
||||
return okstat;
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <SelectMgr_Filter.hxx>
|
||||
class SelectMgr_EntityOwner;
|
||||
|
||||
|
||||
class AIS_AttributeFilter;
|
||||
DEFINE_STANDARD_HANDLE(AIS_AttributeFilter, SelectMgr_Filter)
|
||||
|
||||
@ -42,22 +41,18 @@ DEFINE_STANDARD_HANDLE(AIS_AttributeFilter, SelectMgr_Filter)
|
||||
class AIS_AttributeFilter : public SelectMgr_Filter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs an empty attribute filter object.
|
||||
//! This filter object determines whether selectable
|
||||
//! interactive objects have a non-null owner.
|
||||
Standard_EXPORT AIS_AttributeFilter();
|
||||
|
||||
|
||||
//! Constructs an attribute filter object defined by the
|
||||
//! color attribute aCol.
|
||||
Standard_EXPORT AIS_AttributeFilter(const Quantity_NameOfColor aCol);
|
||||
|
||||
|
||||
//! Constructs an attribute filter object defined by the line
|
||||
//! width attribute aWidth.
|
||||
Standard_EXPORT AIS_AttributeFilter(const Standard_Real aWidth);
|
||||
|
||||
|
||||
//! Indicates that the Interactive Object has the color
|
||||
//! setting specified by the argument aCol at construction time.
|
||||
@ -69,17 +64,17 @@ public:
|
||||
Standard_Boolean HasWidth() const { return hasW; }
|
||||
|
||||
//! Sets the color.
|
||||
void SetColor (const Quantity_NameOfColor theCol)
|
||||
void SetColor(const Quantity_NameOfColor theCol)
|
||||
{
|
||||
myCol = theCol;
|
||||
hasC = Standard_True;
|
||||
hasC = Standard_True;
|
||||
}
|
||||
|
||||
//! Sets the line width.
|
||||
void SetWidth (const Standard_Real theWidth)
|
||||
void SetWidth(const Standard_Real theWidth)
|
||||
{
|
||||
myWid = theWidth;
|
||||
hasW = Standard_True;
|
||||
hasW = Standard_True;
|
||||
}
|
||||
|
||||
//! Removes the setting for color from the filter.
|
||||
@ -96,17 +91,16 @@ public:
|
||||
//! If the Interactive Object returns Standard_True
|
||||
//! when detected by the Local Context selector through
|
||||
//! the mouse, the object is kept; if not, it is rejected.
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_AttributeFilter,SelectMgr_Filter)
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
|
||||
|
||||
private:
|
||||
|
||||
Quantity_NameOfColor myCol;
|
||||
Standard_Real myWid;
|
||||
Standard_Boolean hasC;
|
||||
Standard_Boolean hasW;
|
||||
|
||||
Standard_Real myWid;
|
||||
Standard_Boolean hasC;
|
||||
Standard_Boolean hasW;
|
||||
};
|
||||
|
||||
#endif // _AIS_AttributeFilter_HeaderFile
|
||||
|
@ -38,192 +38,172 @@
|
||||
#include <StdPrs_Curve.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),
|
||||
myTypeOfAxis(AIS_TOAX_Unknown),
|
||||
myIsXYZAxis(Standard_False)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent)
|
||||
: myComponent(aComponent),
|
||||
myTypeOfAxis(AIS_TOAX_Unknown),
|
||||
myIsXYZAxis(Standard_False)
|
||||
{
|
||||
myDrawer->SetLineAspect(new Prs3d_LineAspect
|
||||
(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
|
||||
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
|
||||
SetInfiniteState();
|
||||
|
||||
gp_Dir thedir = myComponent->Position().Direction();
|
||||
gp_Pnt loc = myComponent->Position().Location();
|
||||
gp_Dir thedir = myComponent->Position().Direction();
|
||||
gp_Pnt loc = myComponent->Position().Location();
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
|
||||
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
||||
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
||||
myPfirst = loc.XYZ() + aLength * thedir.XYZ();
|
||||
myPlast = loc.XYZ() - aLength * thedir.XYZ();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Axis
|
||||
//purpose : Xaxis, YAxis, ZAxis
|
||||
// function : AIS_Axis
|
||||
// purpose : Xaxis, YAxis, ZAxis
|
||||
//=======================================================================
|
||||
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
|
||||
const AIS_TypeOfAxis anAxisType):
|
||||
myAx2(aComponent),
|
||||
myTypeOfAxis(anAxisType),
|
||||
myIsXYZAxis(Standard_True)
|
||||
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType)
|
||||
: myAx2(aComponent),
|
||||
myTypeOfAxis(anAxisType),
|
||||
myIsXYZAxis(Standard_True)
|
||||
{
|
||||
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
|
||||
Standard_Real aLength;
|
||||
try {
|
||||
aLength = UnitsAPI::AnyToLS(100. ,"mm");
|
||||
} catch (Standard_Failure const&) {
|
||||
Handle(Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
|
||||
Standard_Real aLength;
|
||||
try
|
||||
{
|
||||
aLength = UnitsAPI::AnyToLS(100., "mm");
|
||||
}
|
||||
catch (Standard_Failure const&)
|
||||
{
|
||||
aLength = 0.1;
|
||||
}
|
||||
DA->SetAxisLength(aLength,aLength,aLength);
|
||||
Quantity_Color col (Quantity_NOC_TURQUOISE);
|
||||
DA->SetAxisLength(aLength, aLength, aLength);
|
||||
Quantity_Color col(Quantity_NOC_TURQUOISE);
|
||||
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
|
||||
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
|
||||
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col);
|
||||
myDrawer->SetDatumAspect(DA);
|
||||
|
||||
myDrawer->SetDatumAspect(DA);
|
||||
|
||||
ComputeFields();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Axis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
|
||||
:myComponent(new Geom_Line(anAxis->Ax1())),
|
||||
myTypeOfAxis(AIS_TOAX_Unknown),
|
||||
myIsXYZAxis(Standard_False)
|
||||
: myComponent(new Geom_Line(anAxis->Ax1())),
|
||||
myTypeOfAxis(AIS_TOAX_Unknown),
|
||||
myIsXYZAxis(Standard_False)
|
||||
{
|
||||
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
|
||||
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
|
||||
SetInfiniteState();
|
||||
|
||||
gp_Dir thedir = myComponent->Position().Direction();
|
||||
gp_Pnt loc = myComponent->Position().Location();
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
|
||||
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
||||
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
||||
gp_Dir thedir = myComponent->Position().Direction();
|
||||
gp_Pnt loc = myComponent->Position().Location();
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
|
||||
myPfirst = loc.XYZ() + aLength * thedir.XYZ();
|
||||
myPlast = loc.XYZ() - aLength * thedir.XYZ();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Axis
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_Axis::AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength)
|
||||
: myComponent (new Geom_Line (theAxis)),
|
||||
myTypeOfAxis (AIS_TOAX_ZAxis),
|
||||
myIsXYZAxis (Standard_True)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Axis::AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength)
|
||||
: myComponent(new Geom_Line(theAxis)),
|
||||
myTypeOfAxis(AIS_TOAX_ZAxis),
|
||||
myIsXYZAxis(Standard_True)
|
||||
{
|
||||
myDir = theAxis.Direction();
|
||||
myDir = theAxis.Direction();
|
||||
myPfirst = theAxis.Location();
|
||||
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();
|
||||
SetInfiniteState();
|
||||
Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
|
||||
aDatumAspect->SetDrawLabels (Standard_False);
|
||||
myDrawer->SetDatumAspect (aDatumAspect);
|
||||
Handle(Prs3d_LineAspect) aDefaultLineAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
|
||||
myDrawer->SetLineAspect (aDefaultLineAspect);
|
||||
aDatumAspect->SetDrawLabels(Standard_False);
|
||||
myDrawer->SetDatumAspect(aDatumAspect);
|
||||
Handle(Prs3d_LineAspect) aDefaultLineAspect =
|
||||
new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
|
||||
myDrawer->SetLineAspect(aDefaultLineAspect);
|
||||
myLineAspect = myDrawer->LineAspect();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetComponent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent)
|
||||
{
|
||||
myComponent = aComponent;
|
||||
myComponent = aComponent;
|
||||
myTypeOfAxis = AIS_TOAX_Unknown;
|
||||
myIsXYZAxis = Standard_False;
|
||||
myIsXYZAxis = Standard_False;
|
||||
SetInfiniteState();
|
||||
|
||||
gp_Dir thedir = myComponent->Position().Direction();
|
||||
gp_Pnt loc = myComponent->Position().Location();
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
|
||||
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
||||
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
||||
gp_Dir thedir = myComponent->Position().Direction();
|
||||
gp_Pnt loc = myComponent->Position().Location();
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
|
||||
myPfirst = loc.XYZ() + aLength * thedir.XYZ();
|
||||
myPlast = loc.XYZ() - aLength * thedir.XYZ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAxis2Placement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
|
||||
const AIS_TypeOfAxis anAxisType)
|
||||
const AIS_TypeOfAxis anAxisType)
|
||||
{
|
||||
myAx2 = aComponent;
|
||||
myAx2 = aComponent;
|
||||
myTypeOfAxis = anAxisType;
|
||||
myIsXYZAxis = Standard_True;
|
||||
myIsXYZAxis = Standard_True;
|
||||
ComputeFields();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAxis1Placement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis)
|
||||
{
|
||||
SetComponent(new Geom_Line(anAxis->Ax1()));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Axis::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer )
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer)
|
||||
{
|
||||
thePrs->SetInfiniteState (myInfiniteState);
|
||||
thePrs->SetInfiniteState(myInfiniteState);
|
||||
if (!myIsXYZAxis)
|
||||
{
|
||||
GeomAdaptor_Curve curv (myComponent);
|
||||
StdPrs_Curve::Add (thePrs, curv, myDrawer);
|
||||
GeomAdaptor_Curve curv(myComponent);
|
||||
StdPrs_Curve::Add(thePrs, curv, myDrawer);
|
||||
}
|
||||
else
|
||||
{
|
||||
DsgPrs_XYZAxisPresentation::Add (thePrs, myLineAspect, myDir, myVal,
|
||||
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "",
|
||||
myPfirst, myPlast);
|
||||
DsgPrs_XYZAxisPresentation::Add(thePrs,
|
||||
myLineAspect,
|
||||
myDir,
|
||||
myVal,
|
||||
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "",
|
||||
myPfirst,
|
||||
myPlast);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
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(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,
|
||||
myPfirst,
|
||||
myPlast);
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 3);
|
||||
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, myPfirst, myPlast);
|
||||
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;
|
||||
myDrawer->SetColor (aCol);
|
||||
hasOwnColor = Standard_True;
|
||||
myDrawer->SetColor(aCol);
|
||||
myDrawer->LineAspect()->SetColor(aCol);
|
||||
|
||||
|
||||
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
|
||||
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol);
|
||||
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
|
||||
@ -231,17 +211,17 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol)
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWidth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::SetWidth(const Standard_Real aValue)
|
||||
{
|
||||
if(aValue<0.0) return;
|
||||
if(aValue==0) UnsetWidth();
|
||||
|
||||
if (aValue < 0.0)
|
||||
return;
|
||||
if (aValue == 0)
|
||||
UnsetWidth();
|
||||
|
||||
myDrawer->LineAspect()->SetWidth(aValue);
|
||||
|
||||
|
||||
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
|
||||
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetWidth(aValue);
|
||||
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetWidth(aValue);
|
||||
@ -249,87 +229,80 @@ void AIS_Axis::SetWidth(const Standard_Real aValue)
|
||||
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();
|
||||
SetColor (theNewLineAspect->Aspect()->Color());
|
||||
SetColor(theNewLineAspect->Aspect()->Color());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeFields
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::ComputeFields()
|
||||
{
|
||||
if (myIsXYZAxis){
|
||||
if (myIsXYZAxis)
|
||||
{
|
||||
// calcul de myPFirst,myPlast
|
||||
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
|
||||
gp_Ax2 anAxis = myAx2->Ax2();
|
||||
const gp_Pnt& Orig = anAxis.Location();
|
||||
const gp_Dir& oX = anAxis.XDirection();
|
||||
const gp_Dir& oY = anAxis.YDirection();
|
||||
const gp_Dir& oZ = anAxis.Direction();
|
||||
Standard_Real xo,yo,zo,x = 0.,y = 0.,z = 0.;
|
||||
Orig.Coord(xo,yo,zo);
|
||||
myPfirst.SetCoord(xo,yo,zo);
|
||||
|
||||
switch (myTypeOfAxis) {
|
||||
case AIS_TOAX_XAxis:
|
||||
{
|
||||
oX.Coord(x,y,z);
|
||||
myVal = DA->AxisLength(Prs3d_DatumParts_XAxis);
|
||||
myDir = oX;
|
||||
myLineAspect = DA->LineAspect(Prs3d_DatumParts_XAxis);
|
||||
myText = Standard_CString ("X");
|
||||
break;
|
||||
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
|
||||
gp_Ax2 anAxis = myAx2->Ax2();
|
||||
const gp_Pnt& Orig = anAxis.Location();
|
||||
const gp_Dir& oX = anAxis.XDirection();
|
||||
const gp_Dir& oY = anAxis.YDirection();
|
||||
const gp_Dir& oZ = anAxis.Direction();
|
||||
Standard_Real xo, yo, zo, x = 0., y = 0., z = 0.;
|
||||
Orig.Coord(xo, yo, zo);
|
||||
myPfirst.SetCoord(xo, yo, zo);
|
||||
|
||||
switch (myTypeOfAxis)
|
||||
{
|
||||
case AIS_TOAX_XAxis: {
|
||||
oX.Coord(x, y, z);
|
||||
myVal = DA->AxisLength(Prs3d_DatumParts_XAxis);
|
||||
myDir = oX;
|
||||
myLineAspect = DA->LineAspect(Prs3d_DatumParts_XAxis);
|
||||
myText = Standard_CString("X");
|
||||
break;
|
||||
}
|
||||
case AIS_TOAX_YAxis:
|
||||
{
|
||||
oY.Coord(x,y,z);
|
||||
myVal = DA->AxisLength(Prs3d_DatumParts_YAxis);
|
||||
myDir = oY;
|
||||
myLineAspect = DA->LineAspect(Prs3d_DatumParts_YAxis);
|
||||
myText = Standard_CString ("Y");
|
||||
break;
|
||||
case AIS_TOAX_YAxis: {
|
||||
oY.Coord(x, y, z);
|
||||
myVal = DA->AxisLength(Prs3d_DatumParts_YAxis);
|
||||
myDir = oY;
|
||||
myLineAspect = DA->LineAspect(Prs3d_DatumParts_YAxis);
|
||||
myText = Standard_CString("Y");
|
||||
break;
|
||||
}
|
||||
case AIS_TOAX_ZAxis:
|
||||
{
|
||||
oZ.Coord(x,y,z);
|
||||
myVal = DA->AxisLength(Prs3d_DatumParts_ZAxis);
|
||||
myDir = oZ;
|
||||
myLineAspect = DA->LineAspect(Prs3d_DatumParts_ZAxis);
|
||||
myText = Standard_CString ("Z");
|
||||
break;
|
||||
case AIS_TOAX_ZAxis: {
|
||||
oZ.Coord(x, y, z);
|
||||
myVal = DA->AxisLength(Prs3d_DatumParts_ZAxis);
|
||||
myDir = oZ;
|
||||
myLineAspect = DA->LineAspect(Prs3d_DatumParts_ZAxis);
|
||||
myText = Standard_CString("Z");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
myComponent = new Geom_Line(Orig,myDir);
|
||||
x = xo + x*myVal; y = yo + y*myVal; z = zo + z*myVal;
|
||||
myPlast.SetCoord(x,y,z);
|
||||
|
||||
myComponent = new Geom_Line(Orig, myDir);
|
||||
x = xo + x * myVal;
|
||||
y = yo + y * myVal;
|
||||
z = zo + z * myVal;
|
||||
myPlast.SetCoord(x, y, z);
|
||||
SetInfiniteState();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AcceptDisplayMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_Axis::
|
||||
AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
{return aMode == 0;}
|
||||
Standard_Boolean AIS_Axis::AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
{
|
||||
return aMode == 0;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Axis::UnsetColor()
|
||||
{
|
||||
myDrawer->LineAspect()->SetColor(Quantity_NOC_RED);
|
||||
@ -340,10 +313,8 @@ void AIS_Axis::UnsetColor()
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Quantity_NOC_TURQUOISE);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : UnsetWidth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Axis::UnsetWidth()
|
||||
{
|
||||
|
@ -38,13 +38,13 @@ class AIS_Axis : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes the line aComponent
|
||||
Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent);
|
||||
|
||||
//! initializes the axis2 position
|
||||
//! aComponent. The coordinate system used is right-handed.
|
||||
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType);
|
||||
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
|
||||
const AIS_TypeOfAxis anAxisType);
|
||||
|
||||
//! Initializes the axis1 position anAxis.
|
||||
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis);
|
||||
@ -52,14 +52,14 @@ public:
|
||||
//! Initializes the ray as axis with start point and direction
|
||||
//! @param[in] theAxis Start point and direction of the ray
|
||||
//! @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
|
||||
//! as a component of a shape.
|
||||
const Handle(Geom_Line)& Component() const { return myComponent; }
|
||||
|
||||
//! 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
|
||||
//! 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
|
||||
//! position and direction of an axis in 3D space. The
|
||||
//! coordinate system used is right-handed.
|
||||
Standard_EXPORT void SetAxis2Placement (const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType);
|
||||
|
||||
Standard_EXPORT void SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
|
||||
const AIS_TypeOfAxis anAxisType);
|
||||
|
||||
//! Constructs a new line to serve as the axis anAxis in 3D space.
|
||||
Standard_EXPORT void SetAxis1Placement (const Handle(Geom_Axis1Placement)& anAxis);
|
||||
|
||||
Standard_EXPORT void SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis);
|
||||
|
||||
//! Returns the type of axis.
|
||||
AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; }
|
||||
|
||||
//! Constructs the entity theTypeAxis to stock information
|
||||
//! 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
|
||||
//! activate mode 2 by a signature, you pick AIS objects
|
||||
@ -87,47 +88,48 @@ public:
|
||||
Standard_Boolean IsXYZAxis() const { return myIsXYZAxis; }
|
||||
|
||||
//! Returns true if the interactive object accepts the display mode aMode.
|
||||
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
Standard_EXPORT Standard_Boolean
|
||||
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 2; }
|
||||
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE;
|
||||
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.
|
||||
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 UnsetWidth() Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
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 ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
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();
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Line) myComponent;
|
||||
Handle(Geom_Line) myComponent;
|
||||
Handle(Geom_Axis2Placement) myAx2;
|
||||
gp_Pnt myPfirst;
|
||||
gp_Pnt myPlast;
|
||||
AIS_TypeOfAxis myTypeOfAxis;
|
||||
Standard_Boolean myIsXYZAxis;
|
||||
gp_Dir myDir;
|
||||
Standard_Real myVal;
|
||||
Standard_CString myText;
|
||||
Handle(Prs3d_LineAspect) myLineAspect;
|
||||
|
||||
gp_Pnt myPfirst;
|
||||
gp_Pnt myPlast;
|
||||
AIS_TypeOfAxis myTypeOfAxis;
|
||||
Standard_Boolean myIsXYZAxis;
|
||||
gp_Dir myDir;
|
||||
Standard_Real myVal;
|
||||
Standard_CString myText;
|
||||
Handle(Prs3d_LineAspect) myLineAspect;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject)
|
||||
|
@ -22,85 +22,71 @@
|
||||
#include <TopoDS_Edge.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()
|
||||
{
|
||||
myContour=0;
|
||||
myContour = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ActsOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
|
||||
{
|
||||
return (aType == TopAbs_EDGE);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsOk
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
|
||||
{
|
||||
if (myContour==0)
|
||||
if (myContour == 0)
|
||||
return Standard_True;
|
||||
|
||||
Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO));
|
||||
Handle(StdSelect_BRepOwner) aBO(Handle(StdSelect_BRepOwner)::DownCast(EO));
|
||||
if (aBO.IsNull())
|
||||
return Standard_True;
|
||||
|
||||
const TopoDS_Shape& aShape = aBO->Shape();
|
||||
|
||||
if (myBadEdges.IsBound(myContour)) {
|
||||
if (myBadEdges.IsBound(myContour))
|
||||
{
|
||||
TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
|
||||
for (; it.More(); it.Next()) {
|
||||
for (; it.More(); it.Next())
|
||||
{
|
||||
if (it.Value().IsSame(aShape))
|
||||
return Standard_False;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
|
||||
const Standard_Integer Index)
|
||||
void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge, const Standard_Integer Index)
|
||||
{
|
||||
if (myBadEdges.IsBound(Index)) {
|
||||
myBadEdges.ChangeFind(Index).Append(anEdge);
|
||||
if (myBadEdges.IsBound(Index))
|
||||
{
|
||||
myBadEdges.ChangeFind(Index).Append(anEdge);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
TopTools_ListOfShape LS;
|
||||
LS.Append(anEdge);
|
||||
myBadEdges.Bind(Index,LS);
|
||||
myBadEdges.Bind(Index, LS);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
|
||||
{
|
||||
myBadEdges.UnBind(Index);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveEdges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
|
||||
{
|
||||
|
@ -26,7 +26,6 @@
|
||||
class SelectMgr_EntityOwner;
|
||||
class TopoDS_Edge;
|
||||
|
||||
|
||||
class AIS_BadEdgeFilter;
|
||||
DEFINE_STANDARD_HANDLE(AIS_BadEdgeFilter, SelectMgr_Filter)
|
||||
|
||||
@ -35,50 +34,33 @@ class AIS_BadEdgeFilter : public SelectMgr_Filter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Constructs an empty filter object for bad edges.
|
||||
Standard_EXPORT AIS_BadEdgeFilter();
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! sets <myContour> with current contour. used by
|
||||
//! 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
|
||||
//! 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
|
||||
//! 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:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
TopTools_DataMapOfIntegerListOfShape myBadEdges;
|
||||
Standard_Integer myContour;
|
||||
|
||||
|
||||
Standard_Integer myContour;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AIS_BadEdgeFilter_HeaderFile
|
||||
|
@ -17,41 +17,35 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
|
||||
|
||||
//=============================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
AIS_BaseAnimationObject::AIS_BaseAnimationObject (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject)
|
||||
: AIS_Animation (theAnimationName),
|
||||
myContext (theContext),
|
||||
myObject (theObject)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_BaseAnimationObject::AIS_BaseAnimationObject(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject)
|
||||
: AIS_Animation(theAnimationName),
|
||||
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())
|
||||
{
|
||||
myContext->SetLocation (myObject, theTrsf);
|
||||
myContext->SetLocation(myObject, theTrsf);
|
||||
invalidateViewer();
|
||||
}
|
||||
else
|
||||
{
|
||||
myObject->SetLocalTransformation (theTrsf);
|
||||
myObject->SetLocalTransformation(theTrsf);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : invalidateViewer
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_BaseAnimationObject::invalidateViewer()
|
||||
{
|
||||
if (myContext.IsNull())
|
||||
@ -59,7 +53,8 @@ void AIS_BaseAnimationObject::invalidateViewer()
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Boolean isImmediate = myContext->CurrentViewer()->ZLayerSettings (myObject->ZLayer()).IsImmediate();
|
||||
const Standard_Boolean isImmediate =
|
||||
myContext->CurrentViewer()->ZLayerSettings(myObject->ZLayer()).IsImmediate();
|
||||
if (!isImmediate)
|
||||
{
|
||||
myContext->CurrentViewer()->Invalidate();
|
||||
@ -67,19 +62,24 @@ void AIS_BaseAnimationObject::invalidateViewer()
|
||||
}
|
||||
|
||||
// Invalidate immediate view only if it is going out of z-fit range.
|
||||
// This might be sub-optimal performing this for each animated objects in case of many animated objects.
|
||||
// This might be sub-optimal performing this for each animated objects in case of many animated
|
||||
// objects.
|
||||
for (V3d_ListOfView::Iterator aDefViewIter = myContext->CurrentViewer()->DefinedViewIterator();
|
||||
aDefViewIter.More(); aDefViewIter.Next())
|
||||
aDefViewIter.More();
|
||||
aDefViewIter.Next())
|
||||
{
|
||||
const Handle(V3d_View)& aView = aDefViewIter.Value();
|
||||
const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues (Standard_False);
|
||||
const Bnd_Box aGraphicBox = aView->View()->MinMaxValues (Standard_True);
|
||||
Standard_Real aZNear = 0.0;
|
||||
Standard_Real aZFar = 0.0;
|
||||
if (aView->Camera()->ZFitAll (aDefViewIter.Value()->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox, aZNear, aZFar))
|
||||
const Handle(V3d_View)& aView = aDefViewIter.Value();
|
||||
const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues(Standard_False);
|
||||
const Bnd_Box aGraphicBox = aView->View()->MinMaxValues(Standard_True);
|
||||
Standard_Real aZNear = 0.0;
|
||||
Standard_Real aZFar = 0.0;
|
||||
if (aView->Camera()->ZFitAll(aDefViewIter.Value()->AutoZFitScaleFactor(),
|
||||
aMinMaxBox,
|
||||
aGraphicBox,
|
||||
aZNear,
|
||||
aZFar))
|
||||
{
|
||||
if (aZNear < aView->Camera()->ZNear()
|
||||
|| aZFar > aView->Camera()->ZFar())
|
||||
if (aZNear < aView->Camera()->ZNear() || aZFar > aView->Camera()->ZFar())
|
||||
{
|
||||
aDefViewIter.Value()->Invalidate();
|
||||
}
|
||||
|
@ -22,28 +22,24 @@ class AIS_BaseAnimationObject : public AIS_Animation
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
|
||||
protected:
|
||||
|
||||
//! Constructor with initialization.
|
||||
//! @param[in] theAnimationName animation identifier
|
||||
//! @param[in] theContext interactive context where object have been displayed
|
||||
//! @param[in] theObject object to apply local transformation
|
||||
Standard_EXPORT AIS_BaseAnimationObject (const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject);
|
||||
Standard_EXPORT AIS_BaseAnimationObject(const TCollection_AsciiString& theAnimationName,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
const Handle(AIS_InteractiveObject)& theObject);
|
||||
|
||||
//! Update the transformation.
|
||||
Standard_EXPORT void updateTrsf (const gp_Trsf& theTrsf);
|
||||
Standard_EXPORT void updateTrsf(const gp_Trsf& theTrsf);
|
||||
|
||||
private:
|
||||
|
||||
//! Invalidate the viewer for proper update.
|
||||
Standard_EXPORT void invalidateViewer();
|
||||
|
||||
protected:
|
||||
|
||||
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
|
||||
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
|
||||
|
||||
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
|
||||
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
|
||||
};
|
||||
|
||||
#endif // _AIS_BaseAnimationObject_HeaderFile
|
||||
|
@ -14,7 +14,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AIS_C0RegularityFilter.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
@ -27,65 +26,62 @@
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.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)
|
||||
{
|
||||
TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
|
||||
TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
|
||||
TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, SubShapes);
|
||||
Standard_Boolean Ok;
|
||||
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
|
||||
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++)
|
||||
{
|
||||
Ok = Standard_False;
|
||||
TopTools_ListIteratorOfListOfShape it(SubShapes(i));
|
||||
TopoDS_Face Face1, Face2;
|
||||
if (it.More()) {
|
||||
TopoDS_Face Face1, Face2;
|
||||
if (it.More())
|
||||
{
|
||||
Face1 = TopoDS::Face(it.Value());
|
||||
it.Next();
|
||||
if (it.More()) {
|
||||
Face2 = TopoDS::Face(it.Value());
|
||||
it.Next();
|
||||
if (!it.More()) {
|
||||
GeomAbs_Shape ShapeContinuity =
|
||||
BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
|
||||
Ok = (ShapeContinuity == GeomAbs_C0);
|
||||
}
|
||||
if (it.More())
|
||||
{
|
||||
Face2 = TopoDS::Face(it.Value());
|
||||
it.Next();
|
||||
if (!it.More())
|
||||
{
|
||||
GeomAbs_Shape ShapeContinuity =
|
||||
BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)), Face1, Face2);
|
||||
Ok = (ShapeContinuity == GeomAbs_C0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Ok) {
|
||||
const TopoDS_Shape& curEdge = SubShapes.FindKey( i );
|
||||
if (Ok)
|
||||
{
|
||||
const TopoDS_Shape& curEdge = SubShapes.FindKey(i);
|
||||
myMapOfEdges.Add(curEdge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ActsOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
|
||||
{
|
||||
return (aType == TopAbs_EDGE);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsOk
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
|
||||
{
|
||||
Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO));
|
||||
Handle(StdSelect_BRepOwner) aBO(Handle(StdSelect_BRepOwner)::DownCast(EO));
|
||||
if (aBO.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
const TopoDS_Shape& aShape = aBO->Shape();
|
||||
|
||||
if(aShape.ShapeType()!= TopAbs_EDGE)
|
||||
if (aShape.ShapeType() != TopAbs_EDGE)
|
||||
return Standard_False;
|
||||
|
||||
return (myMapOfEdges.Contains(aShape));
|
||||
|
@ -25,45 +25,26 @@
|
||||
class TopoDS_Shape;
|
||||
class SelectMgr_EntityOwner;
|
||||
|
||||
|
||||
class AIS_C0RegularityFilter;
|
||||
DEFINE_STANDARD_HANDLE(AIS_C0RegularityFilter, SelectMgr_Filter)
|
||||
|
||||
|
||||
class AIS_C0RegularityFilter : public SelectMgr_Filter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT AIS_C0RegularityFilter(const TopoDS_Shape& aShape);
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter,SelectMgr_Filter)
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter, SelectMgr_Filter)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
TopTools_MapOfShape myMapOfEdges;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AIS_C0RegularityFilter_HeaderFile
|
||||
|
@ -29,51 +29,45 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f;
|
||||
static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE;
|
||||
}
|
||||
static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f;
|
||||
static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE;
|
||||
} // namespace
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_CameraFrustum::AIS_CameraFrustum()
|
||||
: myPoints (0, Graphic3d_Camera::FrustumVerticesNB)
|
||||
: 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();
|
||||
aShadingAspect->SetMaterial (Graphic3d_NameOfMaterial_Plastified);
|
||||
aShadingAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend);
|
||||
aShadingAspect->SetTransparency (THE_DEFAULT_TRANSPARENCY);
|
||||
aShadingAspect->SetColor (THE_DEFAULT_COLOR);
|
||||
myDrawer->SetShadingAspect (aShadingAspect);
|
||||
aShadingAspect->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
|
||||
aShadingAspect->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_Blend);
|
||||
aShadingAspect->SetTransparency(THE_DEFAULT_TRANSPARENCY);
|
||||
aShadingAspect->SetColor(THE_DEFAULT_COLOR);
|
||||
myDrawer->SetShadingAspect(aShadingAspect);
|
||||
|
||||
myDrawer->SetTransparency (THE_DEFAULT_TRANSPARENCY);
|
||||
SetDisplayMode (AIS_Shaded);
|
||||
myDrawer->SetTransparency(THE_DEFAULT_TRANSPARENCY);
|
||||
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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCameraFrustum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_CameraFrustum::SetCameraFrustum(const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
if (theCamera.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theCamera->FrustumPoints (myPoints);
|
||||
theCamera->FrustumPoints(myPoints);
|
||||
|
||||
fillTriangles();
|
||||
fillBorders();
|
||||
@ -81,22 +75,18 @@ void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCam
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_CameraFrustum::SetColor(const Quantity_Color& theColor)
|
||||
{
|
||||
AIS_InteractiveObject::SetColor (theColor);
|
||||
myDrawer->ShadingAspect()->SetColor (theColor);
|
||||
myDrawer->LineAspect()->SetColor (theColor);
|
||||
AIS_InteractiveObject::SetColor(theColor);
|
||||
myDrawer->ShadingAspect()->SetColor(theColor);
|
||||
myDrawer->LineAspect()->SetColor(theColor);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_CameraFrustum::UnsetColor()
|
||||
{
|
||||
if (!HasColor())
|
||||
@ -106,26 +96,22 @@ void AIS_CameraFrustum::UnsetColor()
|
||||
|
||||
AIS_InteractiveObject::UnsetColor();
|
||||
|
||||
myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR);
|
||||
myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR);
|
||||
myDrawer->ShadingAspect()->SetColor(THE_DEFAULT_COLOR);
|
||||
myDrawer->LineAspect()->SetColor(THE_DEFAULT_COLOR);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_CameraFrustum::UnsetTransparency()
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetTransparency (0.0f);
|
||||
myDrawer->SetTransparency (0.0f);
|
||||
myDrawer->ShadingAspect()->SetTransparency(0.0f);
|
||||
myDrawer->SetTransparency(0.0f);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : fillTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_CameraFrustum::fillTriangles()
|
||||
{
|
||||
if (myTriangles.IsNull())
|
||||
@ -133,18 +119,19 @@ void AIS_CameraFrustum::fillTriangles()
|
||||
const Standard_Integer aPlaneTriangleVertsNb = 2 * 3;
|
||||
const Standard_Integer aPlanesNb = 3 * 2;
|
||||
|
||||
myTriangles = new Graphic3d_ArrayOfTriangles (Graphic3d_Camera::FrustumVerticesNB, aPlaneTriangleVertsNb * aPlanesNb);
|
||||
myTriangles->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0));
|
||||
myTriangles = new Graphic3d_ArrayOfTriangles(Graphic3d_Camera::FrustumVerticesNB,
|
||||
aPlaneTriangleVertsNb * aPlanesNb);
|
||||
myTriangles->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
|
||||
|
||||
// Triangles go in order (clockwise vertices traversing for correct normal):
|
||||
// (0, 2, 1), (3, 1, 2)
|
||||
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 aLookup1_clockwise[] = {0, 1, 0, 1, 0, 1};
|
||||
const Standard_Integer aLookup2_clockwise[] = {0, 0, 1, 1, 1, 0};
|
||||
// Triangles go in order (counterclockwise vertices traversing for correct normal):
|
||||
// (1, 2, 0), (2, 1, 3)
|
||||
const Standard_Integer aLookup1_anticlockwise[] = { 0, 1, 0, 1, 0, 1 };
|
||||
const Standard_Integer aLookup2_anticlockwise[] = { 1, 0, 0, 0, 1, 1 };
|
||||
Standard_Integer aShifts[] = { 0, 0, 0 };
|
||||
const Standard_Integer aLookup1_anticlockwise[] = {0, 1, 0, 1, 0, 1};
|
||||
const Standard_Integer aLookup2_anticlockwise[] = {1, 0, 0, 0, 1, 1};
|
||||
Standard_Integer aShifts[] = {0, 0, 0};
|
||||
|
||||
// Planes go in order:
|
||||
// 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];
|
||||
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];
|
||||
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()
|
||||
{
|
||||
if (myBorders.IsNull())
|
||||
{
|
||||
const Standard_Integer aPlaneSegmVertsNb = 2 * 4;
|
||||
const Standard_Integer aPlanesNb = 3 * 2;
|
||||
myBorders = new Graphic3d_ArrayOfSegments (Graphic3d_Camera::FrustumVerticesNB, aPlaneSegmVertsNb * aPlanesNb);
|
||||
myBorders->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0));
|
||||
myBorders = new Graphic3d_ArrayOfSegments(Graphic3d_Camera::FrustumVerticesNB,
|
||||
aPlaneSegmVertsNb * aPlanesNb);
|
||||
myBorders->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
|
||||
|
||||
// Segments go in order:
|
||||
// (0, 2), (2, 3), (3, 1), (1, 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 };
|
||||
Standard_Integer aShifts[] = { 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};
|
||||
Standard_Integer aShifts[] = {0, 0, 0};
|
||||
|
||||
// Planes go in order:
|
||||
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
|
||||
@ -207,33 +194,32 @@ void AIS_CameraFrustum::fillBorders()
|
||||
{
|
||||
for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter)
|
||||
{
|
||||
aShifts[aFaceIdx] = i;
|
||||
aShifts[aFaceIdx] = i;
|
||||
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter];
|
||||
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter];
|
||||
|
||||
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];
|
||||
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,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_CameraFrustum::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
thePrs->SetInfiniteState (true);
|
||||
thePrs->SetInfiniteState(true);
|
||||
if (myTriangles.IsNull())
|
||||
{
|
||||
return;
|
||||
@ -241,48 +227,48 @@ void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
|
||||
switch (theMode)
|
||||
{
|
||||
case AIS_Shaded:
|
||||
{
|
||||
case AIS_Shaded: {
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (myTriangles);
|
||||
aGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray(myTriangles);
|
||||
}
|
||||
Standard_FALLTHROUGH
|
||||
case AIS_WireFrame:
|
||||
{
|
||||
Standard_FALLTHROUGH
|
||||
case AIS_WireFrame: {
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (myBorders);
|
||||
aGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray(myBorders);
|
||||
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)
|
||||
{
|
||||
case SelectionMode_Edges:
|
||||
{
|
||||
Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (anOwner);
|
||||
case SelectionMode_Edges: {
|
||||
Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup(anOwner);
|
||||
for (Standard_Integer anIter = 1; anIter <= myBorders->EdgeNumber(); anIter += 2)
|
||||
{
|
||||
aSensitiveEntity->Add (new Select3D_SensitiveSegment (anOwner, myBorders->Vertice (myBorders->Edge (anIter)), myBorders->Vertice(myBorders->Edge (anIter + 1))));
|
||||
aSensitiveEntity->Add(
|
||||
new Select3D_SensitiveSegment(anOwner,
|
||||
myBorders->Vertice(myBorders->Edge(anIter)),
|
||||
myBorders->Vertice(myBorders->Edge(anIter + 1))));
|
||||
}
|
||||
theSelection->Add (aSensitiveEntity);
|
||||
theSelection->Add(aSensitiveEntity);
|
||||
break;
|
||||
}
|
||||
case SelectionMode_Volume:
|
||||
{
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (anOwner);
|
||||
aSelArray->InitTriangulation (myTriangles->Attributes(), myTriangles->Indices(), TopLoc_Location());
|
||||
theSelection->Add (aSelArray);
|
||||
case SelectionMode_Volume: {
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSelArray =
|
||||
new Select3D_SensitivePrimitiveArray(anOwner);
|
||||
aSelArray->InitTriangulation(myTriangles->Attributes(),
|
||||
myTriangles->Indices(),
|
||||
TopLoc_Location());
|
||||
theSelection->Add(aSelArray);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ class AIS_CameraFrustum : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Selection modes supported by this object
|
||||
enum SelectionMode
|
||||
{
|
||||
@ -36,15 +35,14 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Constructs camera frustum with default configuration.
|
||||
Standard_EXPORT AIS_CameraFrustum();
|
||||
|
||||
//! Sets camera frustum.
|
||||
Standard_EXPORT void SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera);
|
||||
Standard_EXPORT void SetCameraFrustum(const Handle(Graphic3d_Camera)& theCamera);
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
@ -53,21 +51,20 @@ public:
|
||||
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
|
||||
|
||||
//! Return true if specified display mode is supported.
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes presentation of camera frustum.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection.
|
||||
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;
|
||||
|
||||
private:
|
||||
|
||||
//! Fills triangles primitive array for camera frustum filling.
|
||||
void fillTriangles();
|
||||
|
||||
@ -75,11 +72,9 @@ private:
|
||||
void fillBorders();
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Array1<Graphic3d_Vec3d> myPoints; //!< Array of points
|
||||
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for camera frustum filling
|
||||
Handle(Graphic3d_ArrayOfSegments) myBorders; //!< Segments for camera frustum borders
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_CameraFrustum_HeaderFile
|
||||
|
@ -33,105 +33,99 @@
|
||||
#include <Standard_Type.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),
|
||||
myComponent(aComponent),
|
||||
myUStart (0.0),
|
||||
myUEnd (2.0 * M_PI),
|
||||
myCircleIsArc (Standard_False),
|
||||
myIsFilledCircleSens (Standard_False)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent)
|
||||
: AIS_InteractiveObject(PrsMgr_TOP_AllView),
|
||||
myComponent(aComponent),
|
||||
myUStart(0.0),
|
||||
myUEnd(2.0 * M_PI),
|
||||
myCircleIsArc(Standard_False),
|
||||
myIsFilledCircleSens(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Circle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
|
||||
const Standard_Real theUStart,
|
||||
const Standard_Real theUEnd,
|
||||
const Standard_Boolean theIsFilledCircleSens)
|
||||
: AIS_InteractiveObject(PrsMgr_TOP_AllView),
|
||||
myComponent (theComponent),
|
||||
myUStart (theUStart),
|
||||
myUEnd (theUEnd),
|
||||
myCircleIsArc (Abs (Abs (theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()),
|
||||
myIsFilledCircleSens (theIsFilledCircleSens)
|
||||
const Standard_Real theUStart,
|
||||
const Standard_Real theUEnd,
|
||||
const Standard_Boolean theIsFilledCircleSens)
|
||||
: AIS_InteractiveObject(PrsMgr_TOP_AllView),
|
||||
myComponent(theComponent),
|
||||
myUStart(theUStart),
|
||||
myUEnd(theUEnd),
|
||||
myCircleIsArc(Abs(Abs(theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()),
|
||||
myIsFilledCircleSens(theIsFilledCircleSens)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer )
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer)
|
||||
{
|
||||
if (myCircleIsArc) { ComputeArc (thePrs); }
|
||||
else { ComputeCircle (thePrs); }
|
||||
if (myCircleIsArc)
|
||||
{
|
||||
ComputeArc(thePrs);
|
||||
}
|
||||
else
|
||||
{
|
||||
ComputeCircle(thePrs);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
const Standard_Integer /*aMode*/)
|
||||
{
|
||||
|
||||
if (myCircleIsArc) ComputeArcSelection(aSelection);
|
||||
else ComputeCircleSelection(aSelection);
|
||||
|
||||
if (myCircleIsArc)
|
||||
ComputeArcSelection(aSelection);
|
||||
else
|
||||
ComputeCircleSelection(aSelection);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : replaceWithNewLineAspect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
|
||||
{
|
||||
if (!myDrawer->HasLink())
|
||||
{
|
||||
myDrawer->SetLineAspect (theAspect);
|
||||
myDrawer->SetLineAspect(theAspect);
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(Graphic3d_AspectLine3d) anAspectOld = myDrawer->LineAspect()->Aspect();
|
||||
const Handle(Graphic3d_AspectLine3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
|
||||
const Handle(Graphic3d_AspectLine3d) anAspectNew =
|
||||
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
|
||||
if (anAspectNew != anAspectOld)
|
||||
{
|
||||
myDrawer->SetLineAspect (theAspect);
|
||||
myDrawer->SetLineAspect(theAspect);
|
||||
Graphic3d_MapOfAspectsToAspects aReplaceMap;
|
||||
aReplaceMap.Bind (anAspectOld, anAspectNew);
|
||||
replaceAspects (aReplaceMap);
|
||||
aReplaceMap.Bind(anAspectOld, anAspectNew);
|
||||
replaceAspects(aReplaceMap);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::SetColor(const Quantity_Color &aCol)
|
||||
void AIS_Circle::SetColor(const Quantity_Color& aCol)
|
||||
{
|
||||
hasOwnColor=Standard_True;
|
||||
myDrawer->SetColor (aCol);
|
||||
hasOwnColor = Standard_True;
|
||||
myDrawer->SetColor(aCol);
|
||||
|
||||
if (!myDrawer->HasOwnLineAspect())
|
||||
{
|
||||
Standard_Real WW = HasWidth() ? myOwnWidth :
|
||||
myDrawer->HasLink() ?
|
||||
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) :
|
||||
1.;
|
||||
replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW));
|
||||
Standard_Real WW = HasWidth() ? myOwnWidth
|
||||
: myDrawer->HasLink()
|
||||
? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
|
||||
: 1.;
|
||||
replaceWithNewLineAspect(new Prs3d_LineAspect(aCol, Aspect_TOL_SOLID, WW));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -140,20 +134,20 @@ void AIS_Circle::SetColor(const Quantity_Color &aCol)
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWidth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::SetWidth(const Standard_Real aValue)
|
||||
{
|
||||
myOwnWidth = (Standard_ShortReal )aValue;
|
||||
myOwnWidth = (Standard_ShortReal)aValue;
|
||||
|
||||
if (!myDrawer->HasOwnLineAspect())
|
||||
{
|
||||
Quantity_Color CC = Quantity_NOC_YELLOW;
|
||||
if( HasColor() ) CC = myDrawer->Color();
|
||||
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue));
|
||||
if (HasColor())
|
||||
CC = myDrawer->Color();
|
||||
else if (myDrawer->HasLink())
|
||||
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -162,101 +156,90 @@ void AIS_Circle::SetWidth(const Standard_Real aValue)
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::UnsetColor()
|
||||
{
|
||||
hasOwnColor = Standard_False;
|
||||
|
||||
if (!HasWidth())
|
||||
{
|
||||
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
|
||||
replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
|
||||
}
|
||||
else
|
||||
{
|
||||
Quantity_Color CC = Quantity_NOC_YELLOW;
|
||||
if( HasColor() ) CC = myDrawer->Color();
|
||||
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
|
||||
if (HasColor())
|
||||
CC = myDrawer->Color();
|
||||
else if (myDrawer->HasLink())
|
||||
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
myDrawer->LineAspect()->SetColor(CC);
|
||||
myDrawer->SetColor (CC);
|
||||
myDrawer->SetColor(CC);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetWidth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::UnsetWidth()
|
||||
{
|
||||
if (!HasColor())
|
||||
{
|
||||
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
|
||||
replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.0f;
|
||||
myDrawer->LineAspect()->SetWidth(WW);
|
||||
myOwnWidth = WW;
|
||||
Standard_ShortReal WW =
|
||||
myDrawer->HasLink()
|
||||
? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
|
||||
: 1.0f;
|
||||
myDrawer->LineAspect()->SetWidth(WW);
|
||||
myOwnWidth = WW;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeCircle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::ComputeCircle (const Handle(Prs3d_Presentation)& thePresentation)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::ComputeCircle(const Handle(Prs3d_Presentation)& thePresentation)
|
||||
{
|
||||
|
||||
GeomAdaptor_Curve curv(myComponent);
|
||||
Standard_Real prevdev = myDrawer->DeviationCoefficient();
|
||||
myDrawer->SetDeviationCoefficient (1.e-5);
|
||||
StdPrs_DeflectionCurve::Add (thePresentation, curv, myDrawer);
|
||||
myDrawer->SetDeviationCoefficient (prevdev);
|
||||
|
||||
Standard_Real prevdev = myDrawer->DeviationCoefficient();
|
||||
myDrawer->SetDeviationCoefficient(1.e-5);
|
||||
StdPrs_DeflectionCurve::Add(thePresentation, curv, myDrawer);
|
||||
myDrawer->SetDeviationCoefficient(prevdev);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeArc
|
||||
//=================================================================================================
|
||||
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::ComputeArc (const Handle(Prs3d_Presentation)& thePresentation)
|
||||
void AIS_Circle::ComputeArc(const Handle(Prs3d_Presentation)& thePresentation)
|
||||
{
|
||||
GeomAdaptor_Curve curv(myComponent, myUStart, myUEnd);
|
||||
Standard_Real prevdev = myDrawer->DeviationCoefficient();
|
||||
myDrawer->SetDeviationCoefficient (1.e-5);
|
||||
StdPrs_DeflectionCurve::Add (thePresentation, curv, myDrawer);
|
||||
myDrawer->SetDeviationCoefficient (prevdev);
|
||||
Standard_Real prevdev = myDrawer->DeviationCoefficient();
|
||||
myDrawer->SetDeviationCoefficient(1.e-5);
|
||||
StdPrs_DeflectionCurve::Add(thePresentation, curv, myDrawer);
|
||||
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(Select3D_SensitiveCircle) aCirc = new Select3D_SensitiveCircle (anOwner,
|
||||
myComponent->Circ(),
|
||||
myIsFilledCircleSens);
|
||||
theSelection->Add (aCirc);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitiveCircle) aCirc =
|
||||
new Select3D_SensitiveCircle(anOwner, myComponent->Circ(), myIsFilledCircleSens);
|
||||
theSelection->Add(aCirc);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ComputeArcSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_Circle::ComputeArcSelection (const Handle(SelectMgr_Selection)& theSelection)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& theSelection)
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitivePoly) aSeg = new Select3D_SensitivePoly (anOwner,
|
||||
myComponent->Circ(),
|
||||
myUStart, myUEnd,
|
||||
myIsFilledCircleSens);
|
||||
theSelection->Add (aSeg);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitivePoly) aSeg = new Select3D_SensitivePoly(anOwner,
|
||||
myComponent->Circ(),
|
||||
myUStart,
|
||||
myUEnd,
|
||||
myIsFilledCircleSens);
|
||||
theSelection->Add(aSeg);
|
||||
}
|
||||
|
@ -27,97 +27,102 @@ class AIS_Circle : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes this algorithm for constructing AIS circle
|
||||
//! datums initializes the circle aCircle
|
||||
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle);
|
||||
|
||||
|
||||
//! Initializes this algorithm for constructing AIS circle datums.
|
||||
//! Initializes the circle theCircle, the arc
|
||||
//! starting point theUStart, the arc ending point theUEnd,
|
||||
//! and the type of sensitivity theIsFilledCircleSens.
|
||||
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle, const Standard_Real theUStart, const Standard_Real theUEnd, const Standard_Boolean theIsFilledCircleSens = Standard_False);
|
||||
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle,
|
||||
const Standard_Real theUStart,
|
||||
const Standard_Real theUEnd,
|
||||
const Standard_Boolean theIsFilledCircleSens = Standard_False);
|
||||
|
||||
//! Returns index 6 by default.
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; }
|
||||
|
||||
//! Indicates that the type of Interactive Object is a datum.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
//! Returns the circle component defined in SetCircle.
|
||||
const Handle(Geom_Circle)& Circle() const { return myComponent; }
|
||||
|
||||
//! Constructs instances of the starting point and the end
|
||||
//! 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;
|
||||
theU2 = myUEnd;
|
||||
}
|
||||
|
||||
//! 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.
|
||||
void SetFirstParam (const Standard_Real theU)
|
||||
void SetFirstParam(const Standard_Real theU)
|
||||
{
|
||||
myUStart = theU;
|
||||
myUStart = theU;
|
||||
myCircleIsArc = Standard_True;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
}
|
||||
|
||||
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.
|
||||
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.
|
||||
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Removes width settings from the solid line boundary of the circle datum.
|
||||
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Returns the type of sensitivity for the circle;
|
||||
Standard_Boolean IsFilledCircleSens() const { return myIsFilledCircleSens; }
|
||||
|
||||
//! Sets the type of sensitivity for the circle. If theIsFilledCircleSens set to Standard_True
|
||||
//! then the whole circle will be detectable, otherwise only the boundary of the circle.
|
||||
void SetFilledCircleSens (const Standard_Boolean theIsFilledCircleSens) { myIsFilledCircleSens = theIsFilledCircleSens; }
|
||||
void SetFilledCircleSens(const Standard_Boolean theIsFilledCircleSens)
|
||||
{
|
||||
myIsFilledCircleSens = theIsFilledCircleSens;
|
||||
}
|
||||
|
||||
private:
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& theprs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
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 ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
|
||||
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 ComputeCircle(const Handle(Prs3d_Presentation)& aPresentation);
|
||||
|
||||
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.
|
||||
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
|
||||
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Circle) myComponent;
|
||||
Standard_Real myUStart;
|
||||
Standard_Real myUEnd;
|
||||
Standard_Boolean myCircleIsArc;
|
||||
Standard_Boolean myIsFilledCircleSens;
|
||||
|
||||
Standard_Real myUStart;
|
||||
Standard_Real myUEnd;
|
||||
Standard_Boolean myCircleIsArc;
|
||||
Standard_Boolean myIsFilledCircleSens;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,6 +26,7 @@
|
||||
|
||||
class AIS_ColorScale;
|
||||
DEFINE_STANDARD_HANDLE(AIS_ColorScale, AIS_InteractiveObject)
|
||||
|
||||
//! Class for drawing a custom color scale.
|
||||
//!
|
||||
//! The color scale consists of rectangular color bar (composed of fixed
|
||||
@ -39,71 +40,81 @@ class AIS_ColorScale : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject)
|
||||
public:
|
||||
//! Calculate color according passed value; returns true if value is in range or false, if isn't
|
||||
Standard_EXPORT static Standard_Boolean FindColor(const Standard_Real theValue,
|
||||
const Standard_Real theMin,
|
||||
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
|
||||
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
|
||||
static Standard_Boolean FindColor (const Standard_Real theValue,
|
||||
const Standard_Real theMin,
|
||||
const Standard_Real theMax,
|
||||
const Standard_Integer theColorsCount,
|
||||
Quantity_Color& theColor)
|
||||
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,
|
||||
Graphic3d_Vec3d (230.0, 1.0, 1.0),
|
||||
Graphic3d_Vec3d (0.0, 1.0, 1.0),
|
||||
theColor);
|
||||
return FindColor(theValue,
|
||||
theMin,
|
||||
theMax,
|
||||
theColorsCount,
|
||||
Graphic3d_Vec3d(230.0, 1.0, 1.0),
|
||||
Graphic3d_Vec3d(0.0, 1.0, 1.0),
|
||||
theColor);
|
||||
}
|
||||
|
||||
//! Shift hue into valid range.
|
||||
//! Lightness and Saturation should be specified in valid range [0.0, 1.0],
|
||||
//! however Hue might be given out of Quantity_Color range to specify desired range for interpolation.
|
||||
static Standard_Real hueToValidRange (const Standard_Real theHue)
|
||||
//! however Hue might be given out of Quantity_Color range to specify desired range for
|
||||
//! interpolation.
|
||||
static Standard_Real hueToValidRange(const Standard_Real theHue)
|
||||
{
|
||||
Standard_Real aHue = theHue;
|
||||
while (aHue < 0.0) { aHue += 360.0; }
|
||||
while (aHue > 360.0) { aHue -= 360.0; }
|
||||
while (aHue < 0.0)
|
||||
{
|
||||
aHue += 360.0;
|
||||
}
|
||||
while (aHue > 360.0)
|
||||
{
|
||||
aHue -= 360.0;
|
||||
}
|
||||
return aHue;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT AIS_ColorScale();
|
||||
|
||||
//! Calculate color according passed value; returns true if value is in range or false, if isn't
|
||||
Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const;
|
||||
Standard_EXPORT Standard_Boolean FindColor(const Standard_Real theValue,
|
||||
Quantity_Color& theColor) const;
|
||||
|
||||
//! Returns minimal value of color scale, 0.0 by default.
|
||||
Standard_Real GetMin() const { return myMin; }
|
||||
|
||||
//! 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.
|
||||
Standard_Real GetMax() const { return myMax; }
|
||||
|
||||
//! 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.
|
||||
void GetRange (Standard_Real& theMin, Standard_Real& theMax) const
|
||||
void GetRange(Standard_Real& theMin, Standard_Real& theMax) const
|
||||
{
|
||||
theMin = myMin;
|
||||
theMax = myMax;
|
||||
}
|
||||
|
||||
//! Sets the minimal and maximal value of color scale.
|
||||
//! Note that values order will be ignored - the minimum and maximum values will be swapped if needed.
|
||||
//! Note that values order will be ignored - the minimum and maximum values will be swapped if
|
||||
//! needed.
|
||||
//! ::SetReversed() should be called to swap displaying order.
|
||||
Standard_EXPORT void SetRange (const Standard_Real theMin, const Standard_Real theMax);
|
||||
Standard_EXPORT void SetRange(const Standard_Real theMin, const Standard_Real theMax);
|
||||
|
||||
//! Returns the hue angle corresponding to minimum value, 230 by default (blue).
|
||||
Standard_Real HueMin() const { return myColorHlsMin[0]; }
|
||||
@ -111,9 +122,9 @@ public:
|
||||
//! Returns the hue angle corresponding to maximum value, 0 by default (red).
|
||||
Standard_Real HueMax() const { return myColorHlsMax[0]; }
|
||||
|
||||
//! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default (blue to red).
|
||||
void HueRange (Standard_Real& theMinAngle,
|
||||
Standard_Real& theMaxAngle) const
|
||||
//! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default
|
||||
//! (blue to red).
|
||||
void HueRange(Standard_Real& theMinAngle, Standard_Real& theMaxAngle) const
|
||||
{
|
||||
theMinAngle = myColorHlsMin[0];
|
||||
theMaxAngle = myColorHlsMax[0];
|
||||
@ -121,27 +132,30 @@ public:
|
||||
|
||||
//! Sets hue angle range corresponding to minimum and maximum values.
|
||||
//! The valid angle range is [0, 360], see Quantity_Color and Quantity_TOC_HLS for more details.
|
||||
void SetHueRange (const Standard_Real theMinAngle,
|
||||
const Standard_Real theMaxAngle)
|
||||
void SetHueRange(const Standard_Real theMinAngle, const Standard_Real theMaxAngle)
|
||||
{
|
||||
myColorHlsMin[0] = theMinAngle;
|
||||
myColorHlsMax[0] = theMaxAngle;
|
||||
}
|
||||
|
||||
//! Returns color range corresponding to minimum and maximum values, blue to red by default.
|
||||
void ColorRange (Quantity_Color& theMinColor,
|
||||
Quantity_Color& theMaxColor) const
|
||||
void ColorRange(Quantity_Color& theMinColor, Quantity_Color& theMaxColor) const
|
||||
{
|
||||
theMinColor.SetValues (hueToValidRange (myColorHlsMin[0]), myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
|
||||
theMaxColor.SetValues (hueToValidRange (myColorHlsMax[0]), myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
|
||||
theMinColor.SetValues(hueToValidRange(myColorHlsMin[0]),
|
||||
myColorHlsMin[1],
|
||||
myColorHlsMin[2],
|
||||
Quantity_TOC_HLS);
|
||||
theMaxColor.SetValues(hueToValidRange(myColorHlsMax[0]),
|
||||
myColorHlsMax[1],
|
||||
myColorHlsMax[2],
|
||||
Quantity_TOC_HLS);
|
||||
}
|
||||
|
||||
//! Sets color range corresponding to minimum and maximum values.
|
||||
void SetColorRange (const Quantity_Color& theMinColor,
|
||||
const Quantity_Color& theMaxColor)
|
||||
void SetColorRange(const Quantity_Color& theMinColor, const Quantity_Color& theMaxColor)
|
||||
{
|
||||
theMinColor.Values (myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
|
||||
theMaxColor.Values (myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
|
||||
theMinColor.Values(myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[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.
|
||||
@ -152,7 +166,7 @@ public:
|
||||
//! Sets the type of labels.
|
||||
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals
|
||||
//! 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.
|
||||
//! Aspect_TOCSD_AUTO - value between Red and Blue
|
||||
@ -162,19 +176,19 @@ public:
|
||||
//! Sets the type of colors.
|
||||
//! Aspect_TOCSD_AUTO - value between Red and Blue
|
||||
//! 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.
|
||||
Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; }
|
||||
|
||||
//! 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.
|
||||
const TCollection_ExtendedString& GetTitle() const { return myTitle; }
|
||||
|
||||
//! 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.
|
||||
//! The same like format for function printf().
|
||||
@ -185,58 +199,60 @@ public:
|
||||
const TCollection_AsciiString& Format() const { return myFormat; }
|
||||
|
||||
//! 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.
|
||||
//! Index is in range from 1 to GetNumberOfIntervals() or to
|
||||
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true.
|
||||
//! 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 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.
|
||||
//! @param theColor color value to set
|
||||
//! @param theIndex index in range [1, GetNumberOfIntervals()];
|
||||
//! appended to the end of list if -1 is specified
|
||||
Standard_EXPORT void SetIntervalColor (const Quantity_Color& theColor, const Standard_Integer theIndex);
|
||||
Standard_EXPORT void SetIntervalColor(const Quantity_Color& theColor,
|
||||
const Standard_Integer theIndex);
|
||||
|
||||
//! Returns the user specified labels.
|
||||
Standard_EXPORT void GetLabels (TColStd_SequenceOfExtendedString& theLabels) const;
|
||||
Standard_EXPORT void GetLabels(TColStd_SequenceOfExtendedString& theLabels) const;
|
||||
|
||||
//! Returns the user specified labels.
|
||||
const TColStd_SequenceOfExtendedString& Labels() const { return myLabels; }
|
||||
|
||||
//! Sets the color scale labels.
|
||||
//! The length of the sequence should be equal to GetNumberOfIntervals() or to GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true.
|
||||
//! If length of the sequence does not much the number of intervals,
|
||||
//! then these labels will be considered as "free" and will be located
|
||||
//! at the virtual intervals corresponding to the number of labels
|
||||
//! (with flag IsLabelAtBorder() having the same effect as in normal case).
|
||||
Standard_EXPORT void SetLabels (const TColStd_SequenceOfExtendedString& theSeq);
|
||||
//! The length of the sequence should be equal to GetNumberOfIntervals() or to
|
||||
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. If length of the sequence does not
|
||||
//! much the number of intervals, then these labels will be considered as "free" and will be
|
||||
//! located at the virtual intervals corresponding to the number of labels (with flag
|
||||
//! IsLabelAtBorder() having the same effect as in normal case).
|
||||
Standard_EXPORT void SetLabels(const TColStd_SequenceOfExtendedString& theSeq);
|
||||
|
||||
//! Returns the user specified colors.
|
||||
Standard_EXPORT void GetColors (Aspect_SequenceOfColor& theColors) const;
|
||||
Standard_EXPORT void GetColors(Aspect_SequenceOfColor& theColors) const;
|
||||
|
||||
//! Returns the user specified colors.
|
||||
const Aspect_SequenceOfColor& GetColors() const { return myColors; }
|
||||
|
||||
//! Sets the color scale colors.
|
||||
//! 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
|
||||
//! color space, distributed by hue, with perceptually uniform differences
|
||||
//! between consequent colors.
|
||||
//! See MakeUniformColors() for description of parameters.
|
||||
void SetUniformColors (Standard_Real theLightness,
|
||||
Standard_Real theHueFrom, Standard_Real theHueTo)
|
||||
void SetUniformColors(Standard_Real theLightness,
|
||||
Standard_Real theHueFrom,
|
||||
Standard_Real theHueTo)
|
||||
{
|
||||
SetColors (MakeUniformColors (myNbIntervals, theLightness, theHueFrom, theHueTo));
|
||||
SetColorType (Aspect_TOCSD_USER);
|
||||
SetColors(MakeUniformColors(myNbIntervals, theLightness, theHueFrom, theHueTo));
|
||||
SetColorType(Aspect_TOCSD_USER);
|
||||
}
|
||||
|
||||
//! Generates sequence of colors of the same lightness value in CIE Lch
|
||||
@ -250,26 +266,29 @@ public:
|
||||
//! lightness of pure blue)
|
||||
//! @param theHueFrom - hue value at the start of the scale
|
||||
//! @param theHueTo - hue value defining the end of the scale
|
||||
//!
|
||||
//!
|
||||
//! Hue value can be out of the range [0, 360], interpreted as modulo 360.
|
||||
//! The colors of the scale will be in the order of increasing hue if
|
||||
//! theHueTo > theHueFrom, and decreasing otherwise.
|
||||
Standard_EXPORT static Aspect_SequenceOfColor
|
||||
MakeUniformColors (Standard_Integer theNbColors, Standard_Real theLightness,
|
||||
Standard_Real theHueFrom, Standard_Real theHueTo);
|
||||
Standard_EXPORT static Aspect_SequenceOfColor MakeUniformColors(Standard_Integer theNbColors,
|
||||
Standard_Real theLightness,
|
||||
Standard_Real theHueFrom,
|
||||
Standard_Real theHueTo);
|
||||
|
||||
//! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by default.
|
||||
//! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by
|
||||
//! default.
|
||||
Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; }
|
||||
|
||||
//! Sets the color scale labels position relative to color bar.
|
||||
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.
|
||||
Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; }
|
||||
|
||||
//! Sets the color scale title position.
|
||||
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.
|
||||
//! - 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; }
|
||||
|
||||
//! 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
|
||||
//! should be linearly interpolated, FALSE by default.
|
||||
Standard_Boolean IsSmoothTransition() const { return myIsSmooth; }
|
||||
|
||||
//! 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.
|
||||
//! 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).
|
||||
//! 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.
|
||||
Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; }
|
||||
|
||||
//! 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.
|
||||
//! Note that list is automatically resized to include specified index.
|
||||
//! @param theLabel new label text
|
||||
//! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1] if IsLabelAtBorder() is true;
|
||||
//! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1]
|
||||
//! if IsLabelAtBorder() is true;
|
||||
//! label is appended to the end of list if negative index is specified
|
||||
Standard_EXPORT void SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex);
|
||||
Standard_EXPORT void SetLabel(const TCollection_ExtendedString& theLabel,
|
||||
const Standard_Integer theIndex);
|
||||
|
||||
//! Returns the size of color bar, 0 and 0 by default
|
||||
//! (e.g. should be set by user explicitly before displaying).
|
||||
void GetSize (Standard_Integer& theBreadth, Standard_Integer& theHeight) const
|
||||
void GetSize(Standard_Integer& theBreadth, Standard_Integer& theHeight) const
|
||||
{
|
||||
theBreadth = myBreadth;
|
||||
theHeight = myHeight;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
myHeight = theHeight;
|
||||
@ -329,24 +350,24 @@ public:
|
||||
Standard_Integer GetBreadth() const { return myBreadth; }
|
||||
|
||||
//! 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
|
||||
//! (e.g. should be set by user explicitly before displaying).
|
||||
Standard_Integer GetHeight() const { return myHeight; }
|
||||
|
||||
//! 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.
|
||||
void GetPosition (Standard_Real& theX, Standard_Real& theY) const
|
||||
void GetPosition(Standard_Real& theX, Standard_Real& theY) const
|
||||
{
|
||||
theX = myXPos;
|
||||
theY = myYPos;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
myYPos = theY;
|
||||
@ -356,67 +377,69 @@ public:
|
||||
Standard_Integer GetXPosition() const { return myXPos; }
|
||||
|
||||
//! 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.
|
||||
Standard_Integer GetYPosition() const { return myYPos; }
|
||||
|
||||
//! 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.
|
||||
Standard_Integer GetTextHeight() const { return myTextHeight; }
|
||||
|
||||
//! 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:
|
||||
|
||||
//! Returns the width of text.
|
||||
//! @param[in] theText the text of which to calculate width.
|
||||
Standard_EXPORT Standard_Integer TextWidth (const TCollection_ExtendedString& theText) const;
|
||||
Standard_EXPORT Standard_Integer TextWidth(const TCollection_ExtendedString& theText) const;
|
||||
|
||||
//! Returns the height of text.
|
||||
//! @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,
|
||||
const Standard_Integer theHeight,
|
||||
Standard_Integer& theWidth,
|
||||
Standard_Integer& theAscent,
|
||||
Standard_Integer& theDescent) const;
|
||||
Standard_EXPORT void TextSize(const TCollection_ExtendedString& theText,
|
||||
const Standard_Integer theHeight,
|
||||
Standard_Integer& theWidth,
|
||||
Standard_Integer& theAscent,
|
||||
Standard_Integer& theDescent) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Return true if specified display mode is supported.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
|
||||
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode == 0;
|
||||
}
|
||||
|
||||
//! Compute presentation.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection - not implemented for color scale.
|
||||
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||
const Standard_Integer /*aMode*/) Standard_OVERRIDE {}
|
||||
virtual void ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||
const Standard_Integer /*aMode*/) Standard_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Returns the size of color scale.
|
||||
//! @param[out] theWidth the width of color scale.
|
||||
//! @param[out] theHeight the height of color scale.
|
||||
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.
|
||||
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.
|
||||
//! @param[in] theValue the current value of interval
|
||||
//! @param[in] theMin the min value of interval
|
||||
//! @param[in] theMax the max value of interval
|
||||
Quantity_Color colorFromValue (const Standard_Real theValue,
|
||||
const Standard_Real theMin,
|
||||
const Standard_Real theMax) const;
|
||||
Quantity_Color colorFromValue(const Standard_Real theValue,
|
||||
const Standard_Real theMin,
|
||||
const Standard_Real theMax) const;
|
||||
|
||||
//! Initialize text aspect for drawing the labels.
|
||||
void updateTextAspect();
|
||||
@ -427,28 +450,29 @@ private:
|
||||
//! @param[in] theX X coordinate of text position
|
||||
//! @param[in] theY Y coordinate of text position
|
||||
//! @param[in] theVertAlignment text vertical alignment
|
||||
void drawText (const Handle(Graphic3d_Group)& theGroup,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const Standard_Integer theX, const Standard_Integer theY,
|
||||
const Graphic3d_VerticalTextAlignment theVertAlignment);
|
||||
void drawText(const Handle(Graphic3d_Group)& theGroup,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Graphic3d_VerticalTextAlignment theVertAlignment);
|
||||
|
||||
//! 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.
|
||||
void drawLabels (const Handle(Graphic3d_Group)& theGroup,
|
||||
const TColStd_SequenceOfExtendedString& theLabels,
|
||||
const Standard_Integer theBarBottom,
|
||||
const Standard_Integer theBarHeight,
|
||||
const Standard_Integer theMaxLabelWidth,
|
||||
const Standard_Integer theColorBreadth);
|
||||
void drawLabels(const Handle(Graphic3d_Group)& theGroup,
|
||||
const TColStd_SequenceOfExtendedString& theLabels,
|
||||
const Standard_Integer theBarBottom,
|
||||
const Standard_Integer theBarHeight,
|
||||
const Standard_Integer theMaxLabelWidth,
|
||||
const Standard_Integer theColorBreadth);
|
||||
|
||||
//! Draw a color bar.
|
||||
void drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theBarBottom,
|
||||
const Standard_Integer theBarHeight,
|
||||
const Standard_Integer theMaxLabelWidth,
|
||||
const Standard_Integer theColorBreadth);
|
||||
void drawColorBar(const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theBarBottom,
|
||||
const Standard_Integer theBarHeight,
|
||||
const Standard_Integer theMaxLabelWidth,
|
||||
const Standard_Integer theColorBreadth);
|
||||
|
||||
//! Draw a frame.
|
||||
//! @param[in] theX the X coordinate of frame position.
|
||||
@ -456,16 +480,17 @@ private:
|
||||
//! @param[in] theWidth the width of frame.
|
||||
//! @param[in] theHeight the height of frame.
|
||||
//! @param[in] theColor the color of frame.
|
||||
void drawFrame (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theX, const Standard_Integer theY,
|
||||
const Standard_Integer theWidth, const Standard_Integer theHeight,
|
||||
const Quantity_Color& theColor);
|
||||
void drawFrame(const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Standard_Integer theWidth,
|
||||
const Standard_Integer theHeight,
|
||||
const Quantity_Color& theColor);
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myMin; //!< values range - minimal value
|
||||
Standard_Real myMax; //!< values range - maximal value
|
||||
// clang-format off
|
||||
Standard_Real myMin; //!< values range - minimal value
|
||||
Standard_Real myMax; //!< values range - maximal value
|
||||
// clang-format off
|
||||
Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value
|
||||
Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value
|
||||
TCollection_ExtendedString myTitle; //!< optional title string
|
||||
@ -480,15 +505,14 @@ private:
|
||||
Aspect_SequenceOfColor myColors; //!< sequence of custom colors
|
||||
TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels
|
||||
Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale
|
||||
// clang-format on
|
||||
Aspect_TypeOfColorScalePosition myTitlePos; //!< title position
|
||||
Standard_Integer myXPos; //!< left position
|
||||
Standard_Integer myYPos; //!< bottom position
|
||||
Standard_Integer myBreadth; //!< color scale breadth
|
||||
Standard_Integer myHeight; //!< height of the color scale
|
||||
Standard_Integer mySpacing; //!< extra spacing between element
|
||||
Standard_Integer myTextHeight; //!< label font height
|
||||
|
||||
// clang-format on
|
||||
Aspect_TypeOfColorScalePosition myTitlePos; //!< title position
|
||||
Standard_Integer myXPos; //!< left position
|
||||
Standard_Integer myYPos; //!< bottom position
|
||||
Standard_Integer myBreadth; //!< color scale breadth
|
||||
Standard_Integer myHeight; //!< height of the color scale
|
||||
Standard_Integer mySpacing; //!< extra spacing between element
|
||||
Standard_Integer myTextHeight; //!< label font height
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,45 +22,51 @@ class AIS_ColoredDrawer : public Prs3d_Drawer
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ColoredDrawer, Prs3d_Drawer)
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
|
||||
: myIsHidden (false),
|
||||
myHasOwnMaterial(false),
|
||||
myHasOwnColor (false),
|
||||
myHasOwnTransp(false),
|
||||
myHasOwnWidth (false)
|
||||
AIS_ColoredDrawer(const Handle(Prs3d_Drawer)& theLink)
|
||||
: myIsHidden(false),
|
||||
myHasOwnMaterial(false),
|
||||
myHasOwnColor(false),
|
||||
myHasOwnTransp(false),
|
||||
myHasOwnWidth(false)
|
||||
{
|
||||
Link (theLink);
|
||||
Link(theLink);
|
||||
}
|
||||
|
||||
bool IsHidden() const { return myIsHidden; }
|
||||
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
|
||||
bool IsHidden() const { return myIsHidden; }
|
||||
|
||||
bool HasOwnMaterial() const { return myHasOwnMaterial; }
|
||||
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
|
||||
void SetOwnMaterial() { myHasOwnMaterial = true; }
|
||||
void SetHidden(const bool theToHide) { myIsHidden = theToHide; }
|
||||
|
||||
bool HasOwnColor() const { return myHasOwnColor; }
|
||||
void UnsetOwnColor() { myHasOwnColor = false; }
|
||||
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
|
||||
bool HasOwnMaterial() const { return myHasOwnMaterial; }
|
||||
|
||||
bool HasOwnTransparency() const { return myHasOwnTransp; }
|
||||
void UnsetOwnTransparency() { myHasOwnTransp = false; }
|
||||
void SetOwnTransparency (Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
|
||||
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
|
||||
|
||||
bool HasOwnWidth() const { return myHasOwnWidth; }
|
||||
void UnsetOwnWidth() { myHasOwnWidth = false; }
|
||||
void SetOwnWidth (const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
|
||||
void SetOwnMaterial() { myHasOwnMaterial = 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 myHasOwnMaterial;
|
||||
bool myHasOwnColor;
|
||||
bool myHasOwnTransp;
|
||||
bool myHasOwnWidth;
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_ColoredDrawer, Prs3d_Drawer)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,39 +28,36 @@ class StdSelect_BRepOwner;
|
||||
class AIS_ColoredShape : public AIS_Shape
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
Standard_EXPORT AIS_ColoredShape (const TopoDS_Shape& theShape);
|
||||
Standard_EXPORT AIS_ColoredShape(const TopoDS_Shape& theShape);
|
||||
|
||||
//! 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
|
||||
|
||||
//! Customize properties of specified sub-shape.
|
||||
//! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape!
|
||||
//! This method can be used to mark sub-shapes with customizable properties.
|
||||
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.
|
||||
Standard_EXPORT virtual void ClearCustomAspects();
|
||||
|
||||
//! Reset custom properties of specified sub-shape.
|
||||
//! @param theToUnregister unregister or not sub-shape from the map
|
||||
Standard_EXPORT void UnsetCustomAspects (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theToUnregister = Standard_False);
|
||||
Standard_EXPORT void UnsetCustomAspects(const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theToUnregister = Standard_False);
|
||||
|
||||
//! Customize color of specified sub-shape
|
||||
Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape,
|
||||
const Quantity_Color& theColor);
|
||||
Standard_EXPORT void SetCustomColor(const TopoDS_Shape& theShape, const Quantity_Color& theColor);
|
||||
|
||||
//! Customize transparency of specified sub-shape
|
||||
Standard_EXPORT void SetCustomTransparency (const TopoDS_Shape& theShape,
|
||||
Standard_Real theTransparency);
|
||||
Standard_EXPORT void SetCustomTransparency(const TopoDS_Shape& theShape,
|
||||
Standard_Real theTransparency);
|
||||
|
||||
//! Customize line width of specified sub-shape
|
||||
Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLineWidth);
|
||||
Standard_EXPORT void SetCustomWidth(const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLineWidth);
|
||||
|
||||
//! Return the map of custom aspects.
|
||||
const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; }
|
||||
@ -69,21 +66,20 @@ public: //! @name sub-shape aspects
|
||||
AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; }
|
||||
|
||||
public: //! @name global aspects
|
||||
|
||||
//! Setup color of entire shape.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
|
||||
//! 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.
|
||||
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.
|
||||
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theAspect)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Removes the setting for transparency in the reconstructed compound shape.
|
||||
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
|
||||
|
||||
@ -91,22 +87,20 @@ public:
|
||||
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
|
||||
|
||||
protected: //! @name override presentation computation
|
||||
|
||||
//! Compute presentation considering sub-shape color map.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection considering sub-shape hidden state.
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
||||
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound> DataMapOfDrawerCompd;
|
||||
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound>
|
||||
DataMapOfDrawerCompd;
|
||||
|
||||
protected:
|
||||
|
||||
//! Recursive function to map shapes.
|
||||
//! @param theParentDrawer the drawer to be used for undetailed shapes (default colors)
|
||||
//! @param theShapeToParse the subshape to be recursively parsed
|
||||
@ -115,41 +109,45 @@ protected:
|
||||
//! @param theIsParentClosed flag indicating that specified shape is part of closed Solid
|
||||
//! @param theDrawerOpenedShapePerType the array of shape types to fill
|
||||
//! @param theDrawerClosedFaces the map for closed faces
|
||||
Standard_EXPORT static Standard_Boolean dispatchColors (const Handle(AIS_ColoredDrawer)& theParentDrawer,
|
||||
const TopoDS_Shape& theShapeToParse,
|
||||
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
|
||||
const TopAbs_ShapeEnum theParentType,
|
||||
const Standard_Boolean theIsParentClosed,
|
||||
DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
|
||||
DataMapOfDrawerCompd& theDrawerClosedFaces);
|
||||
protected:
|
||||
Standard_EXPORT static Standard_Boolean dispatchColors(
|
||||
const Handle(AIS_ColoredDrawer)& theParentDrawer,
|
||||
const TopoDS_Shape& theShapeToParse,
|
||||
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
|
||||
const TopAbs_ShapeEnum theParentType,
|
||||
const Standard_Boolean theIsParentClosed,
|
||||
DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
|
||||
DataMapOfDrawerCompd& theDrawerClosedFaces);
|
||||
|
||||
protected:
|
||||
//! 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.
|
||||
Standard_EXPORT void fillSubshapeDrawerMap (AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const;
|
||||
//! This needed when colored shape is not part of BaseShape (but subshapes are) and actually
|
||||
//! container for subshapes.
|
||||
Standard_EXPORT void fillSubshapeDrawerMap(AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const;
|
||||
|
||||
//! Add shape to presentation
|
||||
//! @param thePrs the presentation
|
||||
//! @param theDrawerOpenedShapePerType the shapes map with unique attributes
|
||||
//! @param theDrawerClosedFaces the map of attributes for closed faces
|
||||
//! @param theMode display mode
|
||||
Standard_EXPORT void addShapesWithCustomProps (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
|
||||
const DataMapOfDrawerCompd& theDrawerClosedFaces,
|
||||
const Standard_Integer theMode);
|
||||
Standard_EXPORT void addShapesWithCustomProps(
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
|
||||
const DataMapOfDrawerCompd& theDrawerClosedFaces,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
//! Check all shapes from myShapeColorsfor visibility
|
||||
Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const;
|
||||
|
||||
//! Resolve (parse) theKeyShape into subshapes, search in they for theBaseShape,
|
||||
//! bind all resolved subshapes with theOriginKeyShape and store all binds in theShapeDrawerMap
|
||||
//! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape -> theOriginKeyShape
|
||||
//! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape ->
|
||||
//! theOriginKeyShape
|
||||
//! @param theKeyShape a shape to be resolved (parse) into smaller (in topological sense)
|
||||
//! subshapes for new bind cycle
|
||||
//! @param theDrawer assigned drawer
|
||||
Standard_EXPORT void bindSubShapes (AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
|
||||
const TopoDS_Shape& theKeyShape,
|
||||
const Handle(AIS_ColoredDrawer)& theDrawer) const;
|
||||
Standard_EXPORT void bindSubShapes(AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
|
||||
const TopoDS_Shape& theKeyShape,
|
||||
const Handle(AIS_ColoredDrawer)& theDrawer) const;
|
||||
|
||||
//! Add sub-shape to selection considering hidden state (recursively).
|
||||
//! @param theParentDrawer drawer of parent shape
|
||||
@ -160,24 +158,21 @@ protected:
|
||||
//! @param theTypOfSel type of selection
|
||||
//! @param theDeflection linear deflection
|
||||
//! @param theDeflAngle angular deflection
|
||||
Standard_EXPORT void computeSubshapeSelection (const Handle(AIS_ColoredDrawer)& theParentDrawer,
|
||||
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(StdSelect_BRepOwner)& theOwner,
|
||||
const Handle(SelectMgr_Selection)& theSelection,
|
||||
const TopAbs_ShapeEnum theTypOfSel,
|
||||
const Standard_Integer thePriority,
|
||||
const Standard_Real theDeflection,
|
||||
const Standard_Real theDeflAngle);
|
||||
Standard_EXPORT void computeSubshapeSelection(const Handle(AIS_ColoredDrawer)& theParentDrawer,
|
||||
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(StdSelect_BRepOwner)& theOwner,
|
||||
const Handle(SelectMgr_Selection)& theSelection,
|
||||
const TopAbs_ShapeEnum theTypOfSel,
|
||||
const Standard_Integer thePriority,
|
||||
const Standard_Real theDeflection,
|
||||
const Standard_Real theDeflAngle);
|
||||
|
||||
protected:
|
||||
|
||||
AIS_DataMapOfShapeDrawer myShapeColors;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape,AIS_Shape)
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape, AIS_Shape)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape)
|
||||
|
@ -31,32 +31,30 @@
|
||||
#include <StdSelect_BRepOwner.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_InteractiveObject(aTypeOfPresentation3d)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_ConnectedInteractive::AIS_ConnectedInteractive(
|
||||
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
|
||||
: AIS_InteractiveObject(aTypeOfPresentation3d)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : connect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation)
|
||||
{
|
||||
if (myReference == theAnotherObj)
|
||||
{
|
||||
setLocalTransformation (theLocation);
|
||||
setLocalTransformation(theLocation);
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj);
|
||||
Handle(AIS_ConnectedInteractive) aConnected =
|
||||
Handle(AIS_ConnectedInteractive)::DownCast(theAnotherObj);
|
||||
if (!aConnected.IsNull())
|
||||
{
|
||||
myReference = aConnected->myReference;
|
||||
@ -67,59 +65,57 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - object without own presentation can not be connected");
|
||||
throw Standard_ProgramError(
|
||||
"AIS_ConnectedInteractive::Connect() - object without own presentation can not be connected");
|
||||
}
|
||||
|
||||
if (!myReference.IsNull())
|
||||
{
|
||||
if (myReference->HasInteractiveContext()
|
||||
&& myReference->GetContext()->DisplayStatus (myReference) != AIS_DS_None)
|
||||
&& myReference->GetContext()->DisplayStatus(myReference) != AIS_DS_None)
|
||||
{
|
||||
myReference.Nullify();
|
||||
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should NOT be displayed in context");
|
||||
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should "
|
||||
"NOT be displayed in context");
|
||||
}
|
||||
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
|
||||
}
|
||||
setLocalTransformation (theLocation);
|
||||
setLocalTransformation(theLocation);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Disconnect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
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();
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (HasConnection())
|
||||
{
|
||||
thePrs->Clear (Standard_False);
|
||||
thePrs->DisconnectAll (Graphic3d_TOC_DESCENDANT);
|
||||
thePrs->Clear(Standard_False);
|
||||
thePrs->DisconnectAll(Graphic3d_TOC_DESCENDANT);
|
||||
|
||||
if (!myReference->HasInteractiveContext())
|
||||
{
|
||||
myReference->SetContext (GetContext());
|
||||
myReference->SetContext(GetContext());
|
||||
}
|
||||
thePrsMgr->Connect (this, myReference, theMode, theMode);
|
||||
if (thePrsMgr->Presentation (myReference, theMode)->MustBeUpdated())
|
||||
thePrsMgr->Connect(this, myReference, theMode, theMode);
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& thePresentation)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ConnectedInteractive::computeHLR(const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(TopLoc_Datum3D)& theTransformation,
|
||||
const Handle(Prs3d_Presentation)& thePresentation)
|
||||
{
|
||||
const bool hasTrsf = !theTransformation.IsNull()
|
||||
&& theTransformation->Form() != gp_Identity;
|
||||
updateShape (!hasTrsf);
|
||||
const bool hasTrsf = !theTransformation.IsNull() && theTransformation->Form() != gp_Identity;
|
||||
updateShape(!hasTrsf);
|
||||
if (myShape.IsNull())
|
||||
{
|
||||
return;
|
||||
@ -147,49 +140,45 @@ void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& thePr
|
||||
if (hasTrsf)
|
||||
{
|
||||
const TopLoc_Location& aLocation = myShape.Location();
|
||||
TopoDS_Shape aShape = myShape.Located (TopLoc_Location (theTransformation->Trsf()) * aLocation);
|
||||
AIS_Shape::computeHlrPresentation (theProjector, thePresentation, aShape, myDrawer);
|
||||
TopoDS_Shape aShape = myShape.Located(TopLoc_Location(theTransformation->Trsf()) * aLocation);
|
||||
AIS_Shape::computeHlrPresentation(theProjector, thePresentation, aShape, myDrawer);
|
||||
}
|
||||
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())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
TopoDS_Shape aShape = anAisShape->Shape();
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isWithLocation)
|
||||
if (!isWithLocation)
|
||||
{
|
||||
myShape = aShape;
|
||||
}
|
||||
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())
|
||||
{
|
||||
@ -198,27 +187,30 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
|
||||
|
||||
if (theMode != 0 && myReference->AcceptShapeDecomposition())
|
||||
{
|
||||
computeSubShapeSelection (theSelection, theMode);
|
||||
computeSubShapeSelection(theSelection, theMode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myReference->HasSelection (theMode))
|
||||
if (!myReference->HasSelection(theMode))
|
||||
{
|
||||
myReference->RecomputePrimitives (theMode);
|
||||
myReference->RecomputePrimitives(theMode);
|
||||
}
|
||||
|
||||
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection (theMode);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
|
||||
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(theMode);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
|
||||
|
||||
TopLoc_Location aLocation (Transformation());
|
||||
anOwner->SetLocation (aLocation);
|
||||
TopLoc_Location aLocation(Transformation());
|
||||
anOwner->SetLocation(aLocation);
|
||||
|
||||
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())
|
||||
{
|
||||
@ -226,67 +218,73 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
|
||||
if (Handle(Select3D_SensitiveEntity) aNewSensitive = aSensitive->GetConnected())
|
||||
{
|
||||
aNewSensitive->Set(anOwner);
|
||||
theSelection->Add (aNewSensitive);
|
||||
theSelection->Add(aNewSensitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSubShapeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ConnectedInteractive::computeSubShapeSelection(
|
||||
const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
|
||||
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList>
|
||||
Shapes2EntitiesMap;
|
||||
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList> Shapes2EntitiesMap;
|
||||
|
||||
if (!myReference->HasSelection (theMode))
|
||||
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)
|
||||
{
|
||||
myReference->RecomputePrimitives (theMode);
|
||||
myReference->RecomputePrimitives(theMode);
|
||||
}
|
||||
|
||||
// Fill in the map of subshapes and corresponding sensitive entities associated with aMode
|
||||
Shapes2EntitiesMap aShapes2EntitiesMap;
|
||||
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
|
||||
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
|
||||
aRefSel->Entities());
|
||||
aSelEntIter.More();
|
||||
aSelEntIter.Next())
|
||||
{
|
||||
if (const Handle(Select3D_SensitiveEntity)& aSE = aSelEntIter.Value()->BaseSensitive())
|
||||
{
|
||||
if (Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId()))
|
||||
if (Handle(StdSelect_BRepOwner) anOwner =
|
||||
Handle(StdSelect_BRepOwner)::DownCast(aSE->OwnerId()))
|
||||
{
|
||||
const TopoDS_Shape& aSubShape = anOwner->Shape();
|
||||
if(!aShapes2EntitiesMap.IsBound (aSubShape))
|
||||
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
|
||||
for (Shapes2EntitiesMap::Iterator aMapIt (aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
|
||||
for (Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
|
||||
{
|
||||
const SensitiveList& aSEList = aMapIt.Value();
|
||||
Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner (aMapIt.Key(), this, aSEList.First()->OwnerId()->Priority(), Standard_True);
|
||||
anOwner->SetLocation (Transformation());
|
||||
for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next())
|
||||
const SensitiveList& aSEList = aMapIt.Value();
|
||||
Handle(StdSelect_BRepOwner) anOwner =
|
||||
new StdSelect_BRepOwner(aMapIt.Key(),
|
||||
this,
|
||||
aSEList.First()->OwnerId()->Priority(),
|
||||
Standard_True);
|
||||
anOwner->SetLocation(Transformation());
|
||||
for (SensitiveList::Iterator aListIt(aSEList); aListIt.More(); aListIt.Next())
|
||||
{
|
||||
if (Handle(Select3D_SensitiveEntity) aNewSE = aListIt.Value()->GetConnected())
|
||||
{
|
||||
aNewSE->Set (anOwner);
|
||||
theSelection->Add (aNewSE);
|
||||
aNewSE->Set(anOwner);
|
||||
theSelection->Add(aNewSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StdSelect::SetDrawerForBRepOwner (theSelection, myDrawer);
|
||||
StdSelect::SetDrawerForBRepOwner(theSelection, myDrawer);
|
||||
}
|
||||
|
@ -37,34 +37,45 @@ class AIS_ConnectedInteractive : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Disconnects the previous view and sets highlight
|
||||
//! mode to 0. This highlights the wireframe presentation
|
||||
//! aTypeOfPresentation3d.
|
||||
//! Top_AllView deactivates hidden line removal.
|
||||
Standard_EXPORT AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
|
||||
|
||||
Standard_EXPORT AIS_ConnectedInteractive(
|
||||
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
|
||||
|
||||
//! Returns KOI_Object
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Object; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Object;
|
||||
}
|
||||
|
||||
//! Returns 0
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
|
||||
//! Establishes the connection between the Connected
|
||||
//! Interactive Object, anotherIobj, and its reference.
|
||||
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(TopLoc_Datum3D)()); }
|
||||
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj)
|
||||
{
|
||||
connect(theAnotherObj, Handle(TopLoc_Datum3D)());
|
||||
}
|
||||
|
||||
//! Establishes the connection between the Connected
|
||||
//! Interactive Object, anotherIobj, and its reference.
|
||||
//! Locates instance in aLocation.
|
||||
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); }
|
||||
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj, const gp_Trsf& theLocation)
|
||||
{
|
||||
connect(theAnotherObj, new TopLoc_Datum3D(theLocation));
|
||||
}
|
||||
|
||||
//! Establishes the connection between the Connected
|
||||
//! Interactive Object, anotherIobj, and its reference.
|
||||
//! Locates instance in aLocation.
|
||||
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); }
|
||||
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation)
|
||||
{
|
||||
connect(theAnotherObj, theLocation);
|
||||
}
|
||||
|
||||
//! Returns true if there is a connection established
|
||||
//! between the presentation and its source reference.
|
||||
@ -86,14 +97,12 @@ public:
|
||||
}
|
||||
|
||||
//! 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()
|
||||
|| myReference->AcceptDisplayMode (theMode);
|
||||
return myReference.IsNull() || myReference->AcceptDisplayMode(theMode);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Calculates the view aPresentation and its updates.
|
||||
//! The latter are managed by aPresentationManager.
|
||||
//! The display mode aMode is 0 by default.
|
||||
@ -103,35 +112,36 @@ protected:
|
||||
//! compute anything, but just uses the
|
||||
//! presentation of this last object, with
|
||||
//! a transformation if there's one stored.
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& theprs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Computes the presentation according to a point of view.
|
||||
Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(TopLoc_Datum3D)& theTrsf,
|
||||
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void computeHLR(const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(TopLoc_Datum3D)& theTrsf,
|
||||
const Handle(Prs3d_Presentation)& thePrs)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Generates sensitive entities by copying
|
||||
//! them from myReference selection, creates and sets an entity
|
||||
//! owner for this entities and adds them to theSelection
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Generates sensitive entities by copying
|
||||
//! them from myReference sub shapes selection, creates and sets an entity
|
||||
//! owner for this entities and adds them to theSelection
|
||||
Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
|
||||
Standard_EXPORT void computeSubShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
|
||||
Standard_EXPORT void updateShape(const Standard_Boolean WithLocation = Standard_True);
|
||||
|
||||
Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation);
|
||||
Standard_EXPORT void connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(AIS_InteractiveObject) myReference;
|
||||
TopoDS_Shape myShape;
|
||||
|
||||
TopoDS_Shape myShape;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)
|
||||
|
@ -11,7 +11,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile
|
||||
#define AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile
|
||||
|
||||
|
@ -21,8 +21,9 @@
|
||||
#include <AIS_GlobalStatus.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus)> AIS_DataMapOfIOStatus;
|
||||
typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus)>::Iterator AIS_DataMapIteratorOfDataMapOfIOStatus;
|
||||
|
||||
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), Handle(AIS_GlobalStatus)>
|
||||
AIS_DataMapOfIOStatus;
|
||||
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), Handle(AIS_GlobalStatus)>::Iterator
|
||||
AIS_DataMapIteratorOfDataMapOfIOStatus;
|
||||
|
||||
#endif
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <TopTools_ShapeMapHasher.hxx>
|
||||
|
||||
typedef NCollection_DataMap<TopoDS_Shape, Handle(AIS_ColoredDrawer), TopTools_ShapeMapHasher> AIS_DataMapOfShapeDrawer;
|
||||
typedef NCollection_DataMap<TopoDS_Shape, Handle(AIS_ColoredDrawer), TopTools_ShapeMapHasher>
|
||||
AIS_DataMapOfShapeDrawer;
|
||||
|
||||
#endif // _AIS_DataMapOfShapeDrawer_HeaderFile
|
||||
|
@ -17,15 +17,14 @@
|
||||
#ifndef _AIS_DisplayMode_HeaderFile
|
||||
#define _AIS_DisplayMode_HeaderFile
|
||||
|
||||
|
||||
//! Sets display modes other than neutral point ones,
|
||||
//! for interactive objects. The possibilities include:
|
||||
//! - wireframe,
|
||||
//! - shaded,
|
||||
enum AIS_DisplayMode
|
||||
{
|
||||
AIS_WireFrame,
|
||||
AIS_Shaded
|
||||
AIS_WireFrame,
|
||||
AIS_Shaded
|
||||
};
|
||||
|
||||
#endif // _AIS_DisplayMode_HeaderFile
|
||||
|
@ -14,7 +14,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AIS_ExclusionFilter.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
@ -22,55 +21,52 @@
|
||||
#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.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,
|
||||
const Standard_Boolean ExclusionFlagOn):
|
||||
myIsExclusionFlagOn(ExclusionFlagOn)
|
||||
const Standard_Boolean ExclusionFlagOn)
|
||||
: myIsExclusionFlagOn(ExclusionFlagOn)
|
||||
{
|
||||
TColStd_ListOfInteger L;
|
||||
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
|
||||
myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
|
||||
}
|
||||
|
||||
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
|
||||
const Standard_Integer SignatureInType,
|
||||
const Standard_Boolean ExclusionFlagOn):
|
||||
myIsExclusionFlagOn(ExclusionFlagOn)
|
||||
const Standard_Integer SignatureInType,
|
||||
const Standard_Boolean ExclusionFlagOn)
|
||||
: myIsExclusionFlagOn(ExclusionFlagOn)
|
||||
{
|
||||
TColStd_ListOfInteger L;
|
||||
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;
|
||||
TColStd_ListOfInteger L;
|
||||
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
|
||||
myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
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;
|
||||
L.Append(SignatureInType);
|
||||
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
|
||||
myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@ -78,26 +74,27 @@ Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExcl
|
||||
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.UnBind((Standard_Integer)TypeToExclude);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
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);
|
||||
for(TColStd_ListIteratorOfListOfInteger it(LL);it.More();it.Next()){
|
||||
if(it.Value()==SignatureInType){
|
||||
for (TColStd_ListIteratorOfListOfInteger it(LL); it.More(); it.Next())
|
||||
{
|
||||
if (it.Value() == SignatureInType)
|
||||
{
|
||||
LL.Remove(it);
|
||||
return Standard_True;
|
||||
}
|
||||
@ -105,105 +102,82 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_ExclusionFilter::Clear()
|
||||
void AIS_ExclusionFilter::Clear()
|
||||
{
|
||||
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger Mit(myStoredTypes);
|
||||
for(;Mit.More();Mit.Next())
|
||||
for (; Mit.More(); Mit.Next())
|
||||
myStoredTypes.ChangeFind(Mit.Key()).Clear();
|
||||
myStoredTypes.Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsStored
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_ExclusionFilter::IsStored(const AIS_KindOfInteractive aType) const
|
||||
{
|
||||
return myStoredTypes.IsBound(Standard_Integer(aType));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSignatureIn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_ExclusionFilter::IsSignatureIn(const AIS_KindOfInteractive aType,
|
||||
const Standard_Integer SignatureInType) const
|
||||
const Standard_Integer SignatureInType) const
|
||||
{
|
||||
if(!myStoredTypes.IsBound(aType)) return Standard_False;
|
||||
for(TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType));
|
||||
Lit.More();
|
||||
Lit.Next()){
|
||||
if(Lit.Value()==SignatureInType)
|
||||
if (!myStoredTypes.IsBound(aType))
|
||||
return Standard_False;
|
||||
for (TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType)); Lit.More();
|
||||
Lit.Next())
|
||||
{
|
||||
if (Lit.Value() == SignatureInType)
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ListOfStoredTypes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) const
|
||||
{
|
||||
TheList.Clear();
|
||||
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger MIT(myStoredTypes);
|
||||
for(;MIT.More();MIT.Next())
|
||||
for (; MIT.More(); MIT.Next())
|
||||
TheList.Append(MIT.Key());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ListOfSignature
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,TColStd_ListOfInteger& TheStoredList) const
|
||||
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,
|
||||
TColStd_ListOfInteger& TheStoredList) const
|
||||
{
|
||||
TheStoredList.Clear();
|
||||
if(IsStored(aType))
|
||||
for(TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType));it.More();it.Next())
|
||||
if (IsStored(aType))
|
||||
for (TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType)); it.More(); it.Next())
|
||||
TheStoredList.Append(it.Value());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsOk
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
|
||||
{
|
||||
if(myStoredTypes.IsEmpty())
|
||||
if (myStoredTypes.IsEmpty())
|
||||
return myIsExclusionFlagOn;
|
||||
|
||||
if(EO.IsNull())
|
||||
if (EO.IsNull())
|
||||
return Standard_False;
|
||||
Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
|
||||
if(IO.IsNull())
|
||||
if (IO.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// type of AIS is not in the map...
|
||||
if(!myStoredTypes.IsBound(IO->Type()))
|
||||
return myIsExclusionFlagOn ;
|
||||
if (!myStoredTypes.IsBound(IO->Type()))
|
||||
return myIsExclusionFlagOn;
|
||||
// type of AIS is not in the map and there is no signature indicated
|
||||
if(myStoredTypes(IO->Type()).IsEmpty())
|
||||
return !myIsExclusionFlagOn ;
|
||||
// one or several signatures are indicated...
|
||||
if(IsSignatureIn(IO->Type(),IO->Signature()))
|
||||
if (myStoredTypes(IO->Type()).IsEmpty())
|
||||
return !myIsExclusionFlagOn;
|
||||
|
||||
// one or several signatures are indicated...
|
||||
if (IsSignatureIn(IO->Type(), IO->Signature()))
|
||||
return !myIsExclusionFlagOn;
|
||||
|
||||
return myIsExclusionFlagOn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -48,55 +48,59 @@ class AIS_ExclusionFilter : public SelectMgr_Filter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Constructs an empty exclusion filter object defined by
|
||||
//! the flag setting ExclusionFlagOn.
|
||||
//! By default, the flag is set to true.
|
||||
Standard_EXPORT AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn = Standard_True);
|
||||
|
||||
|
||||
//! All the AIS objects of <TypeToExclude>
|
||||
//! Will be rejected by the IsOk Method.
|
||||
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, const Standard_Boolean ExclusionFlagOn = Standard_True);
|
||||
|
||||
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
|
||||
const Standard_Boolean ExclusionFlagOn = Standard_True);
|
||||
|
||||
//! Constructs an exclusion filter object defined by the
|
||||
//! enumeration value TypeToExclude, the signature
|
||||
//! SignatureInType, and the flag setting ExclusionFlagOn.
|
||||
//! By default, the flag is set to true.
|
||||
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType, const Standard_Boolean ExclusionFlagOn = Standard_True);
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const Standard_OVERRIDE;
|
||||
|
||||
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;
|
||||
|
||||
//! Adds the type TypeToExclude to the list of types.
|
||||
Standard_EXPORT Standard_Boolean Add (const AIS_KindOfInteractive TypeToExclude);
|
||||
|
||||
Standard_EXPORT Standard_Boolean Add (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
|
||||
|
||||
Standard_EXPORT Standard_Boolean Remove (const AIS_KindOfInteractive TypeToExclude);
|
||||
|
||||
Standard_EXPORT Standard_Boolean Remove (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
|
||||
|
||||
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 Remove(const AIS_KindOfInteractive TypeToExclude);
|
||||
|
||||
Standard_EXPORT Standard_Boolean Remove(const AIS_KindOfInteractive TypeToExclude,
|
||||
const Standard_Integer SignatureInType);
|
||||
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
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 void ListOfStoredTypes (TColStd_ListOfInteger& TheList) const;
|
||||
|
||||
Standard_EXPORT void ListOfSignature (const AIS_KindOfInteractive aType, TColStd_ListOfInteger& TheStoredList) const;
|
||||
Standard_EXPORT Standard_Boolean IsStored(const AIS_KindOfInteractive aType) const;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ExclusionFilter,SelectMgr_Filter)
|
||||
Standard_EXPORT void ListOfStoredTypes(TColStd_ListOfInteger& TheList) const;
|
||||
|
||||
Standard_EXPORT void ListOfSignature(const AIS_KindOfInteractive aType,
|
||||
TColStd_ListOfInteger& TheStoredList) const;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ExclusionFilter, SelectMgr_Filter)
|
||||
|
||||
private:
|
||||
Standard_EXPORT Standard_Boolean IsSignatureIn(const AIS_KindOfInteractive aType,
|
||||
const Standard_Integer aSignature) const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsSignatureIn (const AIS_KindOfInteractive aType, const Standard_Integer aSignature) const;
|
||||
|
||||
Standard_Boolean myIsExclusionFlagOn;
|
||||
Standard_Boolean myIsExclusionFlagOn;
|
||||
TColStd_DataMapOfIntegerListOfInteger myStoredTypes;
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_ExclusionFilter_HeaderFile
|
||||
|
@ -23,8 +23,8 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
AIS_GlobalStatus::AIS_GlobalStatus()
|
||||
: myDispMode (0),
|
||||
myIsHilit(Standard_False),
|
||||
mySubInt (Standard_False)
|
||||
{
|
||||
: myDispMode(0),
|
||||
myIsHilit(Standard_False),
|
||||
mySubInt(Standard_False)
|
||||
{
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class AIS_GlobalStatus : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT AIS_GlobalStatus();
|
||||
|
||||
@ -39,16 +38,16 @@ public:
|
||||
Standard_Integer DisplayMode() const { return myDispMode; }
|
||||
|
||||
//! 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
|
||||
Standard_Boolean IsHilighted() const { return myIsHilit; }
|
||||
|
||||
//! 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
|
||||
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
|
||||
const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; }
|
||||
@ -57,46 +56,41 @@ public:
|
||||
const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; }
|
||||
|
||||
//! 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.
|
||||
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_False;
|
||||
}
|
||||
|
||||
//! 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.
|
||||
void ClearSelectionModes()
|
||||
{
|
||||
mySelModes.Clear();
|
||||
}
|
||||
void ClearSelectionModes() { mySelModes.Clear(); }
|
||||
|
||||
Standard_Boolean IsSubIntensityOn() const { return mySubInt; }
|
||||
|
||||
void SetSubIntensity (Standard_Boolean theIsOn) { mySubInt = theIsOn; }
|
||||
void SetSubIntensity(Standard_Boolean theIsOn) { mySubInt = theIsOn; }
|
||||
|
||||
private:
|
||||
|
||||
TColStd_ListOfInteger mySelModes;
|
||||
Handle(Prs3d_Drawer) myHiStyle;
|
||||
Standard_Integer myDispMode;
|
||||
Standard_Boolean myIsHilit;
|
||||
Standard_Boolean mySubInt;
|
||||
|
||||
Handle(Prs3d_Drawer) myHiStyle;
|
||||
Standard_Integer myDispMode;
|
||||
Standard_Boolean myIsHilit;
|
||||
Standard_Boolean mySubInt;
|
||||
};
|
||||
|
||||
#endif // _AIS_GlobalStatus_HeaderFile
|
||||
|
@ -14,7 +14,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AIS_GraphicTool.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
@ -27,96 +26,99 @@
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
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:
|
||||
return Dr->LineAspect();
|
||||
case AIS_TOA_Dimension:
|
||||
return Dr->DimensionAspect()->LineAspect();
|
||||
case AIS_TOA_Wire:
|
||||
return Dr->WireAspect();
|
||||
case AIS_TOA_Plane:
|
||||
return Dr->PlaneAspect()->EdgesAspect();
|
||||
case AIS_TOA_Vector:
|
||||
return Dr->VectorAspect();
|
||||
case AIS_TOA_UIso:
|
||||
return Handle(Prs3d_LineAspect) (Dr->UIsoAspect());
|
||||
case AIS_TOA_VIso:
|
||||
return Handle(Prs3d_LineAspect) (Dr->VIsoAspect());
|
||||
case AIS_TOA_Free:
|
||||
return Dr->FreeBoundaryAspect();
|
||||
case AIS_TOA_UnFree:
|
||||
return Dr->UnFreeBoundaryAspect();
|
||||
case AIS_TOA_Section:
|
||||
return Dr->SectionAspect();
|
||||
case AIS_TOA_Hidden:
|
||||
return Dr->HiddenLineAspect();
|
||||
case AIS_TOA_Seen:
|
||||
return Dr->SeenLineAspect();
|
||||
case AIS_TOA_FaceBoundary:
|
||||
return Dr->FaceBoundaryAspect();
|
||||
case AIS_TOA_FirstAxis:
|
||||
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis);
|
||||
case AIS_TOA_SecondAxis:
|
||||
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis);
|
||||
case AIS_TOA_ThirdAxis:
|
||||
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis);
|
||||
case AIS_TOA_Line:
|
||||
return Dr->LineAspect();
|
||||
case AIS_TOA_Dimension:
|
||||
return Dr->DimensionAspect()->LineAspect();
|
||||
case AIS_TOA_Wire:
|
||||
return Dr->WireAspect();
|
||||
case AIS_TOA_Plane:
|
||||
return Dr->PlaneAspect()->EdgesAspect();
|
||||
case AIS_TOA_Vector:
|
||||
return Dr->VectorAspect();
|
||||
case AIS_TOA_UIso:
|
||||
return Handle(Prs3d_LineAspect)(Dr->UIsoAspect());
|
||||
case AIS_TOA_VIso:
|
||||
return Handle(Prs3d_LineAspect)(Dr->VIsoAspect());
|
||||
case AIS_TOA_Free:
|
||||
return Dr->FreeBoundaryAspect();
|
||||
case AIS_TOA_UnFree:
|
||||
return Dr->UnFreeBoundaryAspect();
|
||||
case AIS_TOA_Section:
|
||||
return Dr->SectionAspect();
|
||||
case AIS_TOA_Hidden:
|
||||
return Dr->HiddenLineAspect();
|
||||
case AIS_TOA_Seen:
|
||||
return Dr->SeenLineAspect();
|
||||
case AIS_TOA_FaceBoundary:
|
||||
return Dr->FaceBoundaryAspect();
|
||||
case AIS_TOA_FirstAxis:
|
||||
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis);
|
||||
case AIS_TOA_SecondAxis:
|
||||
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis);
|
||||
case AIS_TOA_ThirdAxis:
|
||||
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis);
|
||||
}
|
||||
Handle(Prs3d_LineAspect) 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;
|
||||
GetLineColor(Dr,Att,color);
|
||||
return color.Name();
|
||||
GetLineColor(Dr, Att, color);
|
||||
return color.Name();
|
||||
}
|
||||
|
||||
void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
|
||||
void AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
|
||||
const AIS_TypeOfAttribute Att,
|
||||
Quantity_Color& aColor)
|
||||
{
|
||||
aColor = GetLineAspect(Dr,Att)->Aspect()->Color();
|
||||
aColor = GetLineAspect(Dr, Att)->Aspect()->Color();
|
||||
}
|
||||
|
||||
Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
|
||||
const AIS_TypeOfAttribute Att)
|
||||
Standard_Real AIS_GraphicTool::GetLineWidth(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()->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();
|
||||
}
|
||||
|
||||
|
||||
void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
|
||||
const AIS_TypeOfAttribute Att,
|
||||
Quantity_NameOfColor& Col,
|
||||
Standard_Real& W,
|
||||
Aspect_TypeOfLine& TYP)
|
||||
const AIS_TypeOfAttribute Att,
|
||||
Quantity_NameOfColor& Col,
|
||||
Standard_Real& W,
|
||||
Aspect_TypeOfLine& TYP)
|
||||
{
|
||||
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
|
||||
Col = LA->Aspect()->Color().Name();
|
||||
W = LA->Aspect()->Width();
|
||||
TYP = LA->Aspect()->Type();
|
||||
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
|
||||
Col = LA->Aspect()->Color().Name();
|
||||
W = LA->Aspect()->Width();
|
||||
TYP = LA->Aspect()->Type();
|
||||
}
|
||||
|
||||
Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
|
||||
{
|
||||
Quantity_Color color;
|
||||
GetInteriorColor(Dr,color);
|
||||
GetInteriorColor(Dr, color);
|
||||
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();
|
||||
aColor = AFA->InteriorColor();
|
||||
aColor = AFA->InteriorColor();
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)
|
||||
|
@ -28,52 +28,41 @@
|
||||
class Quantity_Color;
|
||||
class Graphic3d_MaterialAspect;
|
||||
|
||||
|
||||
|
||||
class AIS_GraphicTool
|
||||
class AIS_GraphicTool
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
Standard_EXPORT static Quantity_NameOfColor GetLineColor (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes);
|
||||
|
||||
Standard_EXPORT static 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 Aspect_TypeOfLine GetLineType (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes);
|
||||
|
||||
Standard_EXPORT static void GetLineAtt (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes, Quantity_NameOfColor& aCol, Standard_Real& aWidth, Aspect_TypeOfLine& aTyp);
|
||||
|
||||
Standard_EXPORT static 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);
|
||||
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 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 void GetLineAtt(const Handle(Prs3d_Drawer)& aDrawer,
|
||||
const AIS_TypeOfAttribute TheTypeOfAttributes,
|
||||
Quantity_NameOfColor& aCol,
|
||||
Standard_Real& aWidth,
|
||||
Aspect_TypeOfLine& aTyp);
|
||||
|
||||
Standard_EXPORT static Quantity_NameOfColor GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer);
|
||||
|
||||
Standard_EXPORT static void GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer,
|
||||
Quantity_Color& aColor);
|
||||
|
||||
Standard_EXPORT static Graphic3d_MaterialAspect GetMaterial(const Handle(Prs3d_Drawer)& aDrawer);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AIS_GraphicTool_HeaderFile
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -27,59 +27,50 @@
|
||||
#include <Prs3d_TextAspect.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)
|
||||
: SelectMgr_SelectableObject (aTypeOfPresentation3d),
|
||||
myCTXPtr (NULL)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_InteractiveObject::AIS_InteractiveObject(
|
||||
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
|
||||
: SelectMgr_SelectableObject(aTypeOfPresentation3d),
|
||||
myCTXPtr(NULL)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Redisplay
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes)
|
||||
{
|
||||
if (myCTXPtr == NULL)
|
||||
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)&,
|
||||
const Handle(SelectMgr_EntityOwner)&,
|
||||
const Graphic3d_Vec2i&,
|
||||
const Graphic3d_Vec2i&,
|
||||
const AIS_DragAction)
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)&,
|
||||
const Handle(V3d_View)&,
|
||||
const Handle(SelectMgr_EntityOwner)&,
|
||||
const Graphic3d_Vec2i&,
|
||||
const Graphic3d_Vec2i&,
|
||||
const AIS_DragAction)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
|
||||
{
|
||||
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())
|
||||
{
|
||||
@ -89,33 +80,27 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
|
||||
myCTXPtr = theCtx.get();
|
||||
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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasPresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_InteractiveObject::HasPresentation() const
|
||||
{
|
||||
return HasInteractiveContext()
|
||||
&& myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode());
|
||||
&& myCTXPtr->MainPrsMgr()->HasPresentation(this, myDrawer->DisplayMode());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Presentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
|
||||
{
|
||||
if (!HasInteractiveContext())
|
||||
@ -123,14 +108,13 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
|
||||
return Handle(Prs3d_Presentation)();
|
||||
}
|
||||
|
||||
Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false);
|
||||
Handle(PrsMgr_Presentation) aPrs =
|
||||
myCTXPtr->MainPrsMgr()->Presentation(this, myDrawer->DisplayMode(), false);
|
||||
return aPrs;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAspect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect)
|
||||
{
|
||||
|
||||
@ -147,31 +131,29 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect
|
||||
const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last();
|
||||
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))
|
||||
{
|
||||
aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect());
|
||||
aGroup->SetGroupPrimitivesAspect(aLineAspect->Aspect());
|
||||
}
|
||||
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))
|
||||
{
|
||||
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)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCTXPtr)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner)
|
||||
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)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myCTXPtr)
|
||||
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myOwner)
|
||||
}
|
||||
|
@ -27,24 +27,26 @@ class V3d_View;
|
||||
|
||||
//! Defines a class of objects with display and selection services.
|
||||
//! Entities which are visualized and selected are Interactive Objects.
|
||||
//! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer.
|
||||
//! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a
|
||||
//! Prs3d_Drawer.
|
||||
//!
|
||||
//! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed,
|
||||
//! or you can implement your own classes of Interactive Objects.
|
||||
//! Key interface methods to be implemented by every Interactive Object:
|
||||
//! You can make use of classes of standard Interactive Objects for which all necessary methods have
|
||||
//! already been programmed, or you can implement your own classes of Interactive Objects. Key
|
||||
//! interface methods to be implemented by every Interactive Object:
|
||||
//! * Presentable Object (PrsMgr_PresentableObject)
|
||||
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
|
||||
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive
|
||||
//! Object or class of Interactive Objects.
|
||||
//! - AcceptDisplayMode() accepting display modes implemented by this object;
|
||||
//! - Compute() computing presentation for the given display mode index;
|
||||
//! * Selectable Object (SelectMgr_SelectableObject)
|
||||
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
|
||||
//! Consider defining an enumeration of supported Selection Mode indexes for particular
|
||||
//! Interactive Object or class of Interactive Objects.
|
||||
//! - ComputeSelection() computing selectable entities for the given selection mode index.
|
||||
class AIS_InteractiveObject : public SelectMgr_SelectableObject
|
||||
{
|
||||
friend class AIS_InteractiveContext;
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
|
||||
public:
|
||||
|
||||
//! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default.
|
||||
virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; }
|
||||
|
||||
@ -59,29 +61,30 @@ public:
|
||||
//! - Circle signature 6
|
||||
//! - Plane signature 7.
|
||||
virtual Standard_Integer Signature() const { return -1; }
|
||||
|
||||
|
||||
//! Updates the active presentation; if <AllModes> = Standard_True
|
||||
//! all the presentations inside are recomputed.
|
||||
//! IMPORTANT: It is preferable to call Redisplay method of
|
||||
//! corresponding AIS_InteractiveContext instance for cases when it
|
||||
//! is accessible. This method just redirects call to myCTXPtr,
|
||||
//! 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.
|
||||
Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
|
||||
|
||||
//! Returns the context pointer to the interactive context.
|
||||
AIS_InteractiveContext* InteractiveContext() const { return myCTXPtr; }
|
||||
|
||||
|
||||
//! Sets the interactive context aCtx and provides a link
|
||||
//! 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.
|
||||
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is composed of, and takes the form of a transient.
|
||||
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is
|
||||
//! composed of, and takes the form of a transient.
|
||||
Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
|
||||
|
||||
|
||||
//! Returns the owner of the Interactive Object.
|
||||
//! The owner can be a shape for a set of sub-shapes or
|
||||
//! a sub-shape for sub-shapes which it is composed of,
|
||||
@ -97,10 +100,13 @@ public:
|
||||
//! an Interactive Object. This can be a shape for a set of
|
||||
//! sub-shapes or a sub-shape for sub-shapes which it
|
||||
//! is composed of. The owner takes the form of a transient.
|
||||
void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; }
|
||||
void SetOwner(const Handle(Standard_Transient)& theApplicativeEntity)
|
||||
{
|
||||
myOwner = theApplicativeEntity;
|
||||
}
|
||||
|
||||
//! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient.
|
||||
//! This method removes the owner from the graphic entity.
|
||||
//! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of
|
||||
//! a Transient. This method removes the owner from the graphic entity.
|
||||
void ClearOwner() { myOwner.Nullify(); }
|
||||
|
||||
//! Drag object in the viewer.
|
||||
@ -111,15 +117,15 @@ public:
|
||||
//! @param[in] theDragTo drag end point
|
||||
//! @param[in] theAction drag action
|
||||
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
|
||||
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Graphic3d_Vec2i& theDragFrom,
|
||||
const Graphic3d_Vec2i& theDragTo,
|
||||
const AIS_DragAction theAction);
|
||||
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
|
||||
const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Graphic3d_Vec2i& theDragFrom,
|
||||
const Graphic3d_Vec2i& theDragTo,
|
||||
const AIS_DragAction theAction);
|
||||
|
||||
public:
|
||||
|
||||
//! Returns the context pointer to the interactive context.
|
||||
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
|
||||
|
||||
@ -131,26 +137,26 @@ public:
|
||||
|
||||
//! Sets the graphic basic aspect to the current presentation.
|
||||
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
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
protected:
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
//! The TypeOfPresention3d means that the interactive object
|
||||
//! may have a presentation dependent on the view of Display.
|
||||
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
|
||||
Standard_EXPORT AIS_InteractiveObject(
|
||||
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
|
||||
|
||||
//! Set presentation display status.
|
||||
Standard_EXPORT void SetDisplayStatus (PrsMgr_DisplayStatus theStatus);
|
||||
Standard_EXPORT void SetDisplayStatus(PrsMgr_DisplayStatus theStatus);
|
||||
|
||||
protected:
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
|
||||
// clang-format on
|
||||
Handle(Standard_Transient) myOwner; //!< application-specific owner object
|
||||
|
||||
// clang-format on
|
||||
Handle(Standard_Transient) myOwner; //!< application-specific owner object
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)
|
||||
|
@ -27,15 +27,16 @@ enum AIS_KindOfInteractive
|
||||
AIS_KindOfInteractive_Shape, //!< presentation of topological shape
|
||||
AIS_KindOfInteractive_Object, //!< presentation of group of topological shapes
|
||||
AIS_KindOfInteractive_Relation, //!< presentation of relation (dimensions and constraints)
|
||||
AIS_KindOfInteractive_Dimension, //!< presentation of dimension (length, radius, diameter and angle)
|
||||
AIS_KindOfInteractive_Dimension, //!< presentation of dimension (length, radius, diameter and
|
||||
//!< angle)
|
||||
AIS_KindOfInteractive_LightSource, //!< presentation of light source
|
||||
|
||||
// old aliases
|
||||
AIS_KOI_None = AIS_KindOfInteractive_None,
|
||||
AIS_KOI_Datum = AIS_KindOfInteractive_Datum,
|
||||
AIS_KOI_Shape = AIS_KindOfInteractive_Shape,
|
||||
AIS_KOI_Object = AIS_KindOfInteractive_Object,
|
||||
AIS_KOI_Relation = AIS_KindOfInteractive_Relation,
|
||||
AIS_KOI_None = AIS_KindOfInteractive_None,
|
||||
AIS_KOI_Datum = AIS_KindOfInteractive_Datum,
|
||||
AIS_KOI_Shape = AIS_KindOfInteractive_Shape,
|
||||
AIS_KOI_Object = AIS_KindOfInteractive_Object,
|
||||
AIS_KOI_Relation = AIS_KindOfInteractive_Relation,
|
||||
AIS_KOI_Dimension = AIS_KindOfInteractive_Dimension
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,28 +29,27 @@ class Select3D_SensitiveSphere;
|
||||
//! - Positional light is represented by a sphere or marker;
|
||||
//! - Spot light is represented by a cone;
|
||||
//! - Directional light is represented by a set of arrows at the corner of view.
|
||||
//! In addition, light source name could be displayed, and clicking on presentation will enable/disable light.
|
||||
//! In addition, light source name could be displayed, and clicking on presentation will
|
||||
//! enable/disable light.
|
||||
class AIS_LightSource : public AIS_InteractiveObject
|
||||
{
|
||||
friend class AIS_LightSourceOwner;
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_LightSource, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes the light source by copying Graphic3d_CLight settings.
|
||||
Standard_EXPORT AIS_LightSource (const Handle(Graphic3d_CLight)& theLightSource);
|
||||
Standard_EXPORT AIS_LightSource(const Handle(Graphic3d_CLight)& theLightSource);
|
||||
|
||||
//! Returns the light.
|
||||
const Handle(Graphic3d_CLight)& Light() const { return myLightSource; }
|
||||
|
||||
//! Set the light.
|
||||
void SetLight (const Handle(Graphic3d_CLight)& theLight)
|
||||
void SetLight(const Handle(Graphic3d_CLight)& theLight)
|
||||
{
|
||||
myLightSource = theLight;
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
public: //! @name Light properties
|
||||
|
||||
//! Returns TRUE if the light source name should be displayed; TRUE by default.
|
||||
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.
|
||||
//! Has no effect for non-zoomable presentation.
|
||||
//! Returns TRUE to display light source range as sphere (positional light) or cone (spot light);
|
||||
//! TRUE by default. Has no effect for non-zoomable presentation.
|
||||
Standard_Boolean ToDisplayRange() const { return myToDisplayRange; }
|
||||
|
||||
//! Show/hide light source range shaded presentation.
|
||||
void SetDisplayRange (Standard_Boolean theToDisplay)
|
||||
void SetDisplayRange(Standard_Boolean theToDisplay)
|
||||
{
|
||||
if (myToDisplayRange != theToDisplay)
|
||||
{
|
||||
@ -82,7 +81,7 @@ public: //! @name Light properties
|
||||
Standard_Real Size() const { return mySize; }
|
||||
|
||||
//! Sets the size of presentation.
|
||||
void SetSize (Standard_Real theSize)
|
||||
void SetSize(Standard_Real theSize)
|
||||
{
|
||||
if (mySize != theSize)
|
||||
{
|
||||
@ -95,7 +94,7 @@ public: //! @name Light properties
|
||||
Standard_Integer ArcSize() const { return mySensSphereArcSize; }
|
||||
|
||||
//! Sets the size of sensitive sphere arc.
|
||||
void SetArcSize (Standard_Integer theSize)
|
||||
void SetArcSize(Standard_Integer theSize)
|
||||
{
|
||||
if (mySensSphereArcSize != theSize)
|
||||
{
|
||||
@ -110,7 +109,7 @@ public: //! @name Light properties
|
||||
bool IsZoomable() const { return myIsZoomable; }
|
||||
|
||||
//! Sets if transform-persistence is allowed.
|
||||
void SetZoomable (bool theIsZoomable)
|
||||
void SetZoomable(bool theIsZoomable)
|
||||
{
|
||||
if (myIsZoomable != theIsZoomable)
|
||||
{
|
||||
@ -120,7 +119,7 @@ public: //! @name Light properties
|
||||
}
|
||||
|
||||
//! Sets if dragging is allowed.
|
||||
void SetDraggable (bool theIsDraggable)
|
||||
void SetDraggable(bool theIsDraggable)
|
||||
{
|
||||
if (myIsDraggable != theIsDraggable)
|
||||
{
|
||||
@ -132,13 +131,13 @@ public: //! @name Light properties
|
||||
bool ToSwitchOnClick() const { return myToSwitchOnClick; }
|
||||
|
||||
//! 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.
|
||||
Standard_Integer NbArrows() const { return myNbArrows; }
|
||||
|
||||
//! 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)
|
||||
{
|
||||
@ -149,25 +148,29 @@ public: //! @name Light properties
|
||||
|
||||
//! Returns light source icon.
|
||||
//! @param[in] theIsEnabled marker index for enabled/disabled light source states
|
||||
const Handle(Graphic3d_MarkerImage)& MarkerImage (bool theIsEnabled) const { return myMarkerImages[theIsEnabled ? 1 : 0]; }
|
||||
const Handle(Graphic3d_MarkerImage)& MarkerImage(bool theIsEnabled) const
|
||||
{
|
||||
return myMarkerImages[theIsEnabled ? 1 : 0];
|
||||
}
|
||||
|
||||
//! Returns light source icon.
|
||||
//! @param[in] theIsEnabled marker index for enabled/disabled light source states
|
||||
Aspect_TypeOfMarker MarkerType (bool theIsEnabled) const { return myMarkerTypes[theIsEnabled ? 1 : 0]; }
|
||||
Aspect_TypeOfMarker MarkerType(bool theIsEnabled) const
|
||||
{
|
||||
return myMarkerTypes[theIsEnabled ? 1 : 0];
|
||||
}
|
||||
|
||||
//! Sets custom icon to light source.
|
||||
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage,
|
||||
bool theIsEnabled)
|
||||
void SetMarkerImage(const Handle(Graphic3d_MarkerImage)& theImage, bool theIsEnabled)
|
||||
{
|
||||
myMarkerImages[theIsEnabled ? 1 : 0] = theImage;
|
||||
myMarkerTypes [theIsEnabled ? 1 : 0] = !theImage.IsNull()
|
||||
? Aspect_TOM_USERDEFINED
|
||||
: (theIsEnabled ? Aspect_TOM_O_POINT : Aspect_TOM_O_X);
|
||||
myMarkerTypes[theIsEnabled ? 1 : 0] = !theImage.IsNull()
|
||||
? Aspect_TOM_USERDEFINED
|
||||
: (theIsEnabled ? Aspect_TOM_O_POINT : Aspect_TOM_O_X);
|
||||
}
|
||||
|
||||
//! Sets standard icon to light source.
|
||||
void SetMarkerType (Aspect_TypeOfMarker theType,
|
||||
bool theIsEnabled)
|
||||
void SetMarkerType(Aspect_TypeOfMarker theType, bool theIsEnabled)
|
||||
{
|
||||
myMarkerTypes[theIsEnabled ? 1 : 0] = theType;
|
||||
}
|
||||
@ -176,34 +179,36 @@ public: //! @name Light properties
|
||||
Standard_Integer NbSplitsQuadric() const { return myNbSplitsQuadric; }
|
||||
|
||||
//! 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.
|
||||
Standard_Integer NbSplitsArrow() const { return myNbSplitsArrow; }
|
||||
|
||||
//! Sets tessellation level for arrows.
|
||||
void SetNbSplitsArrow (Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; }
|
||||
void SetNbSplitsArrow(Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; }
|
||||
|
||||
//! Returns kind of the object.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_LightSource; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_LightSource;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Return true if specified display mode is supported: 0 for main presentation and 1 for highlight.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
//! Return true if specified display mode is supported: 0 for main presentation and 1 for
|
||||
//! highlight.
|
||||
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode == 0
|
||||
|| theMode == 1;
|
||||
return theMode == 0 || theMode == 1;
|
||||
}
|
||||
|
||||
//! Computes selection sensitive zones(triangulation) for light source presentation.
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Fills presentation.
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Drag object in the viewer.
|
||||
//! @param[in] theCtx interactive context
|
||||
@ -213,15 +218,17 @@ protected:
|
||||
//! @param[in] theDragTo drag end point
|
||||
//! @param[in] theAction drag action
|
||||
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
|
||||
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Graphic3d_Vec2i& theDragFrom,
|
||||
const Graphic3d_Vec2i& theDragTo,
|
||||
const AIS_DragAction theAction) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
|
||||
const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Graphic3d_Vec2i& theDragFrom,
|
||||
const Graphic3d_Vec2i& theDragTo,
|
||||
const AIS_DragAction theAction) Standard_OVERRIDE;
|
||||
|
||||
//! Sets new local transformation, which is propagated to Graphic3d_CLight instance.
|
||||
Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void setLocalTransformation(const Handle(TopLoc_Datum3D)& theTrsf)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Updates local transformation basing on a type of light source.
|
||||
Standard_EXPORT virtual void updateLightLocalTransformation();
|
||||
@ -233,26 +240,26 @@ protected:
|
||||
Standard_EXPORT virtual void updateLightAspects();
|
||||
|
||||
//! Compute ambient light source presentation as a sphere at view corner.
|
||||
Standard_EXPORT virtual void computeAmbient (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
Standard_EXPORT virtual void computeAmbient(const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
//! Compute directional light source presentation as a set of arrows at view corner.
|
||||
Standard_EXPORT virtual void computeDirectional (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
Standard_EXPORT virtual void computeDirectional(const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
//! Compute positional light source presentation as a sphere of either fixed size (no range) or of size representing a maximum range.
|
||||
Standard_EXPORT virtual void computePositional (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
//! Compute positional light source presentation as a sphere of either fixed size (no range) or of
|
||||
//! size representing a maximum range.
|
||||
Standard_EXPORT virtual void computePositional(const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
//! Compute spot light source presentation as a cone.
|
||||
Standard_EXPORT virtual void computeSpot (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
Standard_EXPORT virtual void computeSpot(const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
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_AspectLine3d) myArrowLineAspectShadow; //!< arrow shadow style
|
||||
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_Boolean myIsZoomable; //!< flag to allow/disallow transform-persistence when possible
|
||||
Standard_Boolean myIsDraggable; //!< flag to allow/disallow rotate directional light source by dragging
|
||||
// clang-format on
|
||||
Standard_Boolean myToDisplayName; //!< flag to show/hide name
|
||||
Standard_Boolean myToDisplayRange; //!< flag to show/hide range of positional/spot light
|
||||
Standard_Boolean myToSwitchOnClick; //!< flag to handle mouse click to turn light on/off
|
||||
|
||||
// clang-format on
|
||||
Standard_Boolean myToDisplayName; //!< flag to show/hide name
|
||||
Standard_Boolean myToDisplayRange; //!< flag to show/hide range of positional/spot light
|
||||
Standard_Boolean myToSwitchOnClick; //!< flag to handle mouse click to turn light on/off
|
||||
};
|
||||
|
||||
//! Owner of AIS_LightSource presentation.
|
||||
@ -281,27 +287,27 @@ class AIS_LightSourceOwner : public SelectMgr_EntityOwner
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_LightSourceOwner, SelectMgr_EntityOwner)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT AIS_LightSourceOwner (const Handle(AIS_LightSource)& theObject,
|
||||
Standard_Integer thePriority = 5);
|
||||
Standard_EXPORT AIS_LightSourceOwner(const Handle(AIS_LightSource)& theObject,
|
||||
Standard_Integer thePriority = 5);
|
||||
|
||||
//! Handle mouse button click event.
|
||||
Standard_EXPORT virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
|
||||
Aspect_VKeyMouse theButton,
|
||||
Aspect_VKeyFlags theModifiers,
|
||||
bool theIsDoubleClick) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
|
||||
Aspect_VKeyMouse theButton,
|
||||
Aspect_VKeyFlags theModifiers,
|
||||
bool theIsDoubleClick)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Highlights selectable object's presentation with display mode in presentation manager with given highlight style.
|
||||
//! Also a check for auto-highlight is performed - if selectable object manages highlighting on its own,
|
||||
//! execution will be passed to SelectMgr_SelectableObject::HilightOwnerWithColor method.
|
||||
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
//! Highlights selectable object's presentation with display mode in presentation manager with
|
||||
//! given highlight style. Also a check for auto-highlight is performed - if selectable object
|
||||
//! manages highlighting on its own, execution will be passed to
|
||||
//! SelectMgr_SelectableObject::HilightOwnerWithColor method.
|
||||
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Always update dynamic highlighting.
|
||||
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_LightSource_HeaderFile
|
||||
|
@ -34,46 +34,43 @@
|
||||
#include <StdPrs_Curve.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),
|
||||
myLineIsSegment(Standard_False)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Line::AIS_Line(const Handle(Geom_Line)& aComponent)
|
||||
: myComponent(aComponent),
|
||||
myLineIsSegment(Standard_False)
|
||||
{
|
||||
SetInfiniteState();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Line
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_Line::AIS_Line(const Handle(Geom_Point)& aStartPoint,
|
||||
const Handle(Geom_Point)& aEndPoint):
|
||||
myStartPoint(aStartPoint),
|
||||
myEndPoint(aEndPoint),
|
||||
myLineIsSegment(Standard_True)
|
||||
{}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Line::Compute (const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer )
|
||||
AIS_Line::AIS_Line(const Handle(Geom_Point)& aStartPoint, const Handle(Geom_Point)& aEndPoint)
|
||||
: myStartPoint(aStartPoint),
|
||||
myEndPoint(aEndPoint),
|
||||
myLineIsSegment(Standard_True)
|
||||
{
|
||||
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,
|
||||
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())
|
||||
{
|
||||
myDrawer->SetLineAspect (theAspect);
|
||||
myDrawer->SetLineAspect(theAspect);
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(Graphic3d_Aspects)& anAspectOld = myDrawer->LineAspect()->Aspect();
|
||||
const Handle(Graphic3d_Aspects)& anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
|
||||
const Handle(Graphic3d_Aspects)& anAspectNew =
|
||||
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
|
||||
if (anAspectNew != anAspectOld)
|
||||
{
|
||||
myDrawer->SetLineAspect (theAspect);
|
||||
myDrawer->SetLineAspect(theAspect);
|
||||
Graphic3d_MapOfAspectsToAspects aReplaceMap;
|
||||
aReplaceMap.Bind (anAspectOld, anAspectNew);
|
||||
replaceAspects (aReplaceMap);
|
||||
aReplaceMap.Bind(anAspectOld, anAspectNew);
|
||||
replaceAspects(aReplaceMap);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Line::SetColor(const Quantity_Color &aCol)
|
||||
{
|
||||
hasOwnColor=Standard_True;
|
||||
myDrawer->SetColor (aCol);
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Real WW = HasWidth()? myOwnWidth:
|
||||
myDrawer->HasLink() ?
|
||||
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.;
|
||||
void AIS_Line::SetColor(const Quantity_Color& aCol)
|
||||
{
|
||||
hasOwnColor = Standard_True;
|
||||
myDrawer->SetColor(aCol);
|
||||
|
||||
Standard_Real WW = HasWidth() ? myOwnWidth
|
||||
: myDrawer->HasLink()
|
||||
? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
|
||||
: 1.;
|
||||
|
||||
if (!myDrawer->HasOwnLineAspect())
|
||||
{
|
||||
replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW));
|
||||
replaceWithNewLineAspect(new Prs3d_LineAspect(aCol, Aspect_TOL_SOLID, WW));
|
||||
}
|
||||
else
|
||||
{
|
||||
myDrawer->LineAspect()->SetColor (aCol);
|
||||
myDrawer->LineAspect()->SetColor(aCol);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Line::UnsetColor()
|
||||
{
|
||||
hasOwnColor = Standard_False;
|
||||
|
||||
if (!HasWidth())
|
||||
{
|
||||
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
|
||||
replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
|
||||
}
|
||||
else
|
||||
{
|
||||
Quantity_Color CC = Quantity_NOC_YELLOW;
|
||||
if( HasColor() ) CC = myDrawer->Color();
|
||||
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
if (HasColor())
|
||||
CC = myDrawer->Color();
|
||||
else if (myDrawer->HasLink())
|
||||
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
myDrawer->LineAspect()->SetColor(CC);
|
||||
myDrawer->SetColor (CC);
|
||||
myDrawer->SetColor(CC);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWidth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Line::SetWidth(const Standard_Real aValue)
|
||||
{
|
||||
myOwnWidth = (Standard_ShortReal )aValue;
|
||||
myOwnWidth = (Standard_ShortReal)aValue;
|
||||
|
||||
if (!myDrawer->HasOwnLineAspect())
|
||||
{
|
||||
Quantity_Color CC = Quantity_NOC_YELLOW;
|
||||
if( HasColor() ) CC = myDrawer->Color();
|
||||
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue));
|
||||
if (HasColor())
|
||||
CC = myDrawer->Color();
|
||||
else if (myDrawer->HasLink())
|
||||
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
|
||||
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
myDrawer->LineAspect()->SetWidth (aValue);
|
||||
myDrawer->LineAspect()->SetWidth(aValue);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetWidth
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Line::UnsetWidth()
|
||||
{
|
||||
if (!HasColor())
|
||||
{
|
||||
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)());
|
||||
replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.0f;
|
||||
myDrawer->LineAspect()->SetWidth (WW);
|
||||
myOwnWidth = WW;
|
||||
SynchronizeAspects();
|
||||
Standard_ShortReal WW =
|
||||
myDrawer->HasLink()
|
||||
? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
|
||||
: 1.0f;
|
||||
myDrawer->LineAspect()->SetWidth(WW);
|
||||
myOwnWidth = WW;
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeInfiniteLine
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Line::ComputeInfiniteLine( const Handle(Prs3d_Presentation)& aPresentation)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Line::ComputeInfiniteLine(const Handle(Prs3d_Presentation)& aPresentation)
|
||||
{
|
||||
GeomAdaptor_Curve curv(myComponent);
|
||||
StdPrs_Curve::Add(aPresentation,curv,myDrawer);
|
||||
StdPrs_Curve::Add(aPresentation, curv, myDrawer);
|
||||
|
||||
//pas de prise en compte lors du FITALL
|
||||
aPresentation->SetInfiniteState (Standard_True);
|
||||
// pas de prise en compte lors du FITALL
|
||||
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 P2 = myEndPoint->Pnt();
|
||||
|
||||
myComponent = new Geom_Line(P1,gp_Dir(P2.XYZ()-P1.XYZ()));
|
||||
|
||||
Standard_Real dist = P1.Distance(P2);
|
||||
GeomAdaptor_Curve curv(myComponent,0.,dist);
|
||||
StdPrs_Curve::Add(aPresentation,curv,myDrawer);
|
||||
myComponent = new Geom_Line(P1, gp_Dir(P2.XYZ() - P1.XYZ()));
|
||||
|
||||
Standard_Real dist = P1.Distance(P2);
|
||||
GeomAdaptor_Curve curv(myComponent, 0., dist);
|
||||
StdPrs_Curve::Add(aPresentation, curv, myDrawer);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeInfiniteLineSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Line::ComputeInfiniteLineSelection(const Handle(SelectMgr_Selection)& aSelection)
|
||||
{
|
||||
|
||||
/* // on calcule les points min max a partir desquels on cree un segment sensible...
|
||||
GeomAdaptor_Curve curv(myComponent);
|
||||
gp_Pnt P1,P2;
|
||||
FindLimits(curv,myDrawer->MaximalParameterValue(),P1,P2);
|
||||
*/
|
||||
const gp_Dir& thedir = myComponent->Position().Direction();
|
||||
const gp_Pnt& loc = myComponent->Position().Location();
|
||||
/* // on calcule les points min max a partir desquels on cree un segment sensible...
|
||||
GeomAdaptor_Curve curv(myComponent);
|
||||
gp_Pnt P1,P2;
|
||||
FindLimits(curv,myDrawer->MaximalParameterValue(),P1,P2);
|
||||
*/
|
||||
const gp_Dir& thedir = myComponent->Position().Direction();
|
||||
const gp_Pnt& loc = myComponent->Position().Location();
|
||||
const gp_XYZ& dir_xyz = thedir.XYZ();
|
||||
const gp_XYZ& loc_xyz = loc.XYZ();
|
||||
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS (250000. ,"mm");
|
||||
gp_Pnt P1 = loc_xyz + aLength*dir_xyz;
|
||||
gp_Pnt P2 = loc_xyz - aLength*dir_xyz;
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,5);
|
||||
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,P1,P2);
|
||||
// POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
|
||||
gp_Pnt P1 = loc_xyz + aLength * dir_xyz;
|
||||
gp_Pnt P2 = loc_xyz - aLength * dir_xyz;
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 5);
|
||||
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, P1, P2);
|
||||
aSelection->Add(seg);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ComputeSegmentLineSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Line::ComputeSegmentLineSelection(const Handle(SelectMgr_Selection)& aSelection)
|
||||
{
|
||||
|
||||
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,5);
|
||||
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,
|
||||
myStartPoint->Pnt(),
|
||||
myEndPoint->Pnt());
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 5);
|
||||
Handle(Select3D_SensitiveSegment) seg =
|
||||
new Select3D_SensitiveSegment(eown, myStartPoint->Pnt(), myEndPoint->Pnt());
|
||||
aSelection->Add(seg);
|
||||
}
|
||||
|
@ -29,40 +29,43 @@ class AIS_Line : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes the line aLine.
|
||||
Standard_EXPORT AIS_Line(const Handle(Geom_Line)& aLine);
|
||||
|
||||
//! Initializes a starting point aStartPoint
|
||||
//! and a finishing point aEndPoint for the line.
|
||||
Standard_EXPORT AIS_Line(const Handle(Geom_Point)& aStartPoint, const Handle(Geom_Point)& aEndPoint);
|
||||
Standard_EXPORT AIS_Line(const Handle(Geom_Point)& aStartPoint,
|
||||
const Handle(Geom_Point)& aEndPoint);
|
||||
|
||||
//! Returns the signature 5.
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 5; }
|
||||
|
||||
//! Returns the type Datum.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
//! Constructs an infinite line.
|
||||
const Handle(Geom_Line)& Line() const { return myComponent; }
|
||||
|
||||
//! 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;
|
||||
thePEnd = myEndPoint;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
}
|
||||
|
||||
//! Sets the starting point thePStart and ending point thePEnd of the
|
||||
//! 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;
|
||||
myEndPoint = thePEnd;
|
||||
@ -70,11 +73,11 @@ public:
|
||||
}
|
||||
|
||||
//! 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
|
||||
//! 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.
|
||||
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
|
||||
@ -83,31 +86,28 @@ public:
|
||||
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
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 ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
|
||||
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 ComputeInfiniteLine(const Handle(Prs3d_Presentation)& aPresentation);
|
||||
|
||||
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.
|
||||
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
|
||||
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Line) myComponent;
|
||||
Handle(Geom_Line) myComponent;
|
||||
Handle(Geom_Point) myStartPoint;
|
||||
Handle(Geom_Point) myEndPoint;
|
||||
Standard_Boolean myLineIsSegment;
|
||||
|
||||
Standard_Boolean myLineIsSegment;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_Line, AIS_InteractiveObject)
|
||||
|
@ -11,7 +11,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#ifndef AIS_ListIteratorOfListOfInteractive_HeaderFile
|
||||
#define AIS_ListIteratorOfListOfInteractive_HeaderFile
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <NCollection_List.hxx>
|
||||
|
||||
typedef NCollection_List<Handle(AIS_InteractiveObject)> AIS_ListOfInteractive;
|
||||
typedef NCollection_List<Handle(AIS_InteractiveObject)>::Iterator AIS_ListIteratorOfListOfInteractive;
|
||||
|
||||
typedef NCollection_List<Handle(AIS_InteractiveObject)>::Iterator
|
||||
AIS_ListIteratorOfListOfInteractive;
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,7 @@
|
||||
|
||||
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
|
||||
//! 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
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs a manipulator object with default placement and all parts to be displayed.
|
||||
Standard_EXPORT AIS_Manipulator();
|
||||
|
||||
//! Constructs a manipulator object with input location and positions of axes and all parts to be displayed.
|
||||
Standard_EXPORT AIS_Manipulator (const gp_Ax2& thePosition);
|
||||
//! Constructs a manipulator object with input location and positions of axes and all parts to be
|
||||
//! displayed.
|
||||
Standard_EXPORT AIS_Manipulator(const gp_Ax2& thePosition);
|
||||
|
||||
//! Disable or enable visual parts for translation, rotation or scaling for some axis.
|
||||
//! By default all parts are enabled (will be displayed).
|
||||
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation (selection) mode.
|
||||
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation
|
||||
//! (selection) mode.
|
||||
//! @warning Raises program error if axis index is < 0 or > 2.
|
||||
Standard_EXPORT void SetPart (const Standard_Integer theAxisIndex, const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled);
|
||||
Standard_EXPORT void SetPart(const Standard_Integer theAxisIndex,
|
||||
const AIS_ManipulatorMode theMode,
|
||||
const Standard_Boolean theIsEnabled);
|
||||
|
||||
//! Disable or enable visual parts for translation, rotation or scaling for ALL axes.
|
||||
//! By default all parts are enabled (will be displayed).
|
||||
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation (selection) mode.
|
||||
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation
|
||||
//! (selection) mode.
|
||||
//! @warning Raises program error if axis index is < 0 or > 2.
|
||||
Standard_EXPORT void SetPart (const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled);
|
||||
Standard_EXPORT void SetPart(const AIS_ManipulatorMode theMode,
|
||||
const Standard_Boolean theIsEnabled);
|
||||
|
||||
//! Behavior settings to be applied when performing transformation:
|
||||
//! - FollowTranslation - whether the manipulator will be moved together with an object.
|
||||
//! - FollowRotation - whether the manipulator will be rotated together with an object.
|
||||
struct OptionsForAttach {
|
||||
struct OptionsForAttach
|
||||
{
|
||||
|
||||
OptionsForAttach() : AdjustPosition (Standard_True), AdjustSize (Standard_False), EnableModes (Standard_True) {}
|
||||
OptionsForAttach& SetAdjustPosition (const Standard_Boolean theApply) { AdjustPosition = theApply; return *this; }
|
||||
OptionsForAttach& SetAdjustSize (const Standard_Boolean theApply) { AdjustSize = theApply; return *this; }
|
||||
OptionsForAttach& SetEnableModes (const Standard_Boolean theApply) { EnableModes = theApply; return *this; }
|
||||
OptionsForAttach()
|
||||
: AdjustPosition(Standard_True),
|
||||
AdjustSize(Standard_False),
|
||||
EnableModes(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
OptionsForAttach& SetAdjustPosition(const Standard_Boolean theApply)
|
||||
{
|
||||
AdjustPosition = theApply;
|
||||
return *this;
|
||||
}
|
||||
|
||||
OptionsForAttach& SetAdjustSize(const Standard_Boolean theApply)
|
||||
{
|
||||
AdjustSize = theApply;
|
||||
return *this;
|
||||
}
|
||||
|
||||
OptionsForAttach& SetEnableModes(const Standard_Boolean theApply)
|
||||
{
|
||||
EnableModes = theApply;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Standard_Boolean AdjustPosition;
|
||||
Standard_Boolean AdjustSize;
|
||||
@ -128,32 +154,33 @@ public:
|
||||
};
|
||||
|
||||
//! Attaches himself to the input interactive object and become displayed in the same context.
|
||||
//! It is placed in the center of object bounding box, and its size is adjusted to the object bounding box.
|
||||
Standard_EXPORT void Attach (const Handle(AIS_InteractiveObject)& theObject, const OptionsForAttach& theOptions = OptionsForAttach());
|
||||
//! It is placed in the center of object bounding box, and its size is adjusted to the object
|
||||
//! bounding box.
|
||||
Standard_EXPORT void Attach(const Handle(AIS_InteractiveObject)& theObject,
|
||||
const OptionsForAttach& theOptions = OptionsForAttach());
|
||||
|
||||
//! Attaches himself to the input interactive object group and become displayed in the same context.
|
||||
//! It become attached to the first object, baut manage manipulation of the whole group.
|
||||
//! It is placed in the center of object bounding box, and its size is adjusted to the object bounding box.
|
||||
Standard_EXPORT void Attach (const Handle(AIS_ManipulatorObjectSequence)& theObject, const OptionsForAttach& theOptions = OptionsForAttach());
|
||||
//! Attaches himself to the input interactive object group and become displayed in the same
|
||||
//! context. It become attached to the first object, baut manage manipulation of the whole group.
|
||||
//! It is placed in the center of object bounding box, and its size is adjusted to the object
|
||||
//! bounding box.
|
||||
Standard_EXPORT void Attach(const Handle(AIS_ManipulatorObjectSequence)& theObject,
|
||||
const OptionsForAttach& theOptions = OptionsForAttach());
|
||||
|
||||
//! Enable manipualtion mode.
|
||||
//! @warning It activates selection mode in the current context.
|
||||
//! 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).
|
||||
//! By default, mode is activated on selection of manipulator part.
|
||||
//! @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;
|
||||
}
|
||||
|
||||
//! @return true if manual mode activation is enabled.
|
||||
Standard_Boolean IsModeActivationOnDetection() const
|
||||
{
|
||||
return myIsActivationOnDetection;
|
||||
}
|
||||
Standard_Boolean IsModeActivationOnDetection() const { return myIsActivationOnDetection; }
|
||||
|
||||
public:
|
||||
//! Drag object in the viewer.
|
||||
@ -164,18 +191,22 @@ public:
|
||||
//! @param[in] theDragTo drag end point
|
||||
//! @param[in] theAction drag action
|
||||
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
|
||||
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Graphic3d_Vec2i& theDragFrom,
|
||||
const Graphic3d_Vec2i& theDragTo,
|
||||
const AIS_DragAction theAction) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
|
||||
const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Graphic3d_Vec2i& theDragFrom,
|
||||
const Graphic3d_Vec2i& theDragTo,
|
||||
const AIS_DragAction theAction) Standard_OVERRIDE;
|
||||
|
||||
//! Init start (reference) transformation.
|
||||
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
|
||||
//! and is used only for custom transform set. If Transform(const Standard_Integer, const Standard_Integer) is used,
|
||||
//! initial data is set automatically, and it is reset on DeactivateCurrentMode call if it is not reset yet.
|
||||
Standard_EXPORT void StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView);
|
||||
//! and is used only for custom transform set. If Transform(const Standard_Integer, const
|
||||
//! Standard_Integer) is used, initial data is set automatically, and it is reset on
|
||||
//! DeactivateCurrentMode call if it is not reset yet.
|
||||
Standard_EXPORT void StartTransform(const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Apply to the owning objects the input transformation.
|
||||
//! @remark The transformation is set using SetLocalTransformation for owning objects.
|
||||
@ -184,29 +215,32 @@ public:
|
||||
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
|
||||
//! and is used only for custom transform set.
|
||||
//! @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.
|
||||
//! @param[in] theToApply option to apply or to cancel the started transformation.
|
||||
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
|
||||
//! 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
|
||||
//! (save on the first Transform() call and reset on DeactivateCurrentMode() call.)
|
||||
//! to the in/out mouse position (theX, theY)
|
||||
Standard_EXPORT gp_Trsf Transform (const Standard_Integer theX, const Standard_Integer theY,
|
||||
const Handle(V3d_View)& theView);
|
||||
Standard_EXPORT gp_Trsf Transform(const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Handle(V3d_View)& theView);
|
||||
|
||||
//! Computes transformation of parent object according to the active mode and input motion vector.
|
||||
//! You can use this method to get object transformation according to current mode or use own algorithm
|
||||
//! to implement any other transformation for modes.
|
||||
//! You can use this method to get object transformation according to current mode or use own
|
||||
//! algorithm to implement any other transformation for modes.
|
||||
//! @return transformation of parent object.
|
||||
Standard_EXPORT Standard_Boolean ObjectTransformation (const Standard_Integer theX, const Standard_Integer theY,
|
||||
const Handle(V3d_View)& theView, gp_Trsf& theTrsf);
|
||||
Standard_EXPORT Standard_Boolean ObjectTransformation(const Standard_Integer theX,
|
||||
const Standard_Integer theY,
|
||||
const Handle(V3d_View)& theView,
|
||||
gp_Trsf& theTrsf);
|
||||
|
||||
//! Make inactive the current selected manipulator part and reset current axis index and current mode.
|
||||
//! After its call HasActiveMode() returns false.
|
||||
//! Make inactive the current selected manipulator part and reset current axis index and current
|
||||
//! mode. After its call HasActiveMode() returns false.
|
||||
//! @sa HasActiveMode()
|
||||
Standard_EXPORT void DeactivateCurrentMode();
|
||||
|
||||
@ -221,50 +255,55 @@ public:
|
||||
|
||||
//! @return one of the owning objects.
|
||||
//! @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).
|
||||
Standard_Boolean IsAttached() const { return HasOwner(); }
|
||||
|
||||
//! @return true if some part of manipulator is selected (transformation mode is active, and owning object can be transformed).
|
||||
//! @return true if some part of manipulator is selected (transformation mode is active, and
|
||||
//! owning object can be transformed).
|
||||
Standard_Boolean HasActiveMode() const { return IsAttached() && myCurrentMode != AIS_MM_None; }
|
||||
|
||||
Standard_Boolean HasActiveTransformation() { return myHasStartedTransformation; }
|
||||
|
||||
gp_Trsf StartTransformation() const { return !myStartTrsfs.IsEmpty() ? myStartTrsfs.First() : gp_Trsf(); }
|
||||
|
||||
gp_Trsf StartTransformation (Standard_Integer theIndex) const
|
||||
gp_Trsf StartTransformation() 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");
|
||||
return !myStartTrsfs.IsEmpty() ? myStartTrsfs (theIndex) : gp_Trsf();
|
||||
return !myStartTrsfs.IsEmpty() ? myStartTrsfs(theIndex) : gp_Trsf();
|
||||
}
|
||||
|
||||
public: //! @name Configuration of graphical transformations
|
||||
|
||||
//! Enable or disable zoom persistence mode for the manipulator. With
|
||||
//! this mode turned on the presentation will keep fixed screen size.
|
||||
//! @warning when turned on this option overrides transform persistence
|
||||
//! properties and local transformation to achieve necessary visual effect.
|
||||
//! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
|
||||
//! 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.
|
||||
Standard_Boolean ZoomPersistence() const { return myIsZoomPersistentMode; }
|
||||
|
||||
//! Redefines transform persistence management to setup transformation for sub-presentation of axes.
|
||||
//! Redefines transform persistence management to setup transformation for sub-presentation of
|
||||
//! axes.
|
||||
//! @warning this interactive object does not support custom transformation persistence when
|
||||
//! using \sa ZoomPersistence mode. In this mode the transformation persistence flags for
|
||||
//! presentations are overridden by this class.
|
||||
//! @warning Invokes debug assertion to catch incompatible usage of the method with \sa ZoomPersistence mode,
|
||||
//! silently does nothing in release mode.
|
||||
//! @warning Invokes debug assertion to catch incompatible usage of the method with \sa
|
||||
//! ZoomPersistence mode, silently does nothing in release mode.
|
||||
//! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
|
||||
//! when enabling zoom persistence.
|
||||
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetTransformPersistence(
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
|
||||
|
||||
public: //! @name Setters for parameters
|
||||
|
||||
AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; }
|
||||
|
||||
Standard_Integer ActiveAxisIndex() const { return myCurrentIndex; }
|
||||
@ -273,27 +312,47 @@ public: //! @name Setters for parameters
|
||||
const gp_Ax2& Position() const { return myPosition; }
|
||||
|
||||
//! 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(); }
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void SetGap (const Standard_ShortReal theValue);
|
||||
Standard_EXPORT void SetGap(const Standard_ShortReal theValue);
|
||||
|
||||
public:
|
||||
|
||||
//! Behavior settings to be applied when performing transformation:
|
||||
//! - FollowTranslation - whether the manipulator will be moved together with an object.
|
||||
//! - FollowRotation - whether the manipulator will be rotated together with an object.
|
||||
struct BehaviorOnTransform {
|
||||
struct BehaviorOnTransform
|
||||
{
|
||||
|
||||
BehaviorOnTransform() : FollowTranslation (Standard_True), FollowRotation (Standard_True), FollowDragging (Standard_True) {}
|
||||
BehaviorOnTransform& SetFollowTranslation (const Standard_Boolean theApply) { FollowTranslation = theApply; return *this; }
|
||||
BehaviorOnTransform& SetFollowRotation (const Standard_Boolean theApply) { FollowRotation = theApply; return *this; }
|
||||
BehaviorOnTransform& SetFollowDragging (const Standard_Boolean theApply) { FollowDragging = theApply; return *this; }
|
||||
BehaviorOnTransform()
|
||||
: FollowTranslation(Standard_True),
|
||||
FollowRotation(Standard_True),
|
||||
FollowDragging(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
BehaviorOnTransform& SetFollowTranslation(const Standard_Boolean theApply)
|
||||
{
|
||||
FollowTranslation = theApply;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BehaviorOnTransform& SetFollowRotation(const Standard_Boolean theApply)
|
||||
{
|
||||
FollowRotation = theApply;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BehaviorOnTransform& SetFollowDragging(const Standard_Boolean theApply)
|
||||
{
|
||||
FollowDragging = theApply;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Standard_Boolean FollowTranslation;
|
||||
Standard_Boolean FollowRotation;
|
||||
@ -302,7 +361,10 @@ public:
|
||||
|
||||
//! Sets behavior settings for transformation action carried on the manipulator,
|
||||
//! whether it translates, rotates together with the transformed object or not.
|
||||
void SetTransformBehavior (const BehaviorOnTransform& theSettings) { myBehaviorOnTransform = theSettings; }
|
||||
void SetTransformBehavior(const BehaviorOnTransform& theSettings)
|
||||
{
|
||||
myBehaviorOnTransform = theSettings;
|
||||
}
|
||||
|
||||
//! @return behavior settings for transformation action of the manipulator.
|
||||
BehaviorOnTransform& ChangeTransformBehavior() { return myBehaviorOnTransform; }
|
||||
@ -311,52 +373,54 @@ public:
|
||||
const BehaviorOnTransform& TransformBehavior() const { return myBehaviorOnTransform; }
|
||||
|
||||
public: //! @name Presentation computation
|
||||
|
||||
//! Fills presentation.
|
||||
//! @note Manipulator presentation does not use display mode and for all modes has the same presentation.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode = 0) Standard_OVERRIDE;
|
||||
//! @note Manipulator presentation does not use display mode and for all modes has the same
|
||||
//! presentation.
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode = 0) Standard_OVERRIDE;
|
||||
|
||||
//! Computes selection sensitive zones (triangulation) for manipulator.
|
||||
//! @param[in] theNode Selection mode that is treated as transformation mode.
|
||||
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;
|
||||
|
||||
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
|
||||
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden
|
||||
//! methods.
|
||||
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
|
||||
|
||||
//! Method which clear all selected owners belonging
|
||||
//! to this selectable object ( for fast presentation draw ).
|
||||
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
|
||||
|
||||
//! Method which draws selected owners ( for fast presentation draw ).
|
||||
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePM, const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const SelectMgr_SequenceOfOwner& theSeq)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Method which hilight an owner belonging to
|
||||
//! this selectable object ( for fast presentation draw ).
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor(
|
||||
const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT void init();
|
||||
|
||||
Standard_EXPORT void updateTransformation();
|
||||
|
||||
Standard_EXPORT Handle(Prs3d_Presentation) getHighlightPresentation (const Handle(SelectMgr_EntityOwner)& theOwner) const;
|
||||
Standard_EXPORT Handle(Prs3d_Presentation) getHighlightPresentation(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) const;
|
||||
|
||||
Standard_EXPORT Handle(Graphic3d_Group) getGroup (const Standard_Integer theIndex, const AIS_ManipulatorMode theMode) const;
|
||||
Standard_EXPORT Handle(Graphic3d_Group) getGroup(const Standard_Integer theIndex,
|
||||
const AIS_ManipulatorMode theMode) const;
|
||||
|
||||
Standard_EXPORT void attachToBox (const Bnd_Box& theBox);
|
||||
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.
|
||||
//! @warning this interactive object does not support setting custom local transformation,
|
||||
@ -364,52 +428,48 @@ protected:
|
||||
//! without need for recomputing presentation.
|
||||
//! @warning Invokes debug assertion in debug to catch incompatible usage of the
|
||||
//! method, silently does nothing in release mode.
|
||||
Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void setLocalTransformation(const Handle(TopLoc_Datum3D)& theTrsf)
|
||||
Standard_OVERRIDE;
|
||||
using AIS_InteractiveObject::SetLocalTransformation; // hide visibility
|
||||
|
||||
protected: //! @name Auxiliary classes to fill presentation with proper primitives
|
||||
|
||||
class Quadric
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~Quadric()
|
||||
{
|
||||
myTriangulation.Nullify();
|
||||
myArray.Nullify();
|
||||
}
|
||||
|
||||
|
||||
const Handle(Poly_Triangulation)& Triangulation() const { return myTriangulation; }
|
||||
|
||||
const Handle(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; }
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Poly_Triangulation) myTriangulation;
|
||||
Handle(Poly_Triangulation) myTriangulation;
|
||||
Handle(Graphic3d_ArrayOfTriangles) myArray;
|
||||
};
|
||||
|
||||
class Disk : public Quadric
|
||||
{
|
||||
public:
|
||||
|
||||
Disk()
|
||||
: Quadric(),
|
||||
myInnerRad(0.0f),
|
||||
myOuterRad(1.0f)
|
||||
{ }
|
||||
: Quadric(),
|
||||
myInnerRad(0.0f),
|
||||
myOuterRad(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
~Disk() { }
|
||||
~Disk() {}
|
||||
|
||||
void Init (const Standard_ShortReal theInnerRadius,
|
||||
const Standard_ShortReal theOuterRadius,
|
||||
const gp_Ax1& thePosition,
|
||||
const Standard_Integer theSlicesNb = 20,
|
||||
const Standard_Integer theStacksNb = 20);
|
||||
void Init(const Standard_ShortReal theInnerRadius,
|
||||
const Standard_ShortReal theOuterRadius,
|
||||
const gp_Ax1& thePosition,
|
||||
const Standard_Integer theSlicesNb = 20,
|
||||
const Standard_Integer theStacksNb = 20);
|
||||
|
||||
protected:
|
||||
|
||||
gp_Ax1 myPosition;
|
||||
Standard_ShortReal myInnerRad;
|
||||
Standard_ShortReal myOuterRad;
|
||||
@ -419,55 +479,56 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
{
|
||||
public:
|
||||
Sphere()
|
||||
: Quadric(),
|
||||
myRadius(1.0f)
|
||||
{}
|
||||
: Quadric(),
|
||||
myRadius(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
void Init (const Standard_ShortReal theRadius,
|
||||
const gp_Pnt& thePosition,
|
||||
const Standard_Integer theSlicesNb = 20,
|
||||
const Standard_Integer theStacksNb = 20);
|
||||
void Init(const Standard_ShortReal theRadius,
|
||||
const gp_Pnt& thePosition,
|
||||
const Standard_Integer theSlicesNb = 20,
|
||||
const Standard_Integer theStacksNb = 20);
|
||||
|
||||
protected:
|
||||
|
||||
gp_Pnt myPosition;
|
||||
gp_Pnt myPosition;
|
||||
Standard_ShortReal myRadius;
|
||||
};
|
||||
|
||||
class Cube
|
||||
{
|
||||
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(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; }
|
||||
|
||||
private:
|
||||
|
||||
void addTriangle (const Standard_Integer theIndex, const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
|
||||
const gp_Dir& theNormal);
|
||||
void addTriangle(const Standard_Integer theIndex,
|
||||
const gp_Pnt& theP1,
|
||||
const gp_Pnt& theP2,
|
||||
const gp_Pnt& theP3,
|
||||
const gp_Dir& theNormal);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Poly_Triangulation) myTriangulation;
|
||||
Handle(Poly_Triangulation) myTriangulation;
|
||||
Handle(Graphic3d_ArrayOfTriangles) myArray;
|
||||
};
|
||||
|
||||
class Sector : public Quadric
|
||||
{
|
||||
public:
|
||||
|
||||
Sector()
|
||||
: Quadric(),
|
||||
myRadius(0.0f)
|
||||
{ }
|
||||
: Quadric(),
|
||||
myRadius(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
~Sector() { }
|
||||
~Sector() {}
|
||||
|
||||
void Init(const Standard_ShortReal theRadius,
|
||||
const gp_Ax1& thePosition,
|
||||
@ -476,7 +537,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
const Standard_Integer theStacksNb = 5);
|
||||
|
||||
protected:
|
||||
|
||||
gp_Ax1 myPosition;
|
||||
Standard_ShortReal myRadius;
|
||||
};
|
||||
@ -489,36 +549,35 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
class Axis
|
||||
{
|
||||
public:
|
||||
Axis(const gp_Ax1& theAxis = gp_Ax1(),
|
||||
const Quantity_Color& theColor = Quantity_Color(),
|
||||
const Standard_ShortReal theLength = 10.0f);
|
||||
|
||||
Axis (const gp_Ax1& theAxis = gp_Ax1(),
|
||||
const Quantity_Color& theColor = Quantity_Color(),
|
||||
const Standard_ShortReal theLength = 10.0f);
|
||||
|
||||
void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
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; }
|
||||
|
||||
void SetPosition (const gp_Ax1& thePosition) { myPosition = thePosition; }
|
||||
void SetPosition(const gp_Ax1& thePosition) { myPosition = thePosition; }
|
||||
|
||||
const gp_Ax1& Position() const { return myPosition; }
|
||||
|
||||
void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
void SetTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
{
|
||||
if (!myHighlightTranslator.IsNull())
|
||||
{
|
||||
myHighlightTranslator->SetTransformPersistence (theTrsfPers);
|
||||
myHighlightTranslator->SetTransformPersistence(theTrsfPers);
|
||||
}
|
||||
|
||||
if (!myHighlightScaler.IsNull())
|
||||
{
|
||||
myHighlightScaler->SetTransformPersistence (theTrsfPers);
|
||||
myHighlightScaler->SetTransformPersistence(theTrsfPers);
|
||||
}
|
||||
|
||||
if (!myHighlightRotator.IsNull())
|
||||
{
|
||||
myHighlightRotator->SetTransformPersistence (theTrsfPers);
|
||||
myHighlightRotator->SetTransformPersistence(theTrsfPers);
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
myHighlightTranslator->SetTransformation (theTransformation);
|
||||
myHighlightTranslator->SetTransformation(theTransformation);
|
||||
}
|
||||
|
||||
if (!myHighlightScaler.IsNull())
|
||||
{
|
||||
myHighlightScaler->SetTransformation (theTransformation);
|
||||
myHighlightScaler->SetTransformation(theTransformation);
|
||||
}
|
||||
|
||||
if (!myHighlightRotator.IsNull())
|
||||
{
|
||||
myHighlightRotator->SetTransformation (theTransformation);
|
||||
myHighlightRotator->SetTransformation(theTransformation);
|
||||
}
|
||||
|
||||
if (!myHighlightDragger.IsNull())
|
||||
@ -558,11 +617,11 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
|
||||
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; }
|
||||
|
||||
@ -572,9 +631,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
|
||||
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; }
|
||||
|
||||
@ -592,57 +654,67 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
|
||||
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)
|
||||
{
|
||||
myLength = theValue * 0.7f;
|
||||
myBoxSize = theValue * 0.15f;
|
||||
myLength = theValue * 0.7f;
|
||||
myBoxSize = theValue * 0.15f;
|
||||
myDiskThickness = theValue * 0.05f;
|
||||
myIndent = theValue * 0.05f;
|
||||
myIndent = theValue * 0.05f;
|
||||
}
|
||||
else // use pre-set value of predent
|
||||
{
|
||||
Standard_ShortReal aLength = theValue - 2 * myIndent;
|
||||
myLength = aLength * 0.8f;
|
||||
myBoxSize = aLength * 0.15f;
|
||||
myDiskThickness = aLength * 0.05f;
|
||||
myLength = aLength * 0.8f;
|
||||
myBoxSize = aLength * 0.15f;
|
||||
myDiskThickness = aLength * 0.05f;
|
||||
}
|
||||
myInnerRadius = myIndent * 2 + myBoxSize + myLength;
|
||||
myAxisRadius = myBoxSize / 4.0f;
|
||||
myAxisRadius = myBoxSize / 4.0f;
|
||||
}
|
||||
|
||||
Standard_Integer FacettesNumber() const { return myFacettesNumber; }
|
||||
|
||||
public:
|
||||
|
||||
const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
|
||||
|
||||
const Sector& DraggerSector() const { return mySector; }
|
||||
|
||||
const Disk& RotatorDisk() const { return myCircle; }
|
||||
|
||||
float RotatorDiskRadius() const { return myCircleRadius; }
|
||||
|
||||
const Cube& ScalerCube() const { return myCube; }
|
||||
|
||||
const gp_Pnt& ScalerCubePosition() const { return myCubePos; }
|
||||
|
||||
protected:
|
||||
|
||||
gp_Ax1 myReferenceAxis; //!< Returns reference axis assignment.
|
||||
gp_Ax1 myPosition; //!< Position of the axis including local transformation.
|
||||
gp_Ax1 myReferenceAxis; //!< Returns reference axis assignment.
|
||||
gp_Ax1 myPosition; //!< Position of the axis including local transformation.
|
||||
Quantity_Color myColor;
|
||||
|
||||
Standard_Boolean myHasTranslation;
|
||||
Standard_Boolean myHasTranslation;
|
||||
Standard_ShortReal myLength; //!< Length of translation axis.
|
||||
Standard_ShortReal myAxisRadius;
|
||||
|
||||
Standard_Boolean myHasScaling;
|
||||
Standard_Boolean myHasScaling;
|
||||
Standard_ShortReal myBoxSize; //!< Size of scaling cube.
|
||||
|
||||
Standard_Boolean myHasRotation;
|
||||
Standard_Boolean myHasRotation;
|
||||
Standard_ShortReal myInnerRadius; //!< Radius of rotation circle.
|
||||
Standard_ShortReal myDiskThickness;
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Integer myFacettesNumber;
|
||||
|
||||
gp_Pnt myArrowTipPos;
|
||||
Sector mySector;
|
||||
Disk myCircle;
|
||||
float myCircleRadius;
|
||||
Cube myCube;
|
||||
gp_Pnt myCubePos;
|
||||
gp_Pnt myArrowTipPos;
|
||||
Sector mySector;
|
||||
Disk myCircle;
|
||||
float myCircleRadius;
|
||||
Cube myCube;
|
||||
gp_Pnt myCubePos;
|
||||
|
||||
Handle(Graphic3d_Group) myTranslatorGroup;
|
||||
Handle(Graphic3d_Group) myScalerGroup;
|
||||
@ -671,14 +742,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
|
||||
Handle(Prs3d_Presentation) myHighlightDragger;
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) myTriangleArray;
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
Axis myAxes[3]; //!< Tree axes of the manipulator.
|
||||
Sphere myCenter; //!< Visual part displaying the center sphere of the manipulator.
|
||||
// clang-format off
|
||||
Axis myAxes[3]; //!< Tree axes of the manipulator.
|
||||
Sphere myCenter; //!< Visual part displaying the center sphere of the manipulator.
|
||||
// clang-format off
|
||||
gp_Ax2 myPosition; //!< Position of the manipulator object. it displays its location and position of its axes.
|
||||
|
||||
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.
|
||||
Standard_Boolean myHasStartedTransformation; //!< Shows if transformation is processed (sequential calls of Transform()).
|
||||
// clang-format on
|
||||
gp_Ax2 myStartPosition; //! Start position of manipulator.
|
||||
gp_Pnt myStartPick; //! 3d point corresponding to start mouse pick.
|
||||
Standard_Real myPrevState; //! Previous value of angle during rotation.
|
||||
// clang-format on
|
||||
gp_Ax2 myStartPosition; //! Start position of manipulator.
|
||||
gp_Pnt myStartPick; //! 3d point corresponding to start mouse pick.
|
||||
Standard_Real myPrevState; //! Previous value of angle during rotation.
|
||||
|
||||
//! Aspect used to color current detected part and current selected part.
|
||||
Handle(Prs3d_ShadingAspect) myHighlightAspect;
|
||||
|
||||
//! Aspect used to color sector part when it's selected.
|
||||
Handle(Prs3d_ShadingAspect) myDraggerHighlight;
|
||||
public:
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)
|
||||
};
|
||||
#endif // _AIS_Manipulator_HeaderFile
|
||||
|
@ -19,7 +19,7 @@
|
||||
//! Mode to make definite kind of transformations with AIS_Manipulator object.
|
||||
enum AIS_ManipulatorMode
|
||||
{
|
||||
AIS_MM_None = 0,
|
||||
AIS_MM_None = 0,
|
||||
AIS_MM_Translation = 1,
|
||||
AIS_MM_Rotation,
|
||||
AIS_MM_Scaling,
|
||||
|
@ -15,65 +15,58 @@
|
||||
|
||||
#include <AIS_ManipulatorOwner.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_ManipulatorOwner,SelectMgr_EntityOwner)
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_ManipulatorOwner::AIS_ManipulatorOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Standard_Integer theIndex,
|
||||
const AIS_ManipulatorMode theMode,
|
||||
const Standard_Integer thePriority)
|
||||
: SelectMgr_EntityOwner(theSelObject, thePriority),
|
||||
myIndex (theIndex),
|
||||
myMode (theMode)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_ManipulatorOwner, SelectMgr_EntityOwner)
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
AIS_ManipulatorOwner::AIS_ManipulatorOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Standard_Integer theIndex,
|
||||
const AIS_ManipulatorMode theMode,
|
||||
const Standard_Integer thePriority)
|
||||
: SelectMgr_EntityOwner(theSelObject, thePriority),
|
||||
myIndex(theIndex),
|
||||
myMode(theMode)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ManipulatorOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_ManipulatorOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode == 0)
|
||||
{
|
||||
SelectMgr_EntityOwner::HilightWithColor (thePM, theStyle, theMode);
|
||||
SelectMgr_EntityOwner::HilightWithColor(thePM, theStyle, theMode);
|
||||
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())
|
||||
{
|
||||
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())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
thePM->Unhighlight (Selectable());
|
||||
thePM->Unhighlight(Selectable());
|
||||
}
|
||||
|
@ -27,22 +27,23 @@ DEFINE_STANDARD_HANDLE(AIS_ManipulatorOwner, SelectMgr_EntityOwner)
|
||||
class AIS_ManipulatorOwner : public SelectMgr_EntityOwner
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ManipulatorOwner, SelectMgr_EntityOwner)
|
||||
|
||||
Standard_EXPORT AIS_ManipulatorOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Standard_Integer theIndex,
|
||||
const AIS_ManipulatorMode theMode,
|
||||
const Standard_Integer thePriority = 0);
|
||||
Standard_EXPORT AIS_ManipulatorOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Standard_Integer theIndex,
|
||||
const AIS_ManipulatorMode theMode,
|
||||
const Standard_Integer thePriority = 0);
|
||||
|
||||
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) const Standard_OVERRIDE;
|
||||
Standard_EXPORT Standard_Boolean
|
||||
IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
AIS_ManipulatorMode Mode() const { return myMode; }
|
||||
|
||||
@ -50,9 +51,8 @@ public:
|
||||
Standard_Integer Index() const { return myIndex; }
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Integer myIndex; //!< index of manipulator axis.
|
||||
AIS_ManipulatorMode myMode;//!< manipulation (highlight) mode.
|
||||
Standard_Integer myIndex; //!< index of manipulator axis.
|
||||
AIS_ManipulatorMode myMode; //!< manipulation (highlight) mode.
|
||||
};
|
||||
|
||||
#endif // _AIS_ManipulatorOwner_HeaderFile
|
||||
|
@ -25,44 +25,46 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
|
||||
|
||||
//! Create an array of triangles defining a rectangle.
|
||||
static Handle(Graphic3d_ArrayOfTriangles) createRectangleArray (const Graphic3d_Vec2i& theLower,
|
||||
const Graphic3d_Vec2i& theUpper,
|
||||
Graphic3d_ArrayFlags theFlags)
|
||||
static Handle(Graphic3d_ArrayOfTriangles) createRectangleArray(const Graphic3d_Vec2i& theLower,
|
||||
const Graphic3d_Vec2i& theUpper,
|
||||
Graphic3d_ArrayFlags 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(), 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(), theLower.y(), 0.0), gp_Pnt2d (1.0, 1.0));
|
||||
aRectTris->AddEdges (1, 2, 3);
|
||||
aRectTris->AddEdges (1, 3, 4);
|
||||
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(), 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(), theLower.y(), 0.0), gp_Pnt2d(1.0, 1.0));
|
||||
aRectTris->AddEdges(1, 2, 3);
|
||||
aRectTris->AddEdges(1, 3, 4);
|
||||
return aRectTris;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : AIS_MediaPlayer
|
||||
// Purpose :
|
||||
//================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_MediaPlayer::AIS_MediaPlayer()
|
||||
: myFramePair (new Graphic3d_MediaTextureSet()),
|
||||
myFrameSize (1, 1),
|
||||
myToClosePlayer (false)
|
||||
: myFramePair(new Graphic3d_MediaTextureSet()),
|
||||
myFrameSize(1, 1),
|
||||
myToClosePlayer(false)
|
||||
{
|
||||
SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
|
||||
SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||
SetInfiniteState (true);
|
||||
SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
|
||||
SetZLayer(Graphic3d_ZLayerId_TopOSD);
|
||||
SetInfiniteState(true);
|
||||
|
||||
Graphic3d_MaterialAspect aMat;
|
||||
myFrameAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE, Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0f, aMat, aMat);
|
||||
myFrameAspect->SetShadingModel (Graphic3d_TypeOfShadingModel_Unlit);
|
||||
myFrameAspect->SetTextureMapOn (true);
|
||||
myFrameAspect->SetTextureSet (myFramePair);
|
||||
myFrameAspect = new Graphic3d_AspectFillArea3d(Aspect_IS_SOLID,
|
||||
Quantity_NOC_WHITE,
|
||||
Quantity_NOC_BLACK,
|
||||
Aspect_TOL_SOLID,
|
||||
1.0f,
|
||||
aMat,
|
||||
aMat);
|
||||
myFrameAspect->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
|
||||
myFrameAspect->SetTextureMapOn(true);
|
||||
myFrameAspect->SetTextureSet(myFramePair);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
// Function : ~AIS_MediaPlayer
|
||||
// Purpose :
|
||||
//================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_MediaPlayer::~AIS_MediaPlayer()
|
||||
{
|
||||
// stop threads
|
||||
@ -73,16 +75,14 @@ AIS_MediaPlayer::~AIS_MediaPlayer()
|
||||
// function : OpenInput
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_MediaPlayer::OpenInput (const TCollection_AsciiString& thePath,
|
||||
Standard_Boolean theToWait)
|
||||
void AIS_MediaPlayer::OpenInput(const TCollection_AsciiString& thePath, Standard_Boolean theToWait)
|
||||
{
|
||||
if (myFramePair->PlayerContext().IsNull()
|
||||
&& thePath.IsEmpty())
|
||||
if (myFramePair->PlayerContext().IsNull() && thePath.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myFramePair->OpenInput (thePath, theToWait);
|
||||
myFramePair->OpenInput(thePath, theToWait);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
@ -90,8 +90,8 @@ void AIS_MediaPlayer::OpenInput (const TCollection_AsciiString& thePath,
|
||||
// function : PresentFrame
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize)
|
||||
bool AIS_MediaPlayer::PresentFrame(const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize)
|
||||
{
|
||||
if (myToClosePlayer)
|
||||
{
|
||||
@ -106,9 +106,9 @@ bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
|
||||
myFramePair->PlayerContext()->Pause();
|
||||
}
|
||||
|
||||
Handle(AIS_InteractiveContext) aCtx = GetContext();
|
||||
Handle(AIS_InteractiveObject) aThis = this;
|
||||
aCtx->Remove (aThis, false);
|
||||
Handle(AIS_InteractiveContext) aCtx = GetContext();
|
||||
Handle(AIS_InteractiveObject) aThis = this;
|
||||
aCtx->Remove(aThis, false);
|
||||
aCtx->CurrentViewer()->Invalidate();
|
||||
return true;
|
||||
}
|
||||
@ -119,10 +119,10 @@ bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
|
||||
}
|
||||
|
||||
bool toRedraw = myFramePair->SwapFrames();
|
||||
toRedraw = updateSize (theLeftCorner, theMaxSize) || toRedraw;
|
||||
toRedraw = updateSize(theLeftCorner, theMaxSize) || toRedraw;
|
||||
if (toRedraw)
|
||||
{
|
||||
myFrameAspect->SetShaderProgram (myFramePair->ShaderProgram());
|
||||
myFrameAspect->SetShaderProgram(myFramePair->ShaderProgram());
|
||||
SynchronizeAspects();
|
||||
}
|
||||
return toRedraw;
|
||||
@ -132,18 +132,17 @@ bool AIS_MediaPlayer::PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
|
||||
// function : updateSize
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize)
|
||||
bool AIS_MediaPlayer::updateSize(const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize)
|
||||
{
|
||||
const Graphic3d_Vec2i aFrameSize = myFramePair->FrameSize();
|
||||
Graphic3d_Vec2i aNewPos = theLeftCorner;
|
||||
Graphic3d_Vec2i aNewSize = myFrameSize;
|
||||
if (aFrameSize.x() > 0
|
||||
&& aFrameSize.y() > 0)
|
||||
Graphic3d_Vec2i aNewPos = theLeftCorner;
|
||||
Graphic3d_Vec2i aNewSize = myFrameSize;
|
||||
if (aFrameSize.x() > 0 && aFrameSize.y() > 0)
|
||||
{
|
||||
const double anAspect = double(theMaxSize.x()) / double(theMaxSize.y());
|
||||
const double aFitAspect = double(aFrameSize.x()) / double(aFrameSize.y());
|
||||
aNewSize = aFrameSize;
|
||||
aNewSize = aFrameSize;
|
||||
if (aFitAspect >= anAspect)
|
||||
{
|
||||
aNewSize.y() = int(double(aFrameSize.x()) / aFitAspect);
|
||||
@ -158,31 +157,29 @@ bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner,
|
||||
if (aNewSize[aCoord] > theMaxSize[aCoord])
|
||||
{
|
||||
const double aScale = double(theMaxSize[aCoord]) / double(aNewSize[aCoord]);
|
||||
aNewSize.x() = int(double(aNewSize.x()) * aScale);
|
||||
aNewSize.y() = int(double(aNewSize.y()) * aScale);
|
||||
aNewSize.x() = int(double(aNewSize.x()) * aScale);
|
||||
aNewSize.y() = int(double(aNewSize.y()) * aScale);
|
||||
}
|
||||
}
|
||||
|
||||
aNewPos = theLeftCorner + theMaxSize / 2 - aNewSize / 2;
|
||||
}
|
||||
else if (myFrameSize.x() < 2
|
||||
|| myFrameSize.y() < 2)
|
||||
else if (myFrameSize.x() < 2 || myFrameSize.y() < 2)
|
||||
{
|
||||
aNewSize = theMaxSize;
|
||||
}
|
||||
|
||||
if (myFrameSize == aNewSize
|
||||
&& myFrameBottomLeft == aNewPos)
|
||||
if (myFrameSize == aNewSize && myFrameBottomLeft == aNewPos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
myFrameSize = aNewSize;
|
||||
myFrameSize = aNewSize;
|
||||
myFrameBottomLeft = aNewPos;
|
||||
if (HasInteractiveContext())
|
||||
{
|
||||
SetToUpdate();
|
||||
GetContext()->Redisplay (this, false);
|
||||
GetContext()->Redisplay(this, false);
|
||||
GetContext()->CurrentViewer()->Invalidate();
|
||||
}
|
||||
return true;
|
||||
@ -200,19 +197,19 @@ void AIS_MediaPlayer::PlayPause()
|
||||
}
|
||||
|
||||
Standard_Real aProgress = 0.0, aDuration = 0.0;
|
||||
bool isPaused = false;
|
||||
myFramePair->PlayerContext()->PlayPause (isPaused, aProgress, aDuration);
|
||||
bool isPaused = false;
|
||||
myFramePair->PlayerContext()->PlayPause(isPaused, aProgress, aDuration);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Compute
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
void AIS_MediaPlayer::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
thePrs->SetInfiniteState (IsInfinite());
|
||||
thePrs->SetInfiniteState(IsInfinite());
|
||||
if (theMode != 0)
|
||||
{
|
||||
return;
|
||||
@ -220,10 +217,13 @@ void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
|
||||
// main frame
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris = createRectangleArray (myFrameBottomLeft, myFrameBottomLeft + myFrameSize, Graphic3d_ArrayFlags_VertexTexel);
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris =
|
||||
createRectangleArray(myFrameBottomLeft,
|
||||
myFrameBottomLeft + myFrameSize,
|
||||
Graphic3d_ArrayFlags_VertexTexel);
|
||||
Handle(Graphic3d_Group) aMainGroup = thePrs->NewGroup();
|
||||
aMainGroup->SetGroupPrimitivesAspect (myFrameAspect);
|
||||
aMainGroup->AddPrimitiveArray (aTris);
|
||||
aMainGroup->SetGroupPrimitivesAspect(myFrameAspect);
|
||||
aMainGroup->AddPrimitiveArray(aTris);
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,18 +231,20 @@ void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
// function : ComputeSelection
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_MediaPlayer::ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode)
|
||||
void AIS_MediaPlayer::ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris = createRectangleArray (myFrameBottomLeft, myFrameBottomLeft + myFrameSize, Graphic3d_ArrayFlags_None);
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris = createRectangleArray(myFrameBottomLeft,
|
||||
myFrameBottomLeft + myFrameSize,
|
||||
Graphic3d_ArrayFlags_None);
|
||||
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this, 5);
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSens = new Select3D_SensitivePrimitiveArray (anOwner);
|
||||
aSens->InitTriangulation (aTris->Attributes(), aTris->Indices(), TopLoc_Location());
|
||||
theSel->Add (aSens);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this, 5);
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSens = new Select3D_SensitivePrimitiveArray(anOwner);
|
||||
aSens->InitTriangulation(aTris->Attributes(), aTris->Indices(), TopLoc_Location());
|
||||
theSel->Add(aSens);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ class AIS_MediaPlayer : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT AIS_MediaPlayer();
|
||||
|
||||
@ -33,18 +32,19 @@ public:
|
||||
Standard_EXPORT virtual ~AIS_MediaPlayer();
|
||||
|
||||
//! Setup callback to be called on queue progress (e.g. when new frame should be displayed).
|
||||
void SetCallback (Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction, void* theCallbackUserPtr)
|
||||
void SetCallback(Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction,
|
||||
void* theCallbackUserPtr)
|
||||
{
|
||||
myFramePair->SetCallback (theCallbackFunction, theCallbackUserPtr);
|
||||
myFramePair->SetCallback(theCallbackFunction, theCallbackUserPtr);
|
||||
}
|
||||
|
||||
//! Open specified file.
|
||||
Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath,
|
||||
Standard_Boolean theToWait);
|
||||
Standard_EXPORT void OpenInput(const TCollection_AsciiString& thePath,
|
||||
Standard_Boolean theToWait);
|
||||
|
||||
//! Display new frame.
|
||||
Standard_EXPORT bool PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize);
|
||||
Standard_EXPORT bool PresentFrame(const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize);
|
||||
|
||||
//! Return player context.
|
||||
const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); }
|
||||
@ -62,35 +62,34 @@ public:
|
||||
//! Return duration.
|
||||
double Duration() const { return myFramePair->Duration(); }
|
||||
|
||||
//! @name AIS_InteractiveObject interface
|
||||
//! @name AIS_InteractiveObject interface
|
||||
protected:
|
||||
|
||||
//! Accept only display mode 0.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
|
||||
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode == 0;
|
||||
}
|
||||
|
||||
//! Compute presentation.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Update frame size.
|
||||
Standard_EXPORT bool updateSize (const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize);
|
||||
Standard_EXPORT bool updateSize(const Graphic3d_Vec2i& theLeftCorner,
|
||||
const Graphic3d_Vec2i& theMaxSize);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Graphic3d_MediaTextureSet) myFramePair;
|
||||
Handle(Graphic3d_AspectFillArea3d) myFrameAspect;
|
||||
Graphic3d_Vec2i myFrameBottomLeft;
|
||||
Graphic3d_Vec2i myFrameSize;
|
||||
bool myToClosePlayer;
|
||||
|
||||
Graphic3d_Vec2i myFrameBottomLeft;
|
||||
Graphic3d_Vec2i myFrameSize;
|
||||
bool myToClosePlayer;
|
||||
};
|
||||
|
||||
#endif // _AIS_MediaPlayer_HeaderFile
|
||||
|
@ -20,28 +20,32 @@
|
||||
//! Mouse gesture - only one can be active at one moment.
|
||||
enum AIS_MouseGesture
|
||||
{
|
||||
AIS_MouseGesture_NONE, //!< no active gesture
|
||||
AIS_MouseGesture_NONE, //!< no active gesture
|
||||
//
|
||||
AIS_MouseGesture_SelectRectangle, //!< rectangular selection;
|
||||
//! press button to start, move mouse to define rectangle, release to finish
|
||||
//! press button to start, move mouse to define rectangle,
|
||||
//! release to finish
|
||||
AIS_MouseGesture_SelectLasso, //!< polygonal selection;
|
||||
//! press button to start, move mouse to define polygonal path, release to finish
|
||||
//! press button to start, move mouse to define polygonal path,
|
||||
//! release to finish
|
||||
//
|
||||
AIS_MouseGesture_Zoom, //!< view zoom gesture;
|
||||
//! move mouse left to zoom-out, and to the right to zoom-in
|
||||
AIS_MouseGesture_ZoomVertical, //!< view zoom gesture;
|
||||
//! move mouse up to zoom-out, and to the down to zoom-in
|
||||
AIS_MouseGesture_ZoomWindow, //!< view zoom by window gesture;
|
||||
//! press button to start, move mouse to define rectangle, release to finish
|
||||
AIS_MouseGesture_Pan, //!< view panning gesture
|
||||
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
|
||||
AIS_MouseGesture_RotateView, //!< view rotation gesture
|
||||
AIS_MouseGesture_Drag, //!< object dragging;
|
||||
//! press button to start, move mouse to define rectangle, release to finish
|
||||
AIS_MouseGesture_Zoom, //!< view zoom gesture;
|
||||
//! move mouse left to zoom-out, and to the right to zoom-in
|
||||
AIS_MouseGesture_ZoomVertical, //!< view zoom gesture;
|
||||
//! move mouse up to zoom-out, and to the down to zoom-in
|
||||
AIS_MouseGesture_ZoomWindow, //!< view zoom by window gesture;
|
||||
//! press button to start, move mouse to define rectangle, release
|
||||
//! to finish
|
||||
AIS_MouseGesture_Pan, //!< view panning gesture
|
||||
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
|
||||
AIS_MouseGesture_RotateView, //!< view rotation gesture
|
||||
AIS_MouseGesture_Drag, //!< object dragging;
|
||||
//! press button to start, move mouse to define rectangle, release to
|
||||
//! finish
|
||||
};
|
||||
|
||||
//! 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;
|
||||
|
||||
#endif // _AIS_MouseGesture_HeaderFile
|
||||
|
@ -21,49 +21,49 @@
|
||||
#include <AIS_InteractiveObject.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_InteractiveObject (PrsMgr_TOP_AllView)
|
||||
: AIS_InteractiveObject(PrsMgr_TOP_AllView)
|
||||
{
|
||||
myHasOwnPresentations = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : connect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theTrsf,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
//=================================================================================================
|
||||
|
||||
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect(
|
||||
const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theTrsf,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
{
|
||||
if (myAssemblyOwner.IsNull())
|
||||
myAssemblyOwner = new SelectMgr_EntityOwner (this);
|
||||
myAssemblyOwner = new SelectMgr_EntityOwner(this);
|
||||
|
||||
Handle(AIS_InteractiveObject) anObjectToAdd;
|
||||
|
||||
Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
|
||||
Handle(AIS_MultipleConnectedInteractive) aMultiConnected =
|
||||
Handle(AIS_MultipleConnectedInteractive)::DownCast(theAnotherObj);
|
||||
if (!aMultiConnected.IsNull())
|
||||
{
|
||||
Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
|
||||
{
|
||||
Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected =
|
||||
new AIS_MultipleConnectedInteractive();
|
||||
aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
|
||||
aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom());
|
||||
aNewMultiConnected->SetLocalTransformation(aMultiConnected->LocalTransformationGeom());
|
||||
|
||||
// Perform deep copy of instance tree
|
||||
for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
|
||||
for (PrsMgr_ListOfPresentableObjectsIter anIter(aMultiConnected->Children()); anIter.More();
|
||||
anIter.Next())
|
||||
{
|
||||
Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
|
||||
Handle(AIS_InteractiveObject) anInteractive =
|
||||
Handle(AIS_InteractiveObject)::DownCast(anIter.Value());
|
||||
if (anInteractive.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
aNewMultiConnected->Connect (anInteractive);
|
||||
aNewMultiConnected->Connect(anInteractive);
|
||||
}
|
||||
|
||||
anObjectToAdd = aNewMultiConnected;
|
||||
@ -71,81 +71,69 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const H
|
||||
else
|
||||
{
|
||||
Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
|
||||
aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom());
|
||||
aNewConnected->Connect(theAnotherObj, theAnotherObj->LocalTransformationGeom());
|
||||
|
||||
anObjectToAdd = aNewConnected;
|
||||
}
|
||||
|
||||
anObjectToAdd->SetLocalTransformation (theTrsf);
|
||||
anObjectToAdd->SetLocalTransformation(theTrsf);
|
||||
if (!theTrsfPers.IsNull())
|
||||
{
|
||||
anObjectToAdd->SetTransformPersistence (theTrsfPers);
|
||||
anObjectToAdd->SetTransformPersistence(theTrsfPers);
|
||||
}
|
||||
AddChild (anObjectToAdd);
|
||||
AddChild(anObjectToAdd);
|
||||
return anObjectToAdd;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasConnection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
|
||||
{
|
||||
return (Children().Size() != 0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Disconnect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
|
||||
{
|
||||
RemoveChild (anotherIObj);
|
||||
RemoveChild(anotherIObj);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DisconnectAll
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_MultipleConnectedInteractive::DisconnectAll()
|
||||
{
|
||||
Standard_Integer aNbItemsToRemove = Children().Size();
|
||||
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)& ,
|
||||
const Standard_Integer )
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_MultipleConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)&,
|
||||
const Standard_Integer)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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())
|
||||
{
|
||||
continue;
|
||||
@ -159,49 +147,46 @@ Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() co
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_MultipleConnectedInteractive::ComputeSelection(
|
||||
const Handle(SelectMgr_Selection)& /*theSelection*/,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode == 0)
|
||||
{
|
||||
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())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!aChild->HasSelection (theMode))
|
||||
if (!aChild->HasSelection(theMode))
|
||||
{
|
||||
aChild->RecomputePrimitives (theMode);
|
||||
aChild->RecomputePrimitives(theMode);
|
||||
}
|
||||
|
||||
Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
|
||||
aChild->ComputeSelection (aSelection, theMode);
|
||||
Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection(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);
|
||||
for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
|
||||
AIS_InteractiveObject::SetContext(theCtx);
|
||||
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())
|
||||
{
|
||||
aChild->SetContext (theCtx);
|
||||
aChild->SetContext(theCtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,104 +29,119 @@ class AIS_MultipleConnectedInteractive : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes the Interactive Object with multiple
|
||||
//! connections to AIS_Interactive objects.
|
||||
Standard_EXPORT AIS_MultipleConnectedInteractive();
|
||||
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
|
||||
//! Locates instance in theLocation and applies specified transformation persistence mode.
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
|
||||
//! reference. Locates instance in theLocation and applies specified transformation persistence
|
||||
//! mode.
|
||||
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
|
||||
Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const Handle(TopLoc_Datum3D)& theLocation,
|
||||
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; }
|
||||
|
||||
|
||||
//! Returns true if the object is connected to others.
|
||||
Standard_EXPORT Standard_Boolean HasConnection() const;
|
||||
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void DisconnectAll();
|
||||
|
||||
|
||||
//! Informs the graphic context that the interactive Object
|
||||
//! may be decomposed into sub-shapes for dynamic selection.
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns common entity owner if the object is an assembly
|
||||
virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const Standard_OVERRIDE { return myAssemblyOwner; }
|
||||
virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const Standard_OVERRIDE
|
||||
{
|
||||
return myAssemblyOwner;
|
||||
}
|
||||
|
||||
//! Returns the owner of mode for selection of object as a whole
|
||||
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return myAssemblyOwner; }
|
||||
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE
|
||||
{
|
||||
return myAssemblyOwner;
|
||||
}
|
||||
|
||||
//! Assigns interactive context.
|
||||
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& theCtx) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& theCtx)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
public: // short aliases to Connect() method
|
||||
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
|
||||
//! Copies local transformation and transformation persistence mode from theInteractive.
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
|
||||
//! reference. Copies local transformation and transformation persistence mode from
|
||||
//! theInteractive.
|
||||
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
|
||||
Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
|
||||
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj)
|
||||
{
|
||||
return connect (theAnotherObj, theAnotherObj->LocalTransformationGeom(), theAnotherObj->TransformPersistence());
|
||||
return connect(theAnotherObj,
|
||||
theAnotherObj->LocalTransformationGeom(),
|
||||
theAnotherObj->TransformPersistence());
|
||||
}
|
||||
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
|
||||
//! Locates instance in theLocation and copies transformation persistence mode from theInteractive.
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
|
||||
//! reference. Locates instance in theLocation and copies transformation persistence mode from
|
||||
//! theInteractive.
|
||||
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
|
||||
Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const gp_Trsf& theLocation)
|
||||
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const gp_Trsf& theLocation)
|
||||
{
|
||||
return connect (theAnotherObj, new TopLoc_Datum3D (theLocation), theAnotherObj->TransformPersistence());
|
||||
return connect(theAnotherObj,
|
||||
new TopLoc_Datum3D(theLocation),
|
||||
theAnotherObj->TransformPersistence());
|
||||
}
|
||||
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
|
||||
//! Locates instance in theLocation and applies specified transformation persistence mode.
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
|
||||
//! reference. Locates instance in theLocation and applies specified transformation persistence
|
||||
//! mode.
|
||||
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
|
||||
Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const gp_Trsf& theLocation,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
|
||||
const gp_Trsf& theLocation,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
{
|
||||
return connect (theAnotherObj, new TopLoc_Datum3D (theLocation), theTrsfPers);
|
||||
return connect(theAnotherObj, new TopLoc_Datum3D(theLocation), theTrsfPers);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! this method is redefined virtual;
|
||||
//! when the instance is connected to another
|
||||
//! InteractiveObject,this method doesn't
|
||||
//! compute anything, but just uses the
|
||||
//! presentation of this last object, with
|
||||
//! a transformation if there's one stored.
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
|
||||
//! Locates instance in theLocation and applies specified transformation persistence mode.
|
||||
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
|
||||
//! reference. Locates instance in theLocation and applies specified transformation persistence
|
||||
//! mode.
|
||||
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
|
||||
Standard_EXPORT virtual Handle(AIS_InteractiveObject) connect (const Handle(AIS_InteractiveObject)& theInteractive,
|
||||
const Handle(TopLoc_Datum3D)& theLocation,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers);
|
||||
Standard_EXPORT virtual Handle(AIS_InteractiveObject) connect(
|
||||
const Handle(AIS_InteractiveObject)& theInteractive,
|
||||
const Handle(TopLoc_Datum3D)& theLocation,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers);
|
||||
|
||||
private:
|
||||
|
||||
//! Computes the selection for whole subtree in scene hierarchy.
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
const Standard_Integer aMode) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Handle(SelectMgr_EntityOwner) myAssemblyOwner;
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
|
||||
|
@ -46,375 +46,348 @@
|
||||
#include <StdPrs_Plane.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),
|
||||
myCenter(gp_Pnt(0.,0.,0.)),
|
||||
myCurrentMode(aCurrentMode),
|
||||
myAutomaticPosition(Standard_True),
|
||||
myTypeOfPlane(AIS_TOPL_Unknown),
|
||||
myIsXYZPlane(Standard_False),
|
||||
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent, const Standard_Boolean aCurrentMode)
|
||||
: myComponent(aComponent),
|
||||
myCenter(gp_Pnt(0., 0., 0.)),
|
||||
myCurrentMode(aCurrentMode),
|
||||
myAutomaticPosition(Standard_True),
|
||||
myTypeOfPlane(AIS_TOPL_Unknown),
|
||||
myIsXYZPlane(Standard_False),
|
||||
myTypeOfSensitivity(Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
InitDrawerAttributes();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Plane
|
||||
//purpose : avec une position
|
||||
// function : AIS_Plane
|
||||
// purpose : avec une position
|
||||
//=======================================================================
|
||||
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
|
||||
const gp_Pnt& aCenter,
|
||||
const Standard_Boolean aCurrentMode):
|
||||
myComponent(aComponent),
|
||||
myCenter(aCenter),
|
||||
myCurrentMode(aCurrentMode),
|
||||
myAutomaticPosition(Standard_True),
|
||||
myTypeOfPlane(AIS_TOPL_Unknown),
|
||||
myIsXYZPlane(Standard_False),
|
||||
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
|
||||
const gp_Pnt& aCenter,
|
||||
const Standard_Boolean aCurrentMode)
|
||||
: myComponent(aComponent),
|
||||
myCenter(aCenter),
|
||||
myCurrentMode(aCurrentMode),
|
||||
myAutomaticPosition(Standard_True),
|
||||
myTypeOfPlane(AIS_TOPL_Unknown),
|
||||
myIsXYZPlane(Standard_False),
|
||||
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();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Plane
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
|
||||
const gp_Pnt& aCenter,
|
||||
const gp_Pnt& aPmin,
|
||||
const gp_Pnt& aPmax,
|
||||
const Standard_Boolean aCurrentMode):
|
||||
myComponent(aComponent),
|
||||
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
|
||||
// function : AIS_Plane
|
||||
// purpose : XYPlane, XZPlane, YZPlane
|
||||
//=======================================================================
|
||||
AIS_Plane::AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent,
|
||||
const AIS_TypeOfPlane aPlaneType,
|
||||
const Standard_Boolean aCurrentMode):
|
||||
myAx2(aComponent),
|
||||
myCurrentMode(aCurrentMode),
|
||||
myAutomaticPosition(Standard_True),
|
||||
myTypeOfPlane(aPlaneType),
|
||||
myIsXYZPlane(Standard_True),
|
||||
myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
|
||||
const AIS_TypeOfPlane aPlaneType,
|
||||
const Standard_Boolean aCurrentMode)
|
||||
: myAx2(aComponent),
|
||||
myCurrentMode(aCurrentMode),
|
||||
myAutomaticPosition(Standard_True),
|
||||
myTypeOfPlane(aPlaneType),
|
||||
myIsXYZPlane(Standard_True),
|
||||
myTypeOfSensitivity(Select3D_TOS_BOUNDARY)
|
||||
{
|
||||
InitDrawerAttributes();
|
||||
ComputeFields();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetComponent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent)
|
||||
{
|
||||
myComponent = aComponent;
|
||||
myComponent = aComponent;
|
||||
myTypeOfPlane = AIS_TOPL_Unknown;
|
||||
myIsXYZPlane = Standard_False;
|
||||
//myCenter = gp_Pnt(0.,0.,0.);
|
||||
myIsXYZPlane = Standard_False;
|
||||
// myCenter = gp_Pnt(0.,0.,0.);
|
||||
myAutomaticPosition = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Axis2Placement
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Geom_Axis2Placement) AIS_Plane::Axis2Placement()
|
||||
{
|
||||
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;
|
||||
myIsXYZPlane = Standard_True;
|
||||
myAx2= aComponent;
|
||||
myTypeOfPlane = aPlaneType;
|
||||
myIsXYZPlane = Standard_True;
|
||||
myAx2 = aComponent;
|
||||
myAutomaticPosition = Standard_True;
|
||||
ComputeFields();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PlaneAttributes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_Plane::PlaneAttributes(Handle(Geom_Plane)& aComponent,
|
||||
gp_Pnt& aCenter,
|
||||
gp_Pnt& aPmin,
|
||||
gp_Pnt& aPmax)
|
||||
gp_Pnt& aCenter,
|
||||
gp_Pnt& aPmin,
|
||||
gp_Pnt& aPmax)
|
||||
{
|
||||
Standard_Boolean aStatus (Standard_False);
|
||||
if (!myAutomaticPosition){
|
||||
Standard_Boolean aStatus(Standard_False);
|
||||
if (!myAutomaticPosition)
|
||||
{
|
||||
aComponent = myComponent;
|
||||
aCenter = myCenter;
|
||||
aPmin = myPmin;
|
||||
aPmax = myPmax;
|
||||
aStatus = Standard_True;
|
||||
aCenter = myCenter;
|
||||
aPmin = myPmin;
|
||||
aPmax = myPmax;
|
||||
aStatus = Standard_True;
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPlaneAttributes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::SetPlaneAttributes(const Handle(Geom_Plane)& aComponent,
|
||||
const gp_Pnt& aCenter,
|
||||
const gp_Pnt& aPmin,
|
||||
const gp_Pnt& aPmax)
|
||||
const gp_Pnt& aCenter,
|
||||
const gp_Pnt& aPmin,
|
||||
const gp_Pnt& aPmax)
|
||||
{
|
||||
myAutomaticPosition = Standard_False;
|
||||
myComponent = aComponent;
|
||||
myCenter = aCenter;
|
||||
myPmin = aPmin;
|
||||
myPmax = aPmax;
|
||||
myTypeOfPlane = AIS_TOPL_Unknown;
|
||||
myIsXYZPlane = Standard_False;
|
||||
myComponent = aComponent;
|
||||
myCenter = aCenter;
|
||||
myPmin = aPmin;
|
||||
myPmax = aPmax;
|
||||
myTypeOfPlane = AIS_TOPL_Unknown;
|
||||
myIsXYZPlane = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Plane::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
ComputeFields();
|
||||
thePrs->SetInfiniteState (myInfiniteState);
|
||||
myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0? 1 : 3);
|
||||
thePrs->SetInfiniteState(myInfiniteState);
|
||||
myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0 ? 1 : 3);
|
||||
|
||||
switch (theMode)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
case 0: {
|
||||
if (!myIsXYZPlane)
|
||||
{
|
||||
ComputeFrame();
|
||||
const Handle(Geom_Plane)& pl = myComponent;
|
||||
Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
|
||||
Handle(Geom_Plane) thegoodpl(
|
||||
Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(), myCenter)));
|
||||
GeomAdaptor_Surface surf(thegoodpl);
|
||||
StdPrs_Plane::Add (thePrs, surf, myDrawer);
|
||||
StdPrs_Plane::Add(thePrs, surf, myDrawer);
|
||||
}
|
||||
else
|
||||
{
|
||||
DsgPrs_XYZPlanePresentation::Add (thePrs, myDrawer, myCenter, myPmin, myPmax);
|
||||
DsgPrs_XYZPlanePresentation::Add(thePrs, myDrawer, myCenter, myPmin, myPmax);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
case 1: {
|
||||
if (!myIsXYZPlane)
|
||||
{
|
||||
ComputeFrame();
|
||||
Handle(Prs3d_PlaneAspect) anAspect = myDrawer->PlaneAspect();
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
|
||||
aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
gp_Pnt p1;
|
||||
const Standard_Real Xmax = 0.5*Standard_Real(anAspect->PlaneXLength());
|
||||
const Standard_Real Ymax = 0.5*Standard_Real(anAspect->PlaneYLength());
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
|
||||
aGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
|
||||
gp_Pnt p1;
|
||||
const Standard_Real Xmax = 0.5 * Standard_Real(anAspect->PlaneXLength());
|
||||
const Standard_Real Ymax = 0.5 * Standard_Real(anAspect->PlaneYLength());
|
||||
|
||||
Handle(Graphic3d_ArrayOfQuadrangles) aQuads = new Graphic3d_ArrayOfQuadrangles(4);
|
||||
|
||||
myComponent->D0(-Xmax,Ymax,p1);
|
||||
myComponent->D0(-Xmax, Ymax, p1);
|
||||
aQuads->AddVertex(p1);
|
||||
myComponent->D0(Xmax,Ymax,p1);
|
||||
myComponent->D0(Xmax, Ymax, p1);
|
||||
aQuads->AddVertex(p1);
|
||||
myComponent->D0(Xmax,-Ymax,p1);
|
||||
myComponent->D0(Xmax, -Ymax, p1);
|
||||
aQuads->AddVertex(p1);
|
||||
myComponent->D0(-Xmax,-Ymax,p1);
|
||||
myComponent->D0(-Xmax, -Ymax, p1);
|
||||
aQuads->AddVertex(p1);
|
||||
|
||||
aGroup->AddPrimitiveArray (aQuads);
|
||||
aGroup->AddPrimitiveArray(aQuads);
|
||||
}
|
||||
else
|
||||
{
|
||||
DsgPrs_ShadedPlanePresentation::Add (thePrs, myDrawer, myCenter, myPmin, myPmax);
|
||||
DsgPrs_ShadedPlanePresentation::Add(thePrs, myDrawer, myCenter, myPmin, myPmax);
|
||||
}
|
||||
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();
|
||||
Handle(SelectMgr_EntityOwner) aSensitiveOwner = new SelectMgr_EntityOwner (this, 10);
|
||||
Handle(Poly_Triangulation) aSensitivePoly;
|
||||
Handle(SelectMgr_EntityOwner) aSensitiveOwner = new SelectMgr_EntityOwner(this, 10);
|
||||
Handle(Poly_Triangulation) aSensitivePoly;
|
||||
|
||||
if (!myIsXYZPlane)
|
||||
{
|
||||
// plane representing rectangle
|
||||
Standard_Real aLengthX = myDrawer->PlaneAspect()->PlaneXLength() / 2.0;
|
||||
Standard_Real aLengthY = myDrawer->PlaneAspect()->PlaneYLength() / 2.0;
|
||||
Handle(Geom_Plane) aPlane =
|
||||
Handle(Geom_Plane)::DownCast (myComponent->Translated (myComponent->Location(), myCenter));
|
||||
Standard_Real aLengthX = myDrawer->PlaneAspect()->PlaneXLength() / 2.0;
|
||||
Standard_Real aLengthY = myDrawer->PlaneAspect()->PlaneYLength() / 2.0;
|
||||
Handle(Geom_Plane) aPlane =
|
||||
Handle(Geom_Plane)::DownCast(myComponent->Translated(myComponent->Location(), myCenter));
|
||||
|
||||
TColgp_Array1OfPnt aRectanglePoints (1, 4);
|
||||
aPlane->D0 ( aLengthX, aLengthY, aRectanglePoints.ChangeValue (1));
|
||||
aPlane->D0 ( aLengthX, -aLengthY, aRectanglePoints.ChangeValue (2));
|
||||
aPlane->D0 (-aLengthX, -aLengthY, aRectanglePoints.ChangeValue (3));
|
||||
aPlane->D0 (-aLengthX, aLengthY, aRectanglePoints.ChangeValue (4));
|
||||
TColgp_Array1OfPnt aRectanglePoints(1, 4);
|
||||
aPlane->D0(aLengthX, aLengthY, aRectanglePoints.ChangeValue(1));
|
||||
aPlane->D0(aLengthX, -aLengthY, aRectanglePoints.ChangeValue(2));
|
||||
aPlane->D0(-aLengthX, -aLengthY, aRectanglePoints.ChangeValue(3));
|
||||
aPlane->D0(-aLengthX, aLengthY, aRectanglePoints.ChangeValue(4));
|
||||
|
||||
Poly_Array1OfTriangle aTriangles (1, 2);
|
||||
aTriangles.ChangeValue (1) = Poly_Triangle (1, 2, 3);
|
||||
aTriangles.ChangeValue (2) = Poly_Triangle (1, 3, 4);
|
||||
Poly_Array1OfTriangle aTriangles(1, 2);
|
||||
aTriangles.ChangeValue(1) = Poly_Triangle(1, 2, 3);
|
||||
aTriangles.ChangeValue(2) = Poly_Triangle(1, 3, 4);
|
||||
|
||||
aSensitivePoly = new Poly_Triangulation (aRectanglePoints, aTriangles);
|
||||
aSensitivePoly = new Poly_Triangulation(aRectanglePoints, aTriangles);
|
||||
}
|
||||
else
|
||||
{
|
||||
// plane representing triangle
|
||||
TColgp_Array1OfPnt aTrianglePoints (1, 3);
|
||||
aTrianglePoints.ChangeValue (1) = myCenter;
|
||||
aTrianglePoints.ChangeValue (2) = myPmin;
|
||||
aTrianglePoints.ChangeValue (3) = myPmax;
|
||||
TColgp_Array1OfPnt aTrianglePoints(1, 3);
|
||||
aTrianglePoints.ChangeValue(1) = myCenter;
|
||||
aTrianglePoints.ChangeValue(2) = myPmin;
|
||||
aTrianglePoints.ChangeValue(3) = myPmax;
|
||||
|
||||
Poly_Array1OfTriangle aTriangles (1, 1);
|
||||
aTriangles.ChangeValue (1) = Poly_Triangle(1, 2, 3);
|
||||
Poly_Array1OfTriangle aTriangles(1, 1);
|
||||
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;
|
||||
|
||||
Handle(Select3D_SensitiveTriangulation) aSensitive =
|
||||
new Select3D_SensitiveTriangulation (aSensitiveOwner,
|
||||
aSensitivePoly,
|
||||
TopLoc_Location(),
|
||||
isSensitiveInterior);
|
||||
new Select3D_SensitiveTriangulation(aSensitiveOwner,
|
||||
aSensitivePoly,
|
||||
TopLoc_Location(),
|
||||
isSensitiveInterior);
|
||||
|
||||
theSelection->Add(aSensitive);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetSize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::SetSize(const Standard_Real aLength)
|
||||
{
|
||||
SetSize(aLength,aLength);
|
||||
SetSize(aLength, aLength);
|
||||
}
|
||||
|
||||
void AIS_Plane::SetSize(const Standard_Real aXLength,
|
||||
const Standard_Real aYLength)
|
||||
void AIS_Plane::SetSize(const Standard_Real aXLength, const Standard_Real aYLength)
|
||||
{
|
||||
//if the plane already has a proper color or size,
|
||||
//there is already a specific PlaneAspect and DatumAspect
|
||||
|
||||
Handle(Prs3d_PlaneAspect) PA;
|
||||
// if the plane already has a proper color or size,
|
||||
// there is already a specific PlaneAspect and DatumAspect
|
||||
|
||||
Handle(Prs3d_PlaneAspect) PA;
|
||||
Handle(Prs3d_DatumAspect) DA;
|
||||
|
||||
PA = myDrawer->PlaneAspect();
|
||||
DA = myDrawer->DatumAspect();
|
||||
|
||||
Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True);
|
||||
if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
|
||||
Standard_Boolean yenavaitPA(Standard_True), yenavaitDA(Standard_True);
|
||||
if (myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA)
|
||||
{
|
||||
yenavaitPA = Standard_False;
|
||||
PA = new Prs3d_PlaneAspect();}
|
||||
if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
|
||||
yenavaitDA = Standard_False;
|
||||
DA = new Prs3d_DatumAspect();
|
||||
PA = new Prs3d_PlaneAspect();
|
||||
}
|
||||
|
||||
PA->SetPlaneLength(aXLength,aYLength);
|
||||
DA->SetAxisLength(aXLength,aYLength,aXLength);
|
||||
|
||||
if(!yenavaitPA)
|
||||
if (myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA)
|
||||
{
|
||||
yenavaitDA = Standard_False;
|
||||
DA = new Prs3d_DatumAspect();
|
||||
}
|
||||
|
||||
PA->SetPlaneLength(aXLength, aYLength);
|
||||
DA->SetAxisLength(aXLength, aYLength, aXLength);
|
||||
|
||||
if (!yenavaitPA)
|
||||
myDrawer->SetPlaneAspect(PA);
|
||||
if(!yenavaitDA)
|
||||
if (!yenavaitDA)
|
||||
myDrawer->SetDatumAspect(DA);
|
||||
|
||||
|
||||
|
||||
myHasOwnSize = Standard_True;
|
||||
SetToUpdate();
|
||||
UpdatePresentations();
|
||||
UpdateSelection();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetSize
|
||||
//purpose : If there is a color, the size is restaured from the drawer of the context...
|
||||
// function : UnsetSize
|
||||
// purpose : If there is a color, the size is restaured from the drawer of the context...
|
||||
//=======================================================================
|
||||
void AIS_Plane::UnsetSize()
|
||||
{
|
||||
|
||||
if(!myHasOwnSize) return;
|
||||
if(!hasOwnColor)
|
||||
{
|
||||
myDrawer->SetPlaneAspect (Handle(Prs3d_PlaneAspect)());
|
||||
myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
|
||||
}
|
||||
else{
|
||||
const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
|
||||
new Prs3d_PlaneAspect();
|
||||
const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() :
|
||||
new Prs3d_DatumAspect();
|
||||
|
||||
myDrawer->PlaneAspect()->SetPlaneLength(PA->PlaneXLength(),PA->PlaneYLength());
|
||||
myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis),
|
||||
DA->AxisLength(Prs3d_DatumParts_YAxis),
|
||||
DA->AxisLength(Prs3d_DatumParts_ZAxis));
|
||||
if (!myHasOwnSize)
|
||||
return;
|
||||
if (!hasOwnColor)
|
||||
{
|
||||
myDrawer->SetPlaneAspect(Handle(Prs3d_PlaneAspect)());
|
||||
myDrawer->SetDatumAspect(Handle(Prs3d_DatumAspect)());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
const Handle(Prs3d_PlaneAspect) PA =
|
||||
myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() : new Prs3d_PlaneAspect();
|
||||
const Handle(Prs3d_DatumAspect) DA =
|
||||
myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() : new Prs3d_DatumAspect();
|
||||
|
||||
myDrawer->PlaneAspect()->SetPlaneLength(PA->PlaneXLength(), PA->PlaneYLength());
|
||||
myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis),
|
||||
DA->AxisLength(Prs3d_DatumParts_YAxis),
|
||||
DA->AxisLength(Prs3d_DatumParts_ZAxis));
|
||||
}
|
||||
|
||||
myHasOwnSize = Standard_False;
|
||||
SetToUpdate();
|
||||
UpdatePresentations();
|
||||
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();
|
||||
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)
|
||||
{
|
||||
@ -422,183 +395,189 @@ void AIS_Plane::SetMinimumSize (const Standard_Real theValue)
|
||||
return;
|
||||
}
|
||||
Standard_Real aX, anY;
|
||||
Size (aX, anY);
|
||||
SetTransformPersistence (new Graphic3d_TransformPersScaledAbove (Min (aX, anY) / theValue, myCenter));
|
||||
Size(aX, anY);
|
||||
SetTransformPersistence(
|
||||
new Graphic3d_TransformPersScaledAbove(Min(aX, anY) / theValue, myCenter));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetMinimumSize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::UnsetMinimumSize()
|
||||
{
|
||||
SetTransformPersistence (NULL);
|
||||
SetTransformPersistence(NULL);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasMinimumSize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
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
|
||||
// Standard_Boolean yenadeja = hasOwnColor || myHasOwnSize;
|
||||
Handle(Prs3d_PlaneAspect) PA;
|
||||
// if the plane already has its proper size, there is an already created planeaspect
|
||||
// Standard_Boolean yenadeja = hasOwnColor || myHasOwnSize;
|
||||
Handle(Prs3d_PlaneAspect) PA;
|
||||
Handle(Prs3d_DatumAspect) DA;
|
||||
|
||||
PA = myDrawer->PlaneAspect();
|
||||
DA = myDrawer->DatumAspect();
|
||||
|
||||
Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True);
|
||||
if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
|
||||
Standard_Boolean yenavaitPA(Standard_True), yenavaitDA(Standard_True);
|
||||
if (myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA)
|
||||
{
|
||||
yenavaitPA = Standard_False;
|
||||
PA = new Prs3d_PlaneAspect();}
|
||||
if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
|
||||
yenavaitDA = Standard_False;
|
||||
DA = new Prs3d_DatumAspect();
|
||||
PA = new Prs3d_PlaneAspect();
|
||||
}
|
||||
|
||||
if (myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA)
|
||||
{
|
||||
yenavaitDA = Standard_False;
|
||||
DA = new Prs3d_DatumAspect();
|
||||
}
|
||||
|
||||
PA->EdgesAspect()->SetColor(aCol);
|
||||
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol);
|
||||
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
|
||||
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(aCol);
|
||||
|
||||
if(!yenavaitPA)
|
||||
if (!yenavaitPA)
|
||||
myDrawer->SetPlaneAspect(PA);
|
||||
if(!yenavaitDA)
|
||||
if (!yenavaitDA)
|
||||
myDrawer->SetDatumAspect(DA);
|
||||
|
||||
myDrawer->ShadingAspect()->SetColor(aCol);
|
||||
|
||||
hasOwnColor=Standard_True;
|
||||
myDrawer->SetColor (aCol);
|
||||
|
||||
hasOwnColor = Standard_True;
|
||||
myDrawer->SetColor(aCol);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::UnsetColor()
|
||||
{
|
||||
if(!hasOwnColor) return;
|
||||
if(!myHasOwnSize)
|
||||
if (!hasOwnColor)
|
||||
return;
|
||||
if (!myHasOwnSize)
|
||||
{
|
||||
myDrawer->SetPlaneAspect (Handle(Prs3d_PlaneAspect)());
|
||||
myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
|
||||
myDrawer->SetPlaneAspect(Handle(Prs3d_PlaneAspect)());
|
||||
myDrawer->SetDatumAspect(Handle(Prs3d_DatumAspect)());
|
||||
}
|
||||
else{
|
||||
const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
|
||||
new Prs3d_PlaneAspect();
|
||||
else
|
||||
{
|
||||
const Handle(Prs3d_PlaneAspect) PA =
|
||||
myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() : new Prs3d_PlaneAspect();
|
||||
Quantity_Color Col = PA->EdgesAspect()->Aspect()->Color();
|
||||
myDrawer->PlaneAspect()->EdgesAspect()->SetColor(Col);
|
||||
|
||||
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(Col);
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(Col);
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Col);
|
||||
}
|
||||
|
||||
|
||||
hasOwnColor=Standard_False;
|
||||
|
||||
hasOwnColor = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeFrame
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::ComputeFrame()
|
||||
{
|
||||
|
||||
const Handle(Geom_Plane)& pl = myComponent;
|
||||
Standard_Real U,V;
|
||||
Standard_Real U, V;
|
||||
|
||||
if (myAutomaticPosition) {
|
||||
ElSLib::Parameters(pl->Pln(),myCenter,U,V);
|
||||
pl->D0 (U, V, myCenter);
|
||||
if (myAutomaticPosition)
|
||||
{
|
||||
ElSLib::Parameters(pl->Pln(), myCenter, U, V);
|
||||
pl->D0(U, V, myCenter);
|
||||
}
|
||||
else {
|
||||
Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
|
||||
ElSLib::Parameters(thegoodpl->Pln(),myPmin,U,V);
|
||||
|
||||
U = 2.4*Abs(U);
|
||||
V = 2.4*Abs(V);
|
||||
if (U < 10*Precision::Confusion()) U=0.1;
|
||||
if (V < 10*Precision::Confusion()) V=0.1;
|
||||
SetSize(U,V);
|
||||
myDrawer->PlaneAspect()->SetPlaneLength(U,V);
|
||||
else
|
||||
{
|
||||
Handle(Geom_Plane) thegoodpl(
|
||||
Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(), myCenter)));
|
||||
ElSLib::Parameters(thegoodpl->Pln(), myPmin, U, V);
|
||||
|
||||
U = 2.4 * Abs(U);
|
||||
V = 2.4 * Abs(V);
|
||||
if (U < 10 * Precision::Confusion())
|
||||
U = 0.1;
|
||||
if (V < 10 * Precision::Confusion())
|
||||
V = 0.1;
|
||||
SetSize(U, V);
|
||||
myDrawer->PlaneAspect()->SetPlaneLength(U, V);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeFields
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::ComputeFields()
|
||||
{
|
||||
if (myIsXYZPlane){
|
||||
Handle (Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
|
||||
if (myIsXYZPlane)
|
||||
{
|
||||
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
|
||||
|
||||
gp_Pnt Orig = myAx2->Ax2().Location();
|
||||
gp_Dir oX = myAx2->Ax2().XDirection();
|
||||
gp_Dir oY = myAx2->Ax2().YDirection();
|
||||
gp_Dir oZ = myAx2->Ax2().Direction();
|
||||
myCenter = Orig;
|
||||
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;
|
||||
Orig.Coord(xo,yo,zo);
|
||||
oX.Coord(x1,y1,z1);
|
||||
oY.Coord(x2,y2,z2);
|
||||
oZ.Coord(x3,y3,z3);
|
||||
gp_Dir oX = myAx2->Ax2().XDirection();
|
||||
gp_Dir oY = myAx2->Ax2().YDirection();
|
||||
gp_Dir oZ = myAx2->Ax2().Direction();
|
||||
myCenter = Orig;
|
||||
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;
|
||||
Orig.Coord(xo, yo, zo);
|
||||
oX.Coord(x1, y1, z1);
|
||||
oY.Coord(x2, y2, z2);
|
||||
oZ.Coord(x3, y3, z3);
|
||||
Standard_Real DS1 = DA->AxisLength(Prs3d_DatumParts_XAxis);
|
||||
Standard_Real DS2 = DA->AxisLength(Prs3d_DatumParts_YAxis);
|
||||
Standard_Real DS3 = DA->AxisLength(Prs3d_DatumParts_ZAxis);
|
||||
// gp_Pnt aPt2,aPt3;
|
||||
// gp_Pnt aPt2,aPt3;
|
||||
|
||||
switch (myTypeOfPlane) {
|
||||
case AIS_TOPL_XYPlane:
|
||||
{
|
||||
gp_Pln XYP(0,0,1,0);
|
||||
myComponent = new Geom_Plane(XYP);
|
||||
x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1;
|
||||
x5=xo+x2*DS2; y5=yo+y2*DS2; z5=zo+z2*DS2;
|
||||
break;
|
||||
switch (myTypeOfPlane)
|
||||
{
|
||||
case AIS_TOPL_XYPlane: {
|
||||
gp_Pln XYP(0, 0, 1, 0);
|
||||
myComponent = new Geom_Plane(XYP);
|
||||
x4 = xo + x1 * DS1;
|
||||
y4 = yo + y1 * DS1;
|
||||
z4 = zo + z1 * DS1;
|
||||
x5 = xo + x2 * DS2;
|
||||
y5 = yo + y2 * DS2;
|
||||
z5 = zo + z2 * DS2;
|
||||
break;
|
||||
}
|
||||
case AIS_TOPL_XZPlane:
|
||||
{
|
||||
gp_Pln XZP(0,1,0,0);
|
||||
myComponent = new Geom_Plane(XZP);
|
||||
x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1;
|
||||
x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3;
|
||||
break;
|
||||
case AIS_TOPL_XZPlane: {
|
||||
gp_Pln XZP(0, 1, 0, 0);
|
||||
myComponent = new Geom_Plane(XZP);
|
||||
x4 = xo + x1 * DS1;
|
||||
y4 = yo + y1 * DS1;
|
||||
z4 = zo + z1 * DS1;
|
||||
x5 = xo + x3 * DS3;
|
||||
y5 = yo + y3 * DS3;
|
||||
z5 = zo + z3 * DS3;
|
||||
break;
|
||||
}
|
||||
case AIS_TOPL_YZPlane:
|
||||
{
|
||||
gp_Pln XZP(1,0,0,0);
|
||||
myComponent = new Geom_Plane(XZP);
|
||||
x4=xo+x2*DS2; y4=yo+y2*DS2; z4=zo+z2*DS2;
|
||||
x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3;
|
||||
break;
|
||||
case AIS_TOPL_YZPlane: {
|
||||
gp_Pln XZP(1, 0, 0, 0);
|
||||
myComponent = new Geom_Plane(XZP);
|
||||
x4 = xo + x2 * DS2;
|
||||
y4 = yo + y2 * DS2;
|
||||
z4 = zo + z2 * DS2;
|
||||
x5 = xo + x3 * DS3;
|
||||
y5 = yo + y3 * DS3;
|
||||
z5 = zo + z3 * DS3;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
myPmin.SetCoord(x4,y4,z4);
|
||||
myPmax.SetCoord(x5,y5,z5);
|
||||
myPmin.SetCoord(x4, y4, z4);
|
||||
myPmax.SetCoord(x5, y5, z5);
|
||||
}
|
||||
|
||||
}
|
||||
//=======================================================================
|
||||
//function : InitDrawerAttributes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::InitDrawerAttributes()
|
||||
{
|
||||
@ -607,30 +586,23 @@ void AIS_Plane::InitDrawerAttributes()
|
||||
shasp->SetColor(Quantity_NOC_GRAY40);
|
||||
myDrawer->SetShadingAspect(shasp);
|
||||
Handle(Graphic3d_AspectFillArea3d) asf = shasp->Aspect();
|
||||
Graphic3d_MaterialAspect asp = asf->FrontMaterial();
|
||||
asp.SetTransparency (0.8f);
|
||||
Graphic3d_MaterialAspect asp = asf->FrontMaterial();
|
||||
asp.SetTransparency(0.8f);
|
||||
asf->SetFrontMaterial(asp);
|
||||
asf->SetBackMaterial(asp);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AcceptDisplayMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_Plane::
|
||||
AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
{return aMode == 0;}
|
||||
Standard_Boolean AIS_Plane::AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
{
|
||||
return aMode == 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetContext
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Plane::SetContext(const Handle(AIS_InteractiveContext)& Ctx)
|
||||
{
|
||||
AIS_InteractiveObject::SetContext(Ctx);
|
||||
ComputeFields();
|
||||
|
||||
}
|
||||
|
@ -31,42 +31,50 @@ class AIS_Plane : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Plane, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! initializes the plane aComponent. If
|
||||
//! the mode aCurrentMode equals true, the drawing
|
||||
//! tool, "Drawer" is not initialized.
|
||||
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent, const Standard_Boolean aCurrentMode = Standard_False);
|
||||
|
||||
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent,
|
||||
const Standard_Boolean aCurrentMode = Standard_False);
|
||||
|
||||
//! initializes the plane aComponent and
|
||||
//! the point aCenter. If the mode aCurrentMode
|
||||
//! equals true, the drawing tool, "Drawer" is not
|
||||
//! initialized. aCurrentMode equals true, the drawing
|
||||
//! tool, "Drawer" is not initialized.
|
||||
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent, const gp_Pnt& aCenter, const Standard_Boolean aCurrentMode = Standard_False);
|
||||
|
||||
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent,
|
||||
const gp_Pnt& aCenter,
|
||||
const Standard_Boolean aCurrentMode = Standard_False);
|
||||
|
||||
//! initializes the plane aComponent, the
|
||||
//! point aCenter, and the minimum and maximum
|
||||
//! points, aPmin and aPmax. If the mode
|
||||
//! aCurrentMode equals true, the drawing tool, "Drawer" is not initialized.
|
||||
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent, const gp_Pnt& aCenter, const gp_Pnt& aPmin, const gp_Pnt& aPmax, const Standard_Boolean aCurrentMode = Standard_False);
|
||||
|
||||
Standard_EXPORT AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfPlane aPlaneType, 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);
|
||||
|
||||
//! 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
|
||||
//! 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 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; }
|
||||
|
||||
//! 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
|
||||
Standard_EXPORT void UnsetMinimumSize();
|
||||
@ -76,29 +84,38 @@ public:
|
||||
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 7; }
|
||||
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
//! Returns the component specified in SetComponent.
|
||||
const Handle(Geom_Plane)& Component() { return myComponent; }
|
||||
|
||||
//! 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
|
||||
//! aComponent, provided in SetPlaneAttributes.
|
||||
//! These include the points aCenter, aPmin, and aPmax
|
||||
Standard_EXPORT Standard_Boolean PlaneAttributes (Handle(Geom_Plane)& aComponent, gp_Pnt& aCenter, gp_Pnt& aPmin, gp_Pnt& aPmax);
|
||||
|
||||
Standard_EXPORT Standard_Boolean PlaneAttributes(Handle(Geom_Plane)& aComponent,
|
||||
gp_Pnt& aCenter,
|
||||
gp_Pnt& aPmin,
|
||||
gp_Pnt& aPmax);
|
||||
|
||||
//! Allows you to provide settings other than default ones
|
||||
//! for the selected plane. These include: center point
|
||||
//! aCenter, maximum aPmax and minimum aPmin.
|
||||
Standard_EXPORT void SetPlaneAttributes (const Handle(Geom_Plane)& aComponent, const gp_Pnt& aCenter, const gp_Pnt& aPmin, const gp_Pnt& aPmax);
|
||||
Standard_EXPORT void SetPlaneAttributes(const Handle(Geom_Plane)& aComponent,
|
||||
const gp_Pnt& aCenter,
|
||||
const gp_Pnt& aPmin,
|
||||
const gp_Pnt& aPmax);
|
||||
|
||||
//! Returns the coordinates of the center point.
|
||||
const gp_Pnt& Center() const { return myCenter; }
|
||||
|
||||
//! 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
|
||||
//! direction of one of the plane's axes, aComponent, in
|
||||
@ -108,13 +125,14 @@ public:
|
||||
//! - AIS_ TOPL_XYPlane
|
||||
//! - AIS_ TOPL_XZPlane
|
||||
//! - AIS_ TOPL_YZPlane}.
|
||||
Standard_EXPORT void SetAxis2Placement (const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfPlane aPlaneType);
|
||||
|
||||
Standard_EXPORT void SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
|
||||
const AIS_TypeOfPlane aPlaneType);
|
||||
|
||||
//! Returns the position of the plane's axis2 system
|
||||
//! identifying the x, y, or z axis and giving the plane a
|
||||
//! direction in 3D space. An axis2 system is a right-handed coordinate system.
|
||||
Standard_EXPORT Handle(Geom_Axis2Placement) Axis2Placement();
|
||||
|
||||
|
||||
//! Returns the type of plane - xy, yz, xz or unknown.
|
||||
AIS_TypeOfPlane TypeOfPlane() { return myTypeOfPlane; }
|
||||
|
||||
@ -126,31 +144,36 @@ public:
|
||||
|
||||
//! Allows you to provide settings for a non-default
|
||||
//! 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.
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! connection to <aCtx> default drawer implies a recomputation of Frame values.
|
||||
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& aCtx)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Returns the type of sensitivity for the plane;
|
||||
Select3D_TypeOfSensitivity TypeOfSensitivity() const { return myTypeOfSensitivity; }
|
||||
|
||||
//! Sets the type of sensitivity for the plane.
|
||||
void SetTypeOfSensitivity (Select3D_TypeOfSensitivity theTypeOfSensitivity) { myTypeOfSensitivity = theTypeOfSensitivity; }
|
||||
void SetTypeOfSensitivity(Select3D_TypeOfSensitivity theTypeOfSensitivity)
|
||||
{
|
||||
myTypeOfSensitivity = theTypeOfSensitivity;
|
||||
}
|
||||
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE;
|
||||
Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void ComputeFrame();
|
||||
|
||||
@ -159,19 +182,17 @@ private:
|
||||
Standard_EXPORT void InitDrawerAttributes();
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Plane) myComponent;
|
||||
Handle(Geom_Plane) myComponent;
|
||||
Handle(Geom_Axis2Placement) myAx2;
|
||||
gp_Pnt myCenter;
|
||||
gp_Pnt myPmin;
|
||||
gp_Pnt myPmax;
|
||||
Standard_Boolean myCurrentMode;
|
||||
Standard_Boolean myAutomaticPosition;
|
||||
AIS_TypeOfPlane myTypeOfPlane;
|
||||
Standard_Boolean myIsXYZPlane;
|
||||
Standard_Boolean myHasOwnSize;
|
||||
Select3D_TypeOfSensitivity myTypeOfSensitivity;
|
||||
|
||||
gp_Pnt myCenter;
|
||||
gp_Pnt myPmin;
|
||||
gp_Pnt myPmax;
|
||||
Standard_Boolean myCurrentMode;
|
||||
Standard_Boolean myAutomaticPosition;
|
||||
AIS_TypeOfPlane myTypeOfPlane;
|
||||
Standard_Boolean myIsXYZPlane;
|
||||
Standard_Boolean myHasOwnSize;
|
||||
Select3D_TypeOfSensitivity myTypeOfSensitivity;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_Plane, AIS_InteractiveObject)
|
||||
|
@ -15,7 +15,7 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// + X/YAxis() returns AIS_Line instead of AIS_Axis
|
||||
// + (-1) selection mode token into account
|
||||
// + (-1) selection mode token into account
|
||||
// (SAMTECH specific)
|
||||
|
||||
#include <AIS_Line.hxx>
|
||||
@ -45,22 +45,22 @@
|
||||
#include <TCollection_AsciiString.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)
|
||||
:myPlane(aPlane)
|
||||
: myPlane(aPlane)
|
||||
{
|
||||
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
|
||||
//POP Standard_Real aLength = UnitsAPI::CurrentFromLS (100. ,"LENGTH");
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS (100. ,"mm");
|
||||
DA->SetAxisLength(aLength,aLength,aLength);
|
||||
Quantity_Color col (Quantity_NOC_ROYALBLUE1);
|
||||
Handle(Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
|
||||
// POP Standard_Real aLength = UnitsAPI::CurrentFromLS (100. ,"LENGTH");
|
||||
Standard_Real aLength = UnitsAPI::AnyToLS(100., "mm");
|
||||
DA->SetAxisLength(aLength, aLength, aLength);
|
||||
Quantity_Color col(Quantity_NOC_ROYALBLUE1);
|
||||
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
|
||||
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
|
||||
DA->SetDrawDatumAxes(Prs3d_DatumAxes_XYAxes);
|
||||
@ -69,165 +69,154 @@ AIS_PlaneTrihedron::AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane)
|
||||
myShapes[1] = XAxis();
|
||||
myShapes[2] = YAxis();
|
||||
|
||||
myXLabel = TCollection_AsciiString( "X" );
|
||||
myYLabel = TCollection_AsciiString( "Y" );
|
||||
myXLabel = TCollection_AsciiString("X");
|
||||
myYLabel = TCollection_AsciiString("Y");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Component
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Geom_Plane) AIS_PlaneTrihedron::Component()
|
||||
Handle(Geom_Plane) AIS_PlaneTrihedron::Component()
|
||||
{
|
||||
return myPlane;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : SetComponent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_PlaneTrihedron::SetComponent(const Handle(Geom_Plane)& aPlane)
|
||||
void AIS_PlaneTrihedron::SetComponent(const Handle(Geom_Plane)& aPlane)
|
||||
{
|
||||
myPlane = aPlane;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//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(AIS_Line) aLine = new AIS_Line (aGLine);
|
||||
Handle(AIS_Line) aLine = new AIS_Line(aGLine);
|
||||
aLine->SetColor(Quantity_NOC_ROYALBLUE1);
|
||||
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(AIS_Line) aLine = new AIS_Line (aGLine);
|
||||
Handle(AIS_Line) aLine = new AIS_Line(aGLine);
|
||||
aLine->SetColor(Quantity_NOC_ROYALBLUE1);
|
||||
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(AIS_Point) aPt = new AIS_Point (aPoint);
|
||||
Handle(AIS_Point) aPt = new AIS_Point(aPoint);
|
||||
return aPt;
|
||||
}
|
||||
|
||||
void AIS_PlaneTrihedron::SetLength(const Standard_Real theLength) {
|
||||
void AIS_PlaneTrihedron::SetLength(const Standard_Real theLength)
|
||||
{
|
||||
myDrawer->DatumAspect()->SetAxisLength(theLength, theLength, theLength);
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
Standard_Real AIS_PlaneTrihedron::GetLength() const {
|
||||
Standard_Real AIS_PlaneTrihedron::GetLength() const
|
||||
{
|
||||
return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PlaneTrihedron::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer )
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PlaneTrihedron::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer)
|
||||
{
|
||||
// drawing axis in X direction
|
||||
gp_Pnt first, last;
|
||||
gp_Pnt first, last;
|
||||
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();
|
||||
Standard_Real xo, yo, zo, x, y, z;
|
||||
orig.Coord(xo, yo, zo);
|
||||
xDir.Coord(x, y, z);
|
||||
first.SetCoord(xo, yo, zo);
|
||||
last.SetCoord(xo + x * value, yo + y * value, zo + z * value);
|
||||
|
||||
DsgPrs_XYZAxisPresentation::Add(thePrs,
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
|
||||
myDrawer->ArrowAspect(),
|
||||
myDrawer->TextAspect(),
|
||||
xDir,
|
||||
value,
|
||||
myXLabel.ToCString(),
|
||||
first,
|
||||
last);
|
||||
|
||||
gp_Pnt orig = myPlane->Position().Ax2().Location();
|
||||
Standard_Real xo,yo,zo,x,y,z;
|
||||
orig.Coord( xo, yo, zo );
|
||||
xDir.Coord( x, y, z );
|
||||
first.SetCoord( xo, yo, zo );
|
||||
last.SetCoord( xo + x * value, yo + y * value, zo + z * value );
|
||||
|
||||
DsgPrs_XYZAxisPresentation::Add (thePrs,
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
|
||||
myDrawer->ArrowAspect(),
|
||||
myDrawer->TextAspect(),
|
||||
xDir, value, myXLabel.ToCString(), first, last);
|
||||
|
||||
// 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();
|
||||
|
||||
yDir.Coord( x, y, z );
|
||||
last.SetCoord( xo + x * value, yo + y * value, zo + z * value );
|
||||
DsgPrs_XYZAxisPresentation::Add (thePrs,
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
|
||||
myDrawer->ArrowAspect(),
|
||||
myDrawer->TextAspect(),
|
||||
yDir, value, myYLabel.ToCString(), first, last);
|
||||
yDir.Coord(x, y, z);
|
||||
last.SetCoord(xo + x * value, yo + y * value, zo + z * value);
|
||||
DsgPrs_XYZAxisPresentation::Add(thePrs,
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
|
||||
myDrawer->ArrowAspect(),
|
||||
myDrawer->TextAspect(),
|
||||
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,
|
||||
const Standard_Integer aMode)
|
||||
const Standard_Integer aMode)
|
||||
{
|
||||
Standard_Integer Prior;
|
||||
Standard_Integer Prior;
|
||||
Handle(SelectMgr_EntityOwner) eown;
|
||||
TColgp_Array1OfPnt PP(1,4),PO(1,4);
|
||||
// ExtremityPoints(PP);
|
||||
ExtremityPoints(PP,myPlane,myDrawer);
|
||||
switch (aMode) {
|
||||
case 0:
|
||||
{ // triedre complet
|
||||
TColgp_Array1OfPnt PP(1, 4), PO(1, 4);
|
||||
// ExtremityPoints(PP);
|
||||
ExtremityPoints(PP, myPlane, myDrawer);
|
||||
switch (aMode)
|
||||
{
|
||||
case 0: { // triedre complet
|
||||
Prior = 5;
|
||||
// gp_Ax2 theax = gp_Ax2(myPlane->Position().Ax2());
|
||||
// gp_Pnt p1 = theax.Location();
|
||||
|
||||
eown = new SelectMgr_EntityOwner(this,Prior);
|
||||
for (Standard_Integer i=1; i<=2;i++)
|
||||
aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
|
||||
|
||||
// gp_Ax2 theax = gp_Ax2(myPlane->Position().Ax2());
|
||||
// gp_Pnt p1 = theax.Location();
|
||||
|
||||
eown = new SelectMgr_EntityOwner(this, Prior);
|
||||
for (Standard_Integer i = 1; i <= 2; i++)
|
||||
aSelection->Add(new Select3D_SensitiveSegment(eown, PP(1), PP(i + 1)));
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{ //origine
|
||||
Prior = 8;
|
||||
case 1: { // origine
|
||||
Prior = 8;
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj,Prior);
|
||||
aSelection->Add(new Select3D_SensitivePoint(eown,myPlane->Location()));
|
||||
eown = new SelectMgr_EntityOwner(anObj, Prior);
|
||||
aSelection->Add(new Select3D_SensitivePoint(eown, myPlane->Location()));
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{ //axes ... priorite 7
|
||||
case 2: { // axes ... priorite 7
|
||||
Prior = 7;
|
||||
for (Standard_Integer i=1; i<=2;i++){
|
||||
for (Standard_Integer i = 1; i <= 2; i++)
|
||||
{
|
||||
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity
|
||||
eown= new SelectMgr_EntityOwner(anObj,Prior);
|
||||
aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
|
||||
|
||||
eown = new SelectMgr_EntityOwner(anObj, Prior);
|
||||
aSelection->Add(new Select3D_SensitiveSegment(eown, PP(1), PP(i + 1)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case -1:
|
||||
{
|
||||
case -1: {
|
||||
Prior = 5;
|
||||
aSelection->Clear();
|
||||
break;
|
||||
@ -235,42 +224,42 @@ 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;
|
||||
myDrawer->SetColor (aCol);
|
||||
hasOwnColor = Standard_True;
|
||||
myDrawer->SetColor(aCol);
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol);
|
||||
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ExtremityPoints
|
||||
//purpose : to avoid warning
|
||||
// function : ExtremityPoints
|
||||
// purpose : to avoid warning
|
||||
//=======================================================================
|
||||
//void AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const
|
||||
void ExtremityPoints(TColgp_Array1OfPnt& PP,const Handle(Geom_Plane)& myPlane,const Handle(Prs3d_Drawer)& myDrawer )
|
||||
// void AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const
|
||||
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());
|
||||
PP(1) = theax.Location();
|
||||
|
||||
Standard_Real len = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
|
||||
gp_Vec vec = theax.XDirection();
|
||||
gp_Vec vec = theax.XDirection();
|
||||
vec *= len;
|
||||
PP(2) = PP(1).Translated(vec);
|
||||
|
||||
|
||||
len = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_YAxis);
|
||||
vec = theax.YDirection();
|
||||
vec *= len;
|
||||
PP(3) = PP(1).Translated(vec);
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AcceptDisplayMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_PlaneTrihedron::AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
{return aMode == 0;}
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_PlaneTrihedron::AcceptDisplayMode(const Standard_Integer aMode) const
|
||||
{
|
||||
return aMode == 0;
|
||||
}
|
||||
|
@ -45,65 +45,64 @@ class AIS_PlaneTrihedron : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_PlaneTrihedron, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes the plane aPlane. The plane trihedron is
|
||||
//! constructed from this and an axis.
|
||||
Standard_EXPORT AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane);
|
||||
|
||||
|
||||
//! Returns the component specified in SetComponent.
|
||||
Standard_EXPORT Handle(Geom_Plane) Component();
|
||||
|
||||
|
||||
//! 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".
|
||||
Standard_EXPORT Handle(AIS_Line) XAxis() const;
|
||||
|
||||
|
||||
//! Returns the "YAxis".
|
||||
Standard_EXPORT Handle(AIS_Line) YAxis() const;
|
||||
|
||||
|
||||
//! Returns the point of origin of the plane trihedron.
|
||||
Standard_EXPORT Handle(AIS_Point) Position() const;
|
||||
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT Standard_Real GetLength() const;
|
||||
|
||||
|
||||
//! Returns true if the display mode selected, aMode, is valid.
|
||||
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
Standard_EXPORT Standard_Boolean
|
||||
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 4; }
|
||||
|
||||
//! Returns datum as the type of Interactive Object.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
//! Allows you to provide settings for the color aColor.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
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:
|
||||
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Plane) myPlane;
|
||||
Handle(Geom_Plane) myPlane;
|
||||
Handle(AIS_InteractiveObject) myShapes[3];
|
||||
TCollection_AsciiString myXLabel;
|
||||
TCollection_AsciiString myYLabel;
|
||||
|
||||
TCollection_AsciiString myXLabel;
|
||||
TCollection_AsciiString myYLabel;
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_PlaneTrihedron, AIS_InteractiveObject)
|
||||
|
@ -30,190 +30,156 @@
|
||||
#include <StdPrs_Point.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),
|
||||
myHasTOM(Standard_False),
|
||||
myTOM(Aspect_TOM_PLUS)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent)
|
||||
: myComponent(aComponent),
|
||||
myHasTOM(Standard_False),
|
||||
myTOM(Aspect_TOM_PLUS)
|
||||
{
|
||||
myHilightDrawer = new Prs3d_Drawer();
|
||||
myHilightDrawer->SetDisplayMode (-99);
|
||||
myHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0));
|
||||
myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
|
||||
myHilightDrawer->SetZLayer (Graphic3d_ZLayerId_UNKNOWN);
|
||||
myHilightDrawer->SetDisplayMode(-99);
|
||||
myHilightDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0));
|
||||
myHilightDrawer->SetColor(Quantity_NOC_GRAY80);
|
||||
myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
|
||||
myDynHilightDrawer = new Prs3d_Drawer();
|
||||
myDynHilightDrawer->SetDisplayMode (-99);
|
||||
myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
|
||||
myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
|
||||
myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Top);
|
||||
myDynHilightDrawer->SetDisplayMode(-99);
|
||||
myDynHilightDrawer->SetPointAspect(
|
||||
new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
|
||||
myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1);
|
||||
myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Component
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Geom_Point) AIS_Point::Component()
|
||||
{
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetComponent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
|
||||
void AIS_Point::SetComponent(const Handle(Geom_Point)& 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 Standard_Integer theMode)
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
thePrs->SetInfiniteState (myInfiniteState);
|
||||
thePrs->SetInfiniteState(myInfiniteState);
|
||||
if (theMode == 0)
|
||||
{
|
||||
StdPrs_Point::Add (thePrs, myComponent, myDrawer);
|
||||
StdPrs_Point::Add(thePrs, myComponent, myDrawer);
|
||||
}
|
||||
else if (theMode == -99)
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
|
||||
aGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect());
|
||||
Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
|
||||
aPoint->AddVertex (myComponent->X(), myComponent->Y(), myComponent->Z());
|
||||
aGroup->AddPrimitiveArray (aPoint);
|
||||
aGroup->SetPrimitivesAspect(myHilightDrawer->PointAspect()->Aspect());
|
||||
Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints(1);
|
||||
aPoint->AddVertex(myComponent->X(), myComponent->Y(), myComponent->Z());
|
||||
aGroup->AddPrimitiveArray(aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
const Standard_Integer /*aMode*/)
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
|
||||
Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
|
||||
myComponent->Pnt());
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 10);
|
||||
Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown, myComponent->Pnt());
|
||||
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;
|
||||
myDrawer->SetColor (theCol);
|
||||
hasOwnColor = Standard_True;
|
||||
myDrawer->SetColor(theCol);
|
||||
UpdatePointValues();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::UnsetColor()
|
||||
{
|
||||
hasOwnColor=Standard_False;
|
||||
hasOwnColor = Standard_False;
|
||||
UpdatePointValues();
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopoDS_Vertex AIS_Point::Vertex() const
|
||||
{
|
||||
gp_Pnt P = myComponent->Pnt();
|
||||
return BRepBuilderAPI_MakeVertex(P);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMarker
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
|
||||
{
|
||||
myTOM = aTOM;
|
||||
myTOM = aTOM;
|
||||
myHasTOM = Standard_True;
|
||||
UpdatePointValues();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetMarker
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::UnsetMarker()
|
||||
{
|
||||
myHasTOM = Standard_False;
|
||||
UpdatePointValues();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AcceptDisplayMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_Point::AcceptDisplayMode (const Standard_Integer theMode) const
|
||||
Standard_Boolean AIS_Point::AcceptDisplayMode(const Standard_Integer theMode) const
|
||||
{
|
||||
return theMode == 0
|
||||
|| theMode == -99;
|
||||
return theMode == 0 || theMode == -99;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : replaceWithNewPointAspect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect)
|
||||
{
|
||||
if (!myDrawer->HasLink())
|
||||
{
|
||||
myDrawer->SetPointAspect (theAspect);
|
||||
myDrawer->SetPointAspect(theAspect);
|
||||
return;
|
||||
}
|
||||
|
||||
const Handle(Graphic3d_AspectMarker3d) anAspectOld = myDrawer->PointAspect()->Aspect();
|
||||
const Handle(Graphic3d_AspectMarker3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
|
||||
const Handle(Graphic3d_AspectMarker3d) anAspectNew =
|
||||
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
|
||||
if (anAspectNew != anAspectOld)
|
||||
{
|
||||
myDrawer->SetPointAspect (theAspect);
|
||||
myDrawer->SetPointAspect(theAspect);
|
||||
Graphic3d_MapOfAspectsToAspects aReplaceMap;
|
||||
aReplaceMap.Bind (anAspectOld, anAspectNew);
|
||||
replaceAspects (aReplaceMap);
|
||||
aReplaceMap.Bind(anAspectOld, anAspectNew);
|
||||
replaceAspects(aReplaceMap);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdatePointValues
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Point::UpdatePointValues()
|
||||
{
|
||||
if (!hasOwnColor
|
||||
&& myOwnWidth == 0.0f
|
||||
&& !myHasTOM)
|
||||
if (!hasOwnColor && myOwnWidth == 0.0f && !myHasTOM)
|
||||
{
|
||||
replaceWithNewPointAspect (Handle(Prs3d_PointAspect)());
|
||||
replaceWithNewPointAspect(Handle(Prs3d_PointAspect)());
|
||||
return;
|
||||
}
|
||||
|
||||
Quantity_Color aCol (Quantity_NOC_YELLOW);
|
||||
Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
|
||||
Quantity_Color aCol(Quantity_NOC_YELLOW);
|
||||
Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
|
||||
Standard_Real aScale = 1.0;
|
||||
if (myDrawer->HasLink())
|
||||
{
|
||||
@ -222,13 +188,16 @@ void AIS_Point::UpdatePointValues()
|
||||
aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
|
||||
}
|
||||
|
||||
if(hasOwnColor) aCol = myDrawer->Color();
|
||||
if(myOwnWidth != 0.0f) aScale = myOwnWidth;
|
||||
if(myHasTOM) aTOM = myTOM;
|
||||
if (hasOwnColor)
|
||||
aCol = myDrawer->Color();
|
||||
if (myOwnWidth != 0.0f)
|
||||
aScale = myOwnWidth;
|
||||
if (myHasTOM)
|
||||
aTOM = myTOM;
|
||||
|
||||
if(myDrawer->HasOwnPointAspect())
|
||||
if (myDrawer->HasOwnPointAspect())
|
||||
{
|
||||
Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
|
||||
Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
|
||||
PA->SetColor(aCol);
|
||||
PA->SetTypeOfMarker(aTOM);
|
||||
PA->SetScale(aScale);
|
||||
@ -236,7 +205,6 @@ void AIS_Point::UpdatePointValues()
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceWithNewPointAspect (new Prs3d_PointAspect (aTOM, aCol, aScale));
|
||||
replaceWithNewPointAspect(new Prs3d_PointAspect(aTOM, aCol, aScale));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,41 +28,44 @@ class AIS_Point : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Point, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes the point aComponent from which the point
|
||||
//! datum will be built.
|
||||
Standard_EXPORT AIS_Point(const Handle(Geom_Point)& aComponent);
|
||||
|
||||
|
||||
//! Returns index 1, the default index for a point.
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 1; }
|
||||
|
||||
//! Indicates that a point is a datum.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
//! Returns the component specified in SetComponent.
|
||||
Standard_EXPORT Handle(Geom_Point) Component();
|
||||
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
Standard_EXPORT Standard_Boolean
|
||||
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
|
||||
|
||||
//! Allows you to provide settings for the Color.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
|
||||
//! Allows you to remove color settings.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Allows you to provide settings for a marker. These include
|
||||
//! - type of marker,
|
||||
//! - marker color,
|
||||
//! - scale factor.
|
||||
Standard_EXPORT void SetMarker (const Aspect_TypeOfMarker aType);
|
||||
|
||||
Standard_EXPORT void SetMarker(const Aspect_TypeOfMarker aType);
|
||||
|
||||
//! Removes the marker settings.
|
||||
Standard_EXPORT void UnsetMarker();
|
||||
|
||||
|
||||
//! Returns true if the point datum has a marker.
|
||||
Standard_Boolean HasMarker() const { return myHasTOM; }
|
||||
|
||||
@ -70,26 +73,23 @@ public:
|
||||
Standard_EXPORT TopoDS_Vertex Vertex() const;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
const Standard_Integer aMode) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void UpdatePointValues();
|
||||
|
||||
//! 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:
|
||||
|
||||
Handle(Geom_Point) myComponent;
|
||||
Standard_Boolean myHasTOM;
|
||||
Handle(Geom_Point) myComponent;
|
||||
Standard_Boolean myHasTOM;
|
||||
Aspect_TypeOfMarker myTOM;
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_Point, AIS_InteractiveObject)
|
||||
|
@ -31,74 +31,71 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_PointCloudOwner
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_PointCloudOwner::AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin)
|
||||
: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theOrigin, 5),
|
||||
myDetPoints (new TColStd_HPackedMapOfInteger()),
|
||||
mySelPoints (new TColStd_HPackedMapOfInteger())
|
||||
//=================================================================================================
|
||||
|
||||
AIS_PointCloudOwner::AIS_PointCloudOwner(const Handle(AIS_PointCloud)& theOrigin)
|
||||
: SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)theOrigin, 5),
|
||||
myDetPoints(new TColStd_HPackedMapOfInteger()),
|
||||
mySelPoints(new TColStd_HPackedMapOfInteger())
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~AIS_PointCloudOwner
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_PointCloudOwner::~AIS_PointCloudOwner()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_PointCloudOwner::IsForcedHilight() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer )
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PointCloudOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
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())
|
||||
{
|
||||
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()
|
||||
? myDetPoints
|
||||
: mySelPoints;
|
||||
const Handle(TColStd_HPackedMapOfInteger)& aMap =
|
||||
thePrsMgr->IsImmediateModeOn() ? myDetPoints : mySelPoints;
|
||||
Handle(Prs3d_Presentation) aPrs = thePrsMgr->IsImmediateModeOn()
|
||||
? anObj->GetHilightPresentation(thePrsMgr)
|
||||
: anObj->GetSelectPresentation (thePrsMgr);
|
||||
const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1
|
||||
? theStyle->ZLayer()
|
||||
: (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer());
|
||||
? anObj->GetHilightPresentation(thePrsMgr)
|
||||
: anObj->GetSelectPresentation(thePrsMgr);
|
||||
const Graphic3d_ZLayerId aZLayer =
|
||||
theStyle->ZLayer() != -1
|
||||
? theStyle->ZLayer()
|
||||
: (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer());
|
||||
aMap->ChangeMap().Clear();
|
||||
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
|
||||
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(anObj->Selections()); aSelIter.More();
|
||||
aSelIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
|
||||
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
|
||||
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
|
||||
aSel->Entities());
|
||||
aSelEntIter.More();
|
||||
aSelEntIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_SensitiveEntity)& aSelEnt = aSelEntIter.Value();
|
||||
if (aSelEnt->BaseSensitive()->OwnerId() == this)
|
||||
{
|
||||
if (Handle(Select3D_SensitivePrimitiveArray) aSensitive = Handle(Select3D_SensitivePrimitiveArray)::DownCast (aSelEnt->BaseSensitive()))
|
||||
if (Handle(Select3D_SensitivePrimitiveArray) aSensitive =
|
||||
Handle(Select3D_SensitivePrimitiveArray)::DownCast(aSelEnt->BaseSensitive()))
|
||||
{
|
||||
aMap->ChangeMap() = aSensitive->LastDetectedElementMap()->Map();
|
||||
if (aSensitive->LastDetectedElement() != -1)
|
||||
{
|
||||
aMap->ChangeMap().Add (aSensitive->LastDetectedElement());
|
||||
aMap->ChangeMap().Add(aSensitive->LastDetectedElement());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -109,7 +106,7 @@ void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
|
||||
aPrs->Clear();
|
||||
if (aPrs->GetZLayer() != aZLayer)
|
||||
{
|
||||
aPrs->SetZLayer (aZLayer);
|
||||
aPrs->SetZLayer(aZLayer);
|
||||
}
|
||||
if (aMap->Map().IsEmpty())
|
||||
{
|
||||
@ -122,19 +119,19 @@ void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (aMap->Map().Extent());
|
||||
for (TColStd_PackedMapOfInteger::Iterator aPntIter (aMap->Map()); aPntIter.More(); aPntIter.Next())
|
||||
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints(aMap->Map().Extent());
|
||||
for (TColStd_PackedMapOfInteger::Iterator aPntIter(aMap->Map()); aPntIter.More(); aPntIter.Next())
|
||||
{
|
||||
const gp_Pnt aPnt = anAllPoints->Vertice (aPntIter.Key() + 1);
|
||||
aPoints->AddVertex (aPnt);
|
||||
const gp_Pnt aPnt = anAllPoints->Vertice(aPntIter.Key() + 1);
|
||||
aPoints->AddVertex(aPnt);
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aPoints);
|
||||
aGroup->SetGroupPrimitivesAspect(theStyle->PointAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray(aPoints);
|
||||
if (thePrsMgr->IsImmediateModeOn())
|
||||
{
|
||||
thePrsMgr->AddToImmediateList (aPrs);
|
||||
thePrsMgr->AddToImmediateList(aPrs);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//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()
|
||||
{
|
||||
myDrawer->SetupOwnShadingAspect();
|
||||
myDrawer->ShadingAspect()->Aspect()->SetMarkerType (Aspect_TOM_POINT);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetMarkerType(Aspect_TOM_POINT);
|
||||
|
||||
SetDisplayMode (AIS_PointCloud::DM_Points);
|
||||
SetHilightMode (AIS_PointCloud::DM_BndBox);
|
||||
SetDisplayMode(AIS_PointCloud::DM_Points);
|
||||
SetHilightMode(AIS_PointCloud::DM_BndBox);
|
||||
|
||||
myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));
|
||||
myDynHilightDrawer->SetPointAspect(
|
||||
new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetPoints
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
const Handle(Graphic3d_ArrayOfPoints) AIS_PointCloud::GetPoints() const
|
||||
{
|
||||
return myPoints;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetBoundingBox
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Bnd_Box AIS_PointCloud::GetBoundingBox() const
|
||||
{
|
||||
return myBndBox;
|
||||
}
|
||||
|
||||
//! 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;
|
||||
if (thePoints.IsNull())
|
||||
@ -208,28 +199,24 @@ static inline Bnd_Box getBoundingBox (const Handle(Graphic3d_ArrayOfPoints)& the
|
||||
const Standard_Integer aNbVertices = thePoints->VertexNumber();
|
||||
for (Standard_Integer aVertIter = 1; aVertIter <= aNbVertices; ++aVertIter)
|
||||
{
|
||||
aBndBox.Add (thePoints->Vertice (aVertIter));
|
||||
aBndBox.Add(thePoints->Vertice(aVertIter));
|
||||
}
|
||||
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;
|
||||
myBndBox = getBoundingBox (thePoints);
|
||||
myBndBox = getBoundingBox(thePoints);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPoints
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords,
|
||||
const Handle(Quantity_HArray1OfColor)& theColors,
|
||||
const Handle(TColgp_HArray1OfDir)& theNormals)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PointCloud::SetPoints(const Handle(TColgp_HArray1OfPnt)& theCoords,
|
||||
const Handle(Quantity_HArray1OfColor)& theColors,
|
||||
const Handle(TColgp_HArray1OfDir)& theNormals)
|
||||
{
|
||||
myPoints.Nullify();
|
||||
myBndBox.SetVoid();
|
||||
@ -240,52 +227,47 @@ void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords
|
||||
|
||||
const Standard_Integer aNbPoints = theCoords->Length();
|
||||
if ((!theNormals.IsNull() && theNormals->Length() != aNbPoints)
|
||||
|| (!theColors.IsNull() && theColors->Length() != aNbPoints))
|
||||
|| (!theColors.IsNull() && theColors->Length() != aNbPoints))
|
||||
{
|
||||
// invalid input
|
||||
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_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;
|
||||
|
||||
myPoints = new Graphic3d_ArrayOfPoints (aNbPoints, hasColors, hasNormals);
|
||||
myPoints = new Graphic3d_ArrayOfPoints(aNbPoints, hasColors, hasNormals);
|
||||
for (Standard_Integer aPntIter = theCoords->Lower(); aPntIter <= theCoords->Upper(); ++aPntIter)
|
||||
{
|
||||
myPoints->AddVertex (theCoords->Value (aPntIter));
|
||||
myPoints->AddVertex(theCoords->Value(aPntIter));
|
||||
if (hasColors)
|
||||
{
|
||||
myPoints->SetVertexColor (myPoints->VertexNumber(),
|
||||
theColors->Value (aPntIter + aDiffColors));
|
||||
myPoints->SetVertexColor(myPoints->VertexNumber(), theColors->Value(aPntIter + aDiffColors));
|
||||
}
|
||||
if (hasNormals)
|
||||
{
|
||||
myPoints->SetVertexNormal (myPoints->VertexNumber(),
|
||||
theNormals->Value (aPntIter + aDiffNormals));
|
||||
myPoints->SetVertexNormal(myPoints->VertexNumber(),
|
||||
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);
|
||||
|
||||
myDrawer->ShadingAspect()->SetColor (theColor);
|
||||
myDrawer->ShadingAspect()->SetColor(theColor);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PointCloud::UnsetColor()
|
||||
{
|
||||
if (!HasColor())
|
||||
@ -295,54 +277,50 @@ void AIS_PointCloud::UnsetColor()
|
||||
|
||||
AIS_InteractiveObject::UnsetColor();
|
||||
{
|
||||
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NameOfMaterial_Brass);
|
||||
Graphic3d_MaterialAspect aMat = aDefaultMat;
|
||||
Quantity_Color aColor = aDefaultMat.Color();
|
||||
Graphic3d_MaterialAspect aDefaultMat(Graphic3d_NameOfMaterial_Brass);
|
||||
Graphic3d_MaterialAspect aMat = aDefaultMat;
|
||||
Quantity_Color aColor = aDefaultMat.Color();
|
||||
if (myDrawer->HasLink())
|
||||
{
|
||||
aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
|
||||
aColor = myDrawer->Link()->ShadingAspect()->Color(myCurrentFacingModel);
|
||||
}
|
||||
if (HasMaterial() || myDrawer->HasLink())
|
||||
{
|
||||
aMat = AIS_GraphicTool::GetMaterial (HasMaterial() ? myDrawer : myDrawer->Link());
|
||||
aMat = AIS_GraphicTool::GetMaterial(HasMaterial() ? myDrawer : myDrawer->Link());
|
||||
}
|
||||
if (HasMaterial())
|
||||
{
|
||||
aMat.SetColor (aColor);
|
||||
aMat.SetColor(aColor);
|
||||
}
|
||||
if (IsTransparent())
|
||||
{
|
||||
Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
|
||||
aMat.SetTransparency (Standard_ShortReal(aTransp));
|
||||
Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
|
||||
aMat.SetTransparency(Standard_ShortReal(aTransp));
|
||||
}
|
||||
myDrawer->ShadingAspect()->SetMaterial (aMat, myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor);
|
||||
myDrawer->ShadingAspect()->SetMaterial(aMat, myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->Aspect()->SetInteriorColor(aColor);
|
||||
}
|
||||
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PointCloud::SetMaterial(const Graphic3d_MaterialAspect& theMat)
|
||||
{
|
||||
hasOwnMaterial = Standard_True;
|
||||
|
||||
myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->SetMaterial(theMat, myCurrentFacingModel);
|
||||
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();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PointCloud::UnsetMaterial()
|
||||
{
|
||||
if (!HasMaterial())
|
||||
@ -351,33 +329,30 @@ void AIS_PointCloud::UnsetMaterial()
|
||||
}
|
||||
|
||||
{
|
||||
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NameOfMaterial_Brass);
|
||||
myDrawer->ShadingAspect()->SetMaterial (myDrawer->HasLink() ?
|
||||
myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel) :
|
||||
aDefaultMat,
|
||||
myCurrentFacingModel);
|
||||
Graphic3d_MaterialAspect aDefaultMat(Graphic3d_NameOfMaterial_Brass);
|
||||
myDrawer->ShadingAspect()->SetMaterial(
|
||||
myDrawer->HasLink() ? myDrawer->Link()->ShadingAspect()->Material(myCurrentFacingModel)
|
||||
: aDefaultMat,
|
||||
myCurrentFacingModel);
|
||||
if (HasColor())
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->SetColor(myDrawer->Color(), myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->SetTransparency(myDrawer->Transparency(), myCurrentFacingModel);
|
||||
}
|
||||
}
|
||||
hasOwnMaterial = Standard_False;
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_PointCloud::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case AIS_PointCloud::DM_Points:
|
||||
{
|
||||
case AIS_PointCloud::DM_Points: {
|
||||
const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
|
||||
if (aPoints.IsNull())
|
||||
{
|
||||
@ -385,65 +360,63 @@ void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (aPoints);
|
||||
aGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray(aPoints);
|
||||
break;
|
||||
}
|
||||
case AIS_PointCloud::DM_BndBox:
|
||||
{
|
||||
case AIS_PointCloud::DM_BndBox: {
|
||||
Bnd_Box aBndBox = GetBoundingBox();
|
||||
if (aBndBox.IsVoid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Prs3d_BndBox::Add (thePrs, aBndBox, myDrawer);
|
||||
Prs3d_BndBox::Add(thePrs, aBndBox, myDrawer);
|
||||
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)
|
||||
{
|
||||
case SM_Points:
|
||||
case SM_SubsetOfPoints:
|
||||
{
|
||||
case SM_SubsetOfPoints: {
|
||||
const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
|
||||
if (!aPoints.IsNull()
|
||||
&& !aPoints->Attributes().IsNull())
|
||||
if (!aPoints.IsNull() && !aPoints->Attributes().IsNull())
|
||||
{
|
||||
if (theMode == SM_SubsetOfPoints)
|
||||
{
|
||||
anOwner = new AIS_PointCloudOwner (this);
|
||||
anOwner = new AIS_PointCloudOwner(this);
|
||||
}
|
||||
|
||||
// split large point clouds into several groups
|
||||
const Standard_Integer aNbGroups = aPoints->Attributes()->NbElements > 500000 ? 8 : 1;
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anOwner);
|
||||
aSensitive->SetDetectElements (true);
|
||||
aSensitive->SetDetectElementMap (theMode == SM_SubsetOfPoints);
|
||||
aSensitive->SetSensitivityFactor (8);
|
||||
aSensitive->InitPoints (aPoints->Attributes(), aPoints->Indices(), TopLoc_Location(), true, aNbGroups);
|
||||
Handle(Select3D_SensitivePrimitiveArray) aSensitive =
|
||||
new Select3D_SensitivePrimitiveArray(anOwner);
|
||||
aSensitive->SetDetectElements(true);
|
||||
aSensitive->SetDetectElementMap(theMode == SM_SubsetOfPoints);
|
||||
aSensitive->SetSensitivityFactor(8);
|
||||
aSensitive->InitPoints(aPoints->Attributes(),
|
||||
aPoints->Indices(),
|
||||
TopLoc_Location(),
|
||||
true,
|
||||
aNbGroups);
|
||||
aSensitive->BVH();
|
||||
theSelection->Add (aSensitive);
|
||||
theSelection->Add(aSensitive);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SM_BndBox:
|
||||
{
|
||||
case SM_BndBox: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -453,6 +426,6 @@ void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSel
|
||||
{
|
||||
return;
|
||||
}
|
||||
Handle(Select3D_SensitiveBox) aSensBox = new Select3D_SensitiveBox (anOwner, aBndBox);
|
||||
theSelection->Add (aSensBox);
|
||||
Handle(Select3D_SensitiveBox) aSensBox = new Select3D_SensitiveBox(anOwner, aBndBox);
|
||||
theSelection->Add(aSensBox);
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ class AIS_PointCloud : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Display modes supported by this Point Cloud object
|
||||
enum DisplayMode
|
||||
{
|
||||
@ -59,14 +58,13 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT AIS_PointCloud();
|
||||
|
||||
//! Sets the points from array of points.
|
||||
//! Method will not copy the input data - array will be stored as handle.
|
||||
//! @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.
|
||||
//! The input data will be copied into internal buffer.
|
||||
@ -75,14 +73,14 @@ public:
|
||||
//! @param[in] theCoords the array of coordinates
|
||||
//! @param[in] theColors optional array of colors
|
||||
//! @param[in] theNormals optional array of normals
|
||||
Standard_EXPORT virtual void SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords,
|
||||
const Handle(Quantity_HArray1OfColor)& theColors = NULL,
|
||||
const Handle(TColgp_HArray1OfDir)& theNormals = NULL);
|
||||
Standard_EXPORT virtual void SetPoints(const Handle(TColgp_HArray1OfPnt)& theCoords,
|
||||
const Handle(Quantity_HArray1OfColor)& theColors = NULL,
|
||||
const Handle(TColgp_HArray1OfDir)& theNormals = NULL);
|
||||
|
||||
public:
|
||||
|
||||
//! Get the points array.
|
||||
//! Method might be overridden to fill in points array dynamically from application data structures.
|
||||
//! Method might be overridden to fill in points array dynamically from application data
|
||||
//! structures.
|
||||
//! @return the array of points
|
||||
Standard_EXPORT virtual const Handle(Graphic3d_ArrayOfPoints) GetPoints() const;
|
||||
|
||||
@ -90,35 +88,33 @@ public:
|
||||
Standard_EXPORT virtual Bnd_Box GetBoundingBox() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Setup custom color. Affects presentation only when no per-point color attribute has been assigned.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
//! Setup custom color. Affects presentation only when no per-point color attribute has been
|
||||
//! assigned.
|
||||
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
|
||||
//! Restore default color.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
//! Setup custom material. Affects presentation only when normals are defined.
|
||||
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Restore default material.
|
||||
Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Prepare presentation for this object.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Prepare selection for this object.
|
||||
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;
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_ArrayOfPoints) myPoints; //!< points array for presentation
|
||||
Bnd_Box myBndBox; //!< bounding box for presentation
|
||||
|
||||
Handle(Graphic3d_ArrayOfPoints) myPoints; //!< points array for presentation
|
||||
Bnd_Box myBndBox; //!< bounding box for presentation
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject)
|
||||
@ -129,32 +125,37 @@ class AIS_PointCloudOwner : public SelectMgr_EntityOwner
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
|
||||
public:
|
||||
//! Main constructor.
|
||||
Standard_EXPORT AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin);
|
||||
Standard_EXPORT AIS_PointCloudOwner(const Handle(AIS_PointCloud)& theOrigin);
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~AIS_PointCloudOwner();
|
||||
|
||||
//! Return selected points.
|
||||
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
|
||||
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to
|
||||
//! Graphic3d_ArrayOfPoints::Vertice()).
|
||||
const Handle(TColStd_HPackedMapOfInteger)& SelectedPoints() const { return mySelPoints; }
|
||||
|
||||
//! Return last detected points.
|
||||
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
|
||||
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to
|
||||
//! Graphic3d_ArrayOfPoints::Vertice()).
|
||||
const Handle(TColStd_HPackedMapOfInteger)& DetectedPoints() const { return myDetPoints; }
|
||||
|
||||
//! Always update dynamic highlighting.
|
||||
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
|
||||
|
||||
//! Handle dynamic highlighting.
|
||||
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Removes highlighting.
|
||||
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Clears presentation.
|
||||
Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Clear(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
Handle(TColStd_HPackedMapOfInteger) myDetPoints; //!< last detected points
|
||||
Handle(TColStd_HPackedMapOfInteger) mySelPoints; //!< selected points
|
||||
|
@ -26,82 +26,74 @@
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
|
||||
#define MEMORY_BLOCK_SIZE 512 * 7
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
AIS_RubberBand::AIS_RubberBand()
|
||||
: myIsPolygonClosed(Standard_True)
|
||||
: myIsPolygonClosed(Standard_True)
|
||||
{
|
||||
myDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
|
||||
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);
|
||||
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
|
||||
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);
|
||||
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 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);
|
||||
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));
|
||||
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));
|
||||
SetZLayer (Graphic3d_ZLayerId_TopOSD);
|
||||
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));
|
||||
SetZLayer(Graphic3d_ZLayerId_TopOSD);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Destructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_RubberBand::~AIS_RubberBand()
|
||||
{
|
||||
myPoints.Clear();
|
||||
@ -109,254 +101,214 @@ AIS_RubberBand::~AIS_RubberBand()
|
||||
myBorders.Nullify();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetRectangle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_RubberBand::SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY,
|
||||
const Standard_Integer theMaxX, const Standard_Integer theMaxY)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_RubberBand::SetRectangle(const Standard_Integer theMinX,
|
||||
const Standard_Integer theMinY,
|
||||
const Standard_Integer theMaxX,
|
||||
const Standard_Integer theMaxY)
|
||||
{
|
||||
myPoints.Clear();
|
||||
myPoints.Append (Graphic3d_Vec2i (theMinX, theMinY));
|
||||
myPoints.Append (Graphic3d_Vec2i (theMinX, theMaxY));
|
||||
myPoints.Append (Graphic3d_Vec2i (theMaxX, theMaxY));
|
||||
myPoints.Append (Graphic3d_Vec2i (theMaxX, theMinY));
|
||||
myPoints.Append(Graphic3d_Vec2i(theMinX, theMinY));
|
||||
myPoints.Append(Graphic3d_Vec2i(theMinX, theMaxY));
|
||||
myPoints.Append(Graphic3d_Vec2i(theMaxX, theMaxY));
|
||||
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()
|
||||
{
|
||||
myPoints.Remove (myPoints.Length());
|
||||
myPoints.Remove(myPoints.Length());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetPoints
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
const NCollection_Sequence<Graphic3d_Vec2i>& AIS_RubberBand::Points() const
|
||||
{
|
||||
return myPoints;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LineColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Quantity_Color AIS_RubberBand::LineColor() const
|
||||
{
|
||||
return myDrawer->LineAspect()->Aspect()->Color();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLineColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_RubberBand::SetLineColor (const Quantity_Color& theColor)
|
||||
//=================================================================================================
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
SetFillTransparency (theTransparency);
|
||||
SetFillColor (theColor);
|
||||
SetFilling(Standard_True);
|
||||
SetFillTransparency(theTransparency);
|
||||
SetFillColor(theColor);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsFilling
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_RubberBand::IsFilling() const
|
||||
{
|
||||
Aspect_InteriorStyle aStyle = myDrawer->ShadingAspect()->Aspect()->InteriorStyle();
|
||||
return aStyle != Aspect_IS_EMPTY;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsPolygonClosed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_RubberBand::IsPolygonClosed() const
|
||||
{
|
||||
return myIsPolygonClosed;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetPolygonClosed
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_RubberBand::SetPolygonClosed(Standard_Boolean theIsPolygonClosed)
|
||||
{
|
||||
myIsPolygonClosed = theIsPolygonClosed;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : fillTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_RubberBand::fillTriangles()
|
||||
{
|
||||
Handle(NCollection_IncAllocator) anAllocator = new NCollection_IncAllocator (MEMORY_BLOCK_SIZE);
|
||||
Handle(BRepMesh_DataStructureOfDelaun) aMeshStructure = new BRepMesh_DataStructureOfDelaun(anAllocator);
|
||||
Standard_Integer aPtsLower = myPoints.Lower();
|
||||
Standard_Integer aPtsUpper = myPoints.Upper();
|
||||
IMeshData::VectorOfInteger anIndexes (myPoints.Length(), anAllocator);
|
||||
Handle(NCollection_IncAllocator) anAllocator = new NCollection_IncAllocator(MEMORY_BLOCK_SIZE);
|
||||
Handle(BRepMesh_DataStructureOfDelaun) aMeshStructure =
|
||||
new BRepMesh_DataStructureOfDelaun(anAllocator);
|
||||
Standard_Integer aPtsLower = myPoints.Lower();
|
||||
Standard_Integer aPtsUpper = myPoints.Upper();
|
||||
IMeshData::VectorOfInteger anIndexes(myPoints.Length(), anAllocator);
|
||||
for (Standard_Integer aPtIdx = aPtsLower; aPtIdx <= aPtsUpper; ++aPtIdx)
|
||||
{
|
||||
gp_XY aP ((Standard_Real)myPoints.Value (aPtIdx).x(),
|
||||
(Standard_Real)myPoints.Value (aPtIdx).y());
|
||||
BRepMesh_Vertex aVertex (aP, aPtIdx, BRepMesh_Frontier);
|
||||
anIndexes.Append (aMeshStructure->AddNode (aVertex));
|
||||
gp_XY aP((Standard_Real)myPoints.Value(aPtIdx).x(), (Standard_Real)myPoints.Value(aPtIdx).y());
|
||||
BRepMesh_Vertex aVertex(aP, aPtIdx, BRepMesh_Frontier);
|
||||
anIndexes.Append(aMeshStructure->AddNode(aVertex));
|
||||
}
|
||||
|
||||
Standard_Real aPtSum = 0;
|
||||
for (Standard_Integer aIdx = aPtsLower; aIdx <= aPtsUpper; ++aIdx)
|
||||
{
|
||||
Standard_Integer aNextIdx = (aIdx % myPoints.Length()) + 1;
|
||||
aPtSum += (Standard_Real)(myPoints.Value (aNextIdx).x() - myPoints.Value (aIdx).x())
|
||||
* (Standard_Real)(myPoints.Value (aNextIdx).y() + myPoints.Value (aIdx).y());
|
||||
aPtSum += (Standard_Real)(myPoints.Value(aNextIdx).x() - myPoints.Value(aIdx).x())
|
||||
* (Standard_Real)(myPoints.Value(aNextIdx).y() + myPoints.Value(aIdx).y());
|
||||
}
|
||||
Standard_Boolean isClockwiseOrdered = aPtSum < 0;
|
||||
|
||||
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;
|
||||
BRepMesh_Edge anEdge (anIndexes.Value (aPtIdx),
|
||||
anIndexes.Value (aNextPtIdx),
|
||||
BRepMesh_Frontier);
|
||||
aMeshStructure->AddLink (anEdge);
|
||||
BRepMesh_Edge anEdge(anIndexes.Value(aPtIdx), anIndexes.Value(aNextPtIdx), BRepMesh_Frontier);
|
||||
aMeshStructure->AddLink(anEdge);
|
||||
}
|
||||
|
||||
BRepMesh_Delaun aTriangulation (aMeshStructure, anIndexes);
|
||||
BRepMesh_Delaun aTriangulation(aMeshStructure, anIndexes);
|
||||
const IMeshData::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain();
|
||||
if (aTriangles.Extent() < 1)
|
||||
return Standard_False;
|
||||
|
||||
|
||||
Standard_Boolean toFill = Standard_False;
|
||||
if (myTriangles.IsNull() || myTriangles->VertexNumber() != aTriangles.Extent() * 3)
|
||||
{
|
||||
toFill = Standard_True;
|
||||
myTriangles = new Graphic3d_ArrayOfTriangles (aTriangles.Extent() * 3, 0, Standard_True);
|
||||
toFill = Standard_True;
|
||||
myTriangles = new Graphic3d_ArrayOfTriangles(aTriangles.Extent() * 3, 0, Standard_True);
|
||||
}
|
||||
|
||||
Standard_Integer aVertexIndex = 1;
|
||||
IMeshData::IteratorOfMapOfInteger aTriangleIt (aTriangles);
|
||||
Standard_Integer aVertexIndex = 1;
|
||||
IMeshData::IteratorOfMapOfInteger aTriangleIt(aTriangles);
|
||||
for (; aTriangleIt.More(); aTriangleIt.Next())
|
||||
{
|
||||
const Standard_Integer aTriangleId = aTriangleIt.Key();
|
||||
const BRepMesh_Triangle& aCurrentTriangle = aMeshStructure->GetElement (aTriangleId);
|
||||
const Standard_Integer aTriangleId = aTriangleIt.Key();
|
||||
const BRepMesh_Triangle& aCurrentTriangle = aMeshStructure->GetElement(aTriangleId);
|
||||
|
||||
if (aCurrentTriangle.Movability() == BRepMesh_Deleted)
|
||||
continue;
|
||||
|
||||
Standard_Integer aTriangleVerts[3];
|
||||
aMeshStructure->ElementNodes (aCurrentTriangle, aTriangleVerts);
|
||||
aMeshStructure->ElementNodes(aCurrentTriangle, aTriangleVerts);
|
||||
|
||||
gp_Pnt2d aPts[3];
|
||||
for (Standard_Integer aVertIdx = 0; aVertIdx < 3; ++aVertIdx)
|
||||
{
|
||||
const BRepMesh_Vertex& aVertex = aMeshStructure->GetNode (aTriangleVerts[aVertIdx]);
|
||||
aPts[aVertIdx] = aVertex.Coord();
|
||||
const BRepMesh_Vertex& aVertex = aMeshStructure->GetNode(aTriangleVerts[aVertIdx]);
|
||||
aPts[aVertIdx] = aVertex.Coord();
|
||||
}
|
||||
|
||||
if (toFill)
|
||||
@ -364,15 +316,18 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
|
||||
gp_Dir aNorm = gp::DZ();
|
||||
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
|
||||
{
|
||||
myTriangles->AddVertex (aPts[anIt].X(), aPts[anIt].Y(), 0.0,
|
||||
aNorm.X(), aNorm.Y(), aNorm.Z());
|
||||
myTriangles
|
||||
->AddVertex(aPts[anIt].X(), aPts[anIt].Y(), 0.0, aNorm.X(), aNorm.Y(), aNorm.Z());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
|
||||
{
|
||||
myTriangles->SetVertice (aVertexIndex++, (Standard_ShortReal)aPts[anIt].X(), (Standard_ShortReal)aPts[anIt].Y(), 0.0f);
|
||||
myTriangles->SetVertice(aVertexIndex++,
|
||||
(Standard_ShortReal)aPts[anIt].X(),
|
||||
(Standard_ShortReal)aPts[anIt].Y(),
|
||||
0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,13 +338,11 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_RubberBand::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode != 0)
|
||||
{
|
||||
@ -400,43 +353,49 @@ void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
if (IsFilling() && fillTriangles())
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup1 = thePresentation->NewGroup();
|
||||
aGroup1->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup1->AddPrimitiveArray (myTriangles);
|
||||
aGroup1->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
|
||||
aGroup1->AddPrimitiveArray(myTriangles);
|
||||
}
|
||||
|
||||
// Draw frame
|
||||
if (myBorders.IsNull() || myBorders->VertexNumber() != myPoints.Length() + (myIsPolygonClosed ? 1 : 0))
|
||||
if (myBorders.IsNull()
|
||||
|| myBorders->VertexNumber() != myPoints.Length() + (myIsPolygonClosed ? 1 : 0))
|
||||
{
|
||||
myBorders = new Graphic3d_ArrayOfPolylines(myPoints.Length() + (myIsPolygonClosed ? 1 : 0));
|
||||
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
|
||||
{
|
||||
myBorders->AddVertex ((Standard_Real)myPoints.Value (anIt).x(),
|
||||
(Standard_Real)myPoints.Value (anIt).y(), 0.0);
|
||||
}
|
||||
|
||||
if (myIsPolygonClosed)
|
||||
{
|
||||
myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(),
|
||||
(Standard_Real)myPoints.Value(1).y(), 0.0);
|
||||
}
|
||||
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
|
||||
{
|
||||
myBorders->AddVertex((Standard_Real)myPoints.Value(anIt).x(),
|
||||
(Standard_Real)myPoints.Value(anIt).y(),
|
||||
0.0);
|
||||
}
|
||||
|
||||
if (myIsPolygonClosed)
|
||||
{
|
||||
myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(),
|
||||
(Standard_Real)myPoints.Value(1).y(),
|
||||
0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
|
||||
{
|
||||
myBorders->SetVertice (anIt, (Standard_ShortReal)myPoints.Value (anIt).x(),
|
||||
(Standard_ShortReal)myPoints.Value (anIt).y(), 0.0f);
|
||||
myBorders->SetVertice(anIt,
|
||||
(Standard_ShortReal)myPoints.Value(anIt).x(),
|
||||
(Standard_ShortReal)myPoints.Value(anIt).y(),
|
||||
0.0f);
|
||||
}
|
||||
|
||||
if (myIsPolygonClosed)
|
||||
{
|
||||
myBorders->SetVertice(myPoints.Length() + 1, (Standard_ShortReal)myPoints.Value(1).x(),
|
||||
(Standard_ShortReal)myPoints.Value(1).y(), 0.0f);
|
||||
myBorders->SetVertice(myPoints.Length() + 1,
|
||||
(Standard_ShortReal)myPoints.Value(1).x(),
|
||||
(Standard_ShortReal)myPoints.Value(1).y(),
|
||||
0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray (myBorders);
|
||||
aGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
|
||||
aGroup->AddPrimitiveArray(myBorders);
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ DEFINE_STANDARD_HANDLE(AIS_RubberBand, AIS_InteractiveObject)
|
||||
class AIS_RubberBand : public AIS_InteractiveObject
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
|
||||
|
||||
//! Constructs rubber band with default configuration: empty filling and white solid lines.
|
||||
@ -45,34 +44,37 @@ public:
|
||||
//! @param[in] theType type of rubber band lines
|
||||
//! @param[in] theLineWidth width of rubber band line. By default it is 1.
|
||||
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
|
||||
Standard_EXPORT AIS_RubberBand (const Quantity_Color& theLineColor,
|
||||
const Aspect_TypeOfLine theType,
|
||||
const Standard_Real theLineWidth = 1.0,
|
||||
const Standard_Boolean theIsPolygonClosed = Standard_True);
|
||||
Standard_EXPORT AIS_RubberBand(const Quantity_Color& theLineColor,
|
||||
const Aspect_TypeOfLine theType,
|
||||
const Standard_Real theLineWidth = 1.0,
|
||||
const Standard_Boolean theIsPolygonClosed = Standard_True);
|
||||
|
||||
//! Constructs the rubber band with defined filling and line parameters.
|
||||
//! @param[in] theLineColor color of rubber band lines
|
||||
//! @param[in] theType type of rubber band lines
|
||||
//! @param[in] theFillColor color of rubber band filling
|
||||
//! @param[in] theTransparency transparency of the filling. 0 is for opaque filling. By default it is transparent.
|
||||
//! @param[in] theTransparency transparency of the filling. 0 is for opaque filling. By default
|
||||
//! it is transparent.
|
||||
//! @param[in] theLineWidth width of rubber band line. By default it is 1.
|
||||
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
|
||||
Standard_EXPORT AIS_RubberBand (const Quantity_Color& theLineColor,
|
||||
const Aspect_TypeOfLine theType,
|
||||
const Quantity_Color theFillColor,
|
||||
const Standard_Real theTransparency = 1.0,
|
||||
const Standard_Real theLineWidth = 1.0,
|
||||
const Standard_Boolean theIsPolygonClosed = Standard_True);
|
||||
Standard_EXPORT AIS_RubberBand(const Quantity_Color& theLineColor,
|
||||
const Aspect_TypeOfLine theType,
|
||||
const Quantity_Color theFillColor,
|
||||
const Standard_Real theTransparency = 1.0,
|
||||
const Standard_Real theLineWidth = 1.0,
|
||||
const Standard_Boolean theIsPolygonClosed = Standard_True);
|
||||
|
||||
Standard_EXPORT virtual ~AIS_RubberBand();
|
||||
|
||||
//! Sets rectangle bounds.
|
||||
Standard_EXPORT void SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY,
|
||||
const Standard_Integer theMaxX, const Standard_Integer theMaxY);
|
||||
Standard_EXPORT void SetRectangle(const Standard_Integer theMinX,
|
||||
const Standard_Integer theMinY,
|
||||
const Standard_Integer theMaxX,
|
||||
const Standard_Integer theMaxY);
|
||||
|
||||
//! Adds last point to the list of points. They are used to build polygon for rubber band.
|
||||
//! @sa RemoveLastPoint(), GetPoints()
|
||||
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.
|
||||
//! @sa AddPoint(), GetPoints()
|
||||
@ -88,40 +90,41 @@ public:
|
||||
Standard_EXPORT Quantity_Color LineColor() const;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT Quantity_Color FillColor() const;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void SetLineWidth (const Standard_Real theWidth) const;
|
||||
Standard_EXPORT void SetLineWidth(const Standard_Real theWidth) const;
|
||||
|
||||
//! @return width of lines.
|
||||
Standard_EXPORT Standard_Real LineWidth() const;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT Aspect_TypeOfLine LineType() const;
|
||||
|
||||
//! Sets fill transparency.
|
||||
//! @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.
|
||||
Standard_EXPORT Standard_Real FillTransparency() const;
|
||||
|
||||
//! 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.
|
||||
//! @param[in] theColor color of filling
|
||||
//! @param[in] theTransparency transparency of the filling. 0 is for opaque filling.
|
||||
Standard_EXPORT void SetFilling (const Quantity_Color theColor, const Standard_Real theTransparency);
|
||||
Standard_EXPORT void SetFilling(const Quantity_Color theColor,
|
||||
const Standard_Real theTransparency);
|
||||
|
||||
//! @return true if filling of rubber band is enabled.
|
||||
Standard_EXPORT Standard_Boolean IsFilling() const;
|
||||
@ -129,26 +132,25 @@ public:
|
||||
//! @return true if automatic closing of rubber band is enabled.
|
||||
Standard_EXPORT Standard_Boolean IsPolygonClosed() const;
|
||||
|
||||
//! Automatically create an additional line connecting the first and
|
||||
//! Automatically create an additional line connecting the first and
|
||||
//! the last screen points to close the boundary polyline
|
||||
Standard_EXPORT void SetPolygonClosed(Standard_Boolean theIsPolygonClosed);
|
||||
|
||||
protected:
|
||||
|
||||
//! Returns true if the interactive object accepts the display mode.
|
||||
Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode == 0;
|
||||
}
|
||||
|
||||
//! Computes presentation of rubber band.
|
||||
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,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Does not fill selection primitives for rubber band.
|
||||
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||
const Standard_Integer /*aMode*/) Standard_OVERRIDE { };
|
||||
virtual void ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||
const Standard_Integer /*aMode*/) Standard_OVERRIDE {};
|
||||
|
||||
//! Fills triangles primitive array for rubber band filling.
|
||||
//! It uses Delaunay triangulation.
|
||||
@ -156,12 +158,11 @@ protected:
|
||||
Standard_EXPORT Standard_Boolean fillTriangles();
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Sequence<Graphic3d_Vec2i> myPoints; //!< Array of screen points
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling
|
||||
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
|
||||
|
@ -17,12 +17,11 @@
|
||||
#ifndef _AIS_SelectStatus_HeaderFile
|
||||
#define _AIS_SelectStatus_HeaderFile
|
||||
|
||||
|
||||
enum AIS_SelectStatus
|
||||
{
|
||||
AIS_SS_Added,
|
||||
AIS_SS_Removed,
|
||||
AIS_SS_NotDone
|
||||
AIS_SS_Added,
|
||||
AIS_SS_Removed,
|
||||
AIS_SS_NotDone
|
||||
};
|
||||
|
||||
#endif // _AIS_SelectStatus_HeaderFile
|
||||
|
@ -22,62 +22,55 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_Integer THE_MaxSizeOfResult = 100000;
|
||||
static const Standard_Integer THE_MaxSizeOfResult = 100000;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_Selection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
AIS_Selection::AIS_Selection()
|
||||
{
|
||||
// for maximum performance on medium selections (< 100000 objects)
|
||||
myResultMap.ReSize (THE_MaxSizeOfResult);
|
||||
myResultMap.ReSize(THE_MaxSizeOfResult);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
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();
|
||||
anObject->SetSelected (Standard_False);
|
||||
anObject->SetSelected(Standard_False);
|
||||
}
|
||||
myresult.Clear();
|
||||
myResultMap.Clear();
|
||||
myIterator = AIS_NListOfEntityOwner::Iterator();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(SelectMgr_Filter)& theFilter,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theIsDetected)
|
||||
//=================================================================================================
|
||||
|
||||
AIS_SelectStatus AIS_Selection::Select(const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(SelectMgr_Filter)& theFilter,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theIsDetected)
|
||||
{
|
||||
if (theOwner.IsNull()
|
||||
|| !theOwner->HasSelectable())
|
||||
if (theOwner.IsNull() || !theOwner->HasSelectable())
|
||||
{
|
||||
return AIS_SS_NotDone;
|
||||
}
|
||||
|
||||
const Standard_Boolean isDetected = theIsDetected
|
||||
&& (theFilter.IsNull() || theFilter->IsOk (theOwner));
|
||||
const Standard_Boolean isDetected =
|
||||
theIsDetected && (theFilter.IsNull() || theFilter->IsOk(theOwner));
|
||||
|
||||
const Standard_Boolean wasSelected = theOwner->IsSelected();
|
||||
const Standard_Boolean toSelect = theOwner->Select (theSelScheme, isDetected);
|
||||
const Standard_Boolean toSelect = theOwner->Select(theSelScheme, isDetected);
|
||||
|
||||
if (toSelect && !wasSelected)
|
||||
{
|
||||
AIS_NListOfEntityOwner::Iterator aListIter;
|
||||
myresult.Append (theOwner, aListIter);
|
||||
myResultMap.Bind (theOwner, aListIter);
|
||||
theOwner->SetSelected (Standard_True);
|
||||
myresult.Append(theOwner, aListIter);
|
||||
myResultMap.Bind(theOwner, aListIter);
|
||||
theOwner->SetSelected(Standard_True);
|
||||
return AIS_SS_Added;
|
||||
}
|
||||
|
||||
@ -86,7 +79,7 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
|
||||
return AIS_SS_NotDone;
|
||||
}
|
||||
|
||||
AIS_NListOfEntityOwner::Iterator aListIter = myResultMap.Find (theOwner);
|
||||
AIS_NListOfEntityOwner::Iterator aListIter = myResultMap.Find(theOwner);
|
||||
if (myIterator == aListIter)
|
||||
{
|
||||
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.
|
||||
// It is necessary to check the current detected entity
|
||||
// and remove the owner from map only if the detected entity is the same as previous selected (IsForcedHilight call)
|
||||
// and remove the owner from map only if the detected entity is the same as previous selected
|
||||
// (IsForcedHilight call)
|
||||
if (theOwner->IsForcedHilight())
|
||||
{
|
||||
return AIS_SS_Added;
|
||||
}
|
||||
|
||||
myresult.Remove (aListIter);
|
||||
myResultMap.UnBind (theOwner);
|
||||
theOwner->SetSelected (Standard_False);
|
||||
myresult.Remove(aListIter);
|
||||
myResultMap.UnBind(theOwner);
|
||||
theOwner->SetSelected(Standard_False);
|
||||
|
||||
// update list iterator for next object in <myresult> list if any
|
||||
if (aListIter.More())
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner)& aNextObject = aListIter.Value();
|
||||
if (myResultMap.IsBound (aNextObject))
|
||||
if (myResultMap.IsBound(aNextObject))
|
||||
{
|
||||
myResultMap (aNextObject) = aListIter;
|
||||
myResultMap(aNextObject) = aListIter;
|
||||
}
|
||||
else
|
||||
{
|
||||
myResultMap.Bind (aNextObject, aListIter);
|
||||
myResultMap.Bind(aNextObject, aListIter);
|
||||
}
|
||||
}
|
||||
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()
|
||||
|| !theObject->HasSelectable()
|
||||
|| myResultMap.IsBound (theObject))
|
||||
if (theObject.IsNull() || !theObject->HasSelectable() || myResultMap.IsBound(theObject))
|
||||
{
|
||||
return AIS_SS_NotDone;
|
||||
}
|
||||
|
||||
AIS_NListOfEntityOwner::Iterator aListIter;
|
||||
myresult.Append (theObject, aListIter);
|
||||
myResultMap.Bind (theObject, aListIter);
|
||||
theObject->SetSelected (Standard_True);
|
||||
myresult.Append(theObject, aListIter);
|
||||
myResultMap.Bind(theObject, aListIter);
|
||||
theObject->SetSelected(Standard_True);
|
||||
return AIS_SS_Added;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectOwners
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theToAllowSelOverlap,
|
||||
const Handle(SelectMgr_Filter)& theFilter)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Selection::SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theToAllowSelOverlap,
|
||||
const Handle(SelectMgr_Filter)& theFilter)
|
||||
{
|
||||
(void)theToAllowSelOverlap;
|
||||
|
||||
if (theSelScheme == AIS_SelectionScheme_ReplaceExtra
|
||||
&& thePickedOwners.Size() == myresult.Size())
|
||||
if (theSelScheme == AIS_SelectionScheme_ReplaceExtra && thePickedOwners.Size() == myresult.Size())
|
||||
{
|
||||
// If picked owners is equivalent to the selected then just clear selected.
|
||||
Standard_Boolean isTheSame = Standard_True;
|
||||
for (AIS_NArray1OfEntityOwner::Iterator aPickedIter (thePickedOwners); aPickedIter.More(); aPickedIter.Next())
|
||||
for (AIS_NArray1OfEntityOwner::Iterator aPickedIter(thePickedOwners); aPickedIter.More();
|
||||
aPickedIter.Next())
|
||||
{
|
||||
if (!myResultMap.IsBound (aPickedIter.Value()))
|
||||
if (!myResultMap.IsBound(aPickedIter.Value()))
|
||||
{
|
||||
isTheSame = Standard_False;
|
||||
break;
|
||||
@ -173,38 +161,35 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
|
||||
}
|
||||
if (isTheSame)
|
||||
{
|
||||
Clear();
|
||||
return;
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (theSelScheme == AIS_SelectionScheme_Replace
|
||||
|| theSelScheme == AIS_SelectionScheme_ReplaceExtra
|
||||
|| theSelScheme == AIS_SelectionScheme_Clear)
|
||||
|| theSelScheme == AIS_SelectionScheme_ReplaceExtra
|
||||
|| theSelScheme == AIS_SelectionScheme_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();
|
||||
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()
|
||||
|| !theOwner->HasSelectable()
|
||||
|| !theFilter->IsOk (theOwner))
|
||||
if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk(theOwner))
|
||||
{
|
||||
return AIS_SS_NotDone;
|
||||
}
|
||||
|
||||
return AddSelect (theOwner);
|
||||
return AddSelect(theOwner);
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class AIS_Selection : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! creates a new selection.
|
||||
Standard_EXPORT AIS_Selection();
|
||||
|
||||
@ -45,29 +44,33 @@ public:
|
||||
//! @param[in] theSelScheme selection scheme
|
||||
//! @param[in] theIsDetected flag of object detection
|
||||
//! @return result of selection
|
||||
Standard_EXPORT virtual AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(SelectMgr_Filter)& theFilter,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theIsDetected);
|
||||
Standard_EXPORT virtual AIS_SelectStatus Select(const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(SelectMgr_Filter)& theFilter,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theIsDetected);
|
||||
|
||||
//! the object is always add int the selection.
|
||||
//! faster when the number of objects selected is great.
|
||||
Standard_EXPORT virtual AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
|
||||
Standard_EXPORT virtual AIS_SelectStatus AddSelect(
|
||||
const Handle(SelectMgr_EntityOwner)& theObject);
|
||||
|
||||
//! clears the selection and adds the object in the selection.
|
||||
//! @param[in] theObject element to change selection state
|
||||
//! @param[in] theFilter context filter
|
||||
//! @param[in] theIsDetected flag of object detection
|
||||
virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject,
|
||||
const Handle(SelectMgr_Filter)& theFilter,
|
||||
const Standard_Boolean theIsDetected)
|
||||
virtual void ClearAndSelect(const Handle(SelectMgr_EntityOwner)& theObject,
|
||||
const Handle(SelectMgr_Filter)& theFilter,
|
||||
const Standard_Boolean theIsDetected)
|
||||
{
|
||||
Clear();
|
||||
Select (theObject, theFilter, AIS_SelectionScheme_Add, theIsDetected);
|
||||
Select(theObject, theFilter, AIS_SelectionScheme_Add, theIsDetected);
|
||||
}
|
||||
|
||||
//! checks if the object is in the selection.
|
||||
Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
|
||||
Standard_Boolean IsSelected(const Handle(SelectMgr_EntityOwner)& theObject) const
|
||||
{
|
||||
return myResultMap.IsBound(theObject);
|
||||
}
|
||||
|
||||
//! Return the list of selected objects.
|
||||
const AIS_NListOfEntityOwner& Objects() const { return myresult; }
|
||||
@ -79,7 +82,6 @@ public:
|
||||
Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
|
||||
|
||||
public:
|
||||
|
||||
//! Start iteration through selected objects.
|
||||
void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
|
||||
|
||||
@ -97,26 +99,24 @@ public:
|
||||
//! @param[in] theSelScheme selection scheme, defines how owner is selected
|
||||
//! @param[in] theToAllowSelOverlap selection flag, if true - overlapped entities are allowed
|
||||
//! @param[in] theFilter context filter to skip not acceptable owners
|
||||
Standard_EXPORT virtual void SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theToAllowSelOverlap,
|
||||
const Handle(SelectMgr_Filter)& theFilter);
|
||||
Standard_EXPORT virtual void SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners,
|
||||
const AIS_SelectionScheme theSelScheme,
|
||||
const Standard_Boolean theToAllowSelOverlap,
|
||||
const Handle(SelectMgr_Filter)& theFilter);
|
||||
|
||||
protected:
|
||||
|
||||
//! Append the owner into the current selection if filter is Ok.
|
||||
//! @param[in] theOwner element to change selection state
|
||||
//! @param[in] theFilter context filter to skip not acceptable owners
|
||||
//! @return result of selection
|
||||
Standard_EXPORT virtual AIS_SelectStatus appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(SelectMgr_Filter)& theFilter);
|
||||
Standard_EXPORT virtual AIS_SelectStatus appendOwner(
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(SelectMgr_Filter)& theFilter);
|
||||
|
||||
protected:
|
||||
|
||||
AIS_NListOfEntityOwner myresult;
|
||||
AIS_NListOfEntityOwner::Iterator myIterator;
|
||||
AIS_NListOfEntityOwner myresult;
|
||||
AIS_NListOfEntityOwner::Iterator myIterator;
|
||||
NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)
|
||||
|
@ -14,12 +14,17 @@
|
||||
#ifndef _AIS_SelectionModesConcurrency_HeaderFile
|
||||
#define _AIS_SelectionModesConcurrency_HeaderFile
|
||||
|
||||
//! The mode specifying how multiple active Selection Modes should be treated during activation of new one.
|
||||
//! The mode specifying how multiple active Selection Modes should be treated during activation of
|
||||
//! new one.
|
||||
enum AIS_SelectionModesConcurrency
|
||||
{
|
||||
AIS_SelectionModesConcurrency_Single, //!< only one selection mode can be activated at the same moment - previously activated should be deactivated
|
||||
AIS_SelectionModesConcurrency_GlobalOrLocal, //!< either Global (AIS_InteractiveObject::GlobalSelectionMode() or Local (multiple) selection modes can be active at the same moment
|
||||
AIS_SelectionModesConcurrency_Multiple, //!< any combination of selection modes can be activated
|
||||
AIS_SelectionModesConcurrency_Single, //!< only one selection mode can be activated at the same
|
||||
//!< moment - previously activated should be deactivated
|
||||
AIS_SelectionModesConcurrency_GlobalOrLocal, //!< either Global
|
||||
//!< (AIS_InteractiveObject::GlobalSelectionMode() or
|
||||
//!< Local (multiple) selection modes can be active
|
||||
//!< at the same moment
|
||||
AIS_SelectionModesConcurrency_Multiple, //!< any combination of selection modes can be activated
|
||||
};
|
||||
|
||||
#endif // _AIS_SelectionModesConcurrency_HeaderFile
|
||||
|
@ -21,10 +21,11 @@ enum AIS_SelectionScheme
|
||||
AIS_SelectionScheme_Replace = 0, //!< clears current selection and select detected objects
|
||||
AIS_SelectionScheme_Add, //!< adds detected object to 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_Clear, //!< clears current selection
|
||||
AIS_SelectionScheme_ReplaceExtra, //!< replace with one difference: if result of replace is an empty,
|
||||
//!< and current selection contains detected element, it will be selected
|
||||
AIS_SelectionScheme_XOR, //!< performs XOR for detected objects, other selected not touched
|
||||
AIS_SelectionScheme_Clear, //!< clears current selection
|
||||
AIS_SelectionScheme_ReplaceExtra, //!< replace with one difference: if result of replace is an
|
||||
//!< empty, and current selection contains detected element, it
|
||||
//!< will be selected
|
||||
};
|
||||
|
||||
#endif // _AIS_SelectionScheme_HeaderFile
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -47,21 +47,22 @@
|
||||
//! true indicating that there is a local setting available
|
||||
//! for the specific object.
|
||||
//!
|
||||
//! This class allows to map textures on shapes using native UV parametric space of underlying surface of each Face
|
||||
//! (this means that texture will be visually duplicated on all Faces).
|
||||
//! To generate texture coordinates, appropriate shading attribute should be set before computing presentation in AIS_Shaded display mode:
|
||||
//! This class allows to map textures on shapes using native UV parametric space of underlying
|
||||
//! surface of each Face (this means that texture will be visually duplicated on all Faces). To
|
||||
//! generate texture coordinates, appropriate shading attribute should be set before computing
|
||||
//! presentation in AIS_Shaded display mode:
|
||||
//! @code
|
||||
//! Handle(AIS_Shape) aPrs = new AIS_Shape();
|
||||
//! aPrs->Attributes()->SetupOwnShadingAspect();
|
||||
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
|
||||
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
|
||||
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual
|
||||
//! (Graphic3d_NOT_2D_ALUMINUM));
|
||||
//! @endcode
|
||||
//! The texture itself is parametrized in (0,1)x(0,1).
|
||||
class AIS_Shape : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Shape, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes construction of the shape shap from wires,
|
||||
//! edges and vertices.
|
||||
Standard_EXPORT AIS_Shape(const TopoDS_Shape& shap);
|
||||
@ -70,59 +71,70 @@ public:
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
//! Returns Object as the type of Interactive Object.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Shape; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Shape;
|
||||
}
|
||||
|
||||
//! Returns true if the Interactive Object accepts shape decomposition.
|
||||
virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE { return Standard_True; }
|
||||
virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Return true if specified display mode is supported.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode >= 0 && theMode <= 2; }
|
||||
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode >= 0 && theMode <= 2;
|
||||
}
|
||||
|
||||
//! Returns this shape object.
|
||||
const TopoDS_Shape& Shape() const { return myshape; }
|
||||
|
||||
//! Constructs an instance of the shape object theShape.
|
||||
void SetShape (const TopoDS_Shape& theShape)
|
||||
void SetShape(const TopoDS_Shape& theShape)
|
||||
{
|
||||
myshape = theShape;
|
||||
myCompBB = Standard_True;
|
||||
}
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient();
|
||||
|
||||
//! Sets a local value for deviation angle for this specific shape.
|
||||
Standard_EXPORT Standard_Boolean SetOwnDeviationAngle();
|
||||
|
||||
|
||||
//! 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
|
||||
//! 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.
|
||||
Standard_EXPORT Standard_Real UserAngle() const;
|
||||
|
||||
|
||||
//! 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
|
||||
//! coefficient aCoefficient and the previous deviation
|
||||
//! coefficient aPreviousCoefficient. If these values are
|
||||
//! not already set, false is returned.
|
||||
Standard_EXPORT Standard_Boolean OwnDeviationCoefficient (Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean
|
||||
OwnDeviationCoefficient(Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
|
||||
|
||||
//! Returns true and the values of the deviation angle
|
||||
//! anAngle and the previous deviation angle aPreviousAngle.
|
||||
//! If these values are not already set, false is returned.
|
||||
Standard_EXPORT Standard_Boolean OwnDeviationAngle (Standard_Real& anAngle, Standard_Real& aPreviousAngle) const;
|
||||
|
||||
Standard_EXPORT Standard_Boolean OwnDeviationAngle(Standard_Real& anAngle,
|
||||
Standard_Real& aPreviousAngle) const;
|
||||
|
||||
//! Sets the type of HLR algorithm used by the shape
|
||||
void SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR) { myDrawer->SetTypeOfHLR (theTypeOfHLR); }
|
||||
void SetTypeOfHLR(const Prs3d_TypeOfHLR theTypeOfHLR) { myDrawer->SetTypeOfHLR(theTypeOfHLR); }
|
||||
|
||||
//! Gets the type of HLR algorithm
|
||||
Prs3d_TypeOfHLR TypeOfHLR() const { return myDrawer->TypeOfHLR(); }
|
||||
@ -140,102 +152,120 @@ public:
|
||||
//! Prs3d_Drawer_SeenLineAspect
|
||||
//! - hidden line color in hidden line mode:
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Sets the value aValue for line width in the reconstructed compound shape.
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
|
||||
|
||||
//! Allows you to provide settings for the material aName
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Constructs a bounding box with which to reconstruct
|
||||
//! compound topological shapes for presentation.
|
||||
Standard_EXPORT virtual const Bnd_Box& BoundingBox();
|
||||
|
||||
|
||||
//! AIS_InteractiveObject defines another virtual method BoundingBox,
|
||||
//! which is not the same as above; keep it visible.
|
||||
using AIS_InteractiveObject::BoundingBox;
|
||||
|
||||
//! Returns the Color attributes of the shape accordingly to
|
||||
//! 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
|
||||
//! the current facing model;
|
||||
Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Returns the transparency attributes of the shape accordingly to
|
||||
//! the current facing model;
|
||||
Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
|
||||
|
||||
//! 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)
|
||||
{
|
||||
case 1: return TopAbs_VERTEX;
|
||||
case 2: return TopAbs_EDGE;
|
||||
case 3: return TopAbs_WIRE;
|
||||
case 4: return TopAbs_FACE;
|
||||
case 5: return TopAbs_SHELL;
|
||||
case 6: return TopAbs_SOLID;
|
||||
case 7: return TopAbs_COMPSOLID;
|
||||
case 8: return TopAbs_COMPOUND;
|
||||
case 0: return TopAbs_SHAPE;
|
||||
case 1:
|
||||
return TopAbs_VERTEX;
|
||||
case 2:
|
||||
return TopAbs_EDGE;
|
||||
case 3:
|
||||
return TopAbs_WIRE;
|
||||
case 4:
|
||||
return TopAbs_FACE;
|
||||
case 5:
|
||||
return TopAbs_SHELL;
|
||||
case 6:
|
||||
return TopAbs_SOLID;
|
||||
case 7:
|
||||
return TopAbs_COMPSOLID;
|
||||
case 8:
|
||||
return TopAbs_COMPOUND;
|
||||
case 0:
|
||||
return TopAbs_SHAPE;
|
||||
}
|
||||
return TopAbs_SHAPE;
|
||||
}
|
||||
|
||||
//! 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)
|
||||
{
|
||||
case TopAbs_VERTEX: return 1;
|
||||
case TopAbs_EDGE: return 2;
|
||||
case TopAbs_WIRE: return 3;
|
||||
case TopAbs_FACE: return 4;
|
||||
case TopAbs_SHELL: return 5;
|
||||
case TopAbs_SOLID: return 6;
|
||||
case TopAbs_COMPSOLID: return 7;
|
||||
case TopAbs_COMPOUND: return 8;
|
||||
case TopAbs_SHAPE: return 0;
|
||||
case TopAbs_VERTEX:
|
||||
return 1;
|
||||
case TopAbs_EDGE:
|
||||
return 2;
|
||||
case TopAbs_WIRE:
|
||||
return 3;
|
||||
case TopAbs_FACE:
|
||||
return 4;
|
||||
case TopAbs_SHELL:
|
||||
return 5;
|
||||
case TopAbs_SOLID:
|
||||
return 6;
|
||||
case TopAbs_COMPSOLID:
|
||||
return 7;
|
||||
case TopAbs_COMPOUND:
|
||||
return 8;
|
||||
case TopAbs_SHAPE:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public: //! @name methods to alter texture mapping properties
|
||||
|
||||
//! Return texture repeat UV values; (1, 1) by default.
|
||||
const gp_Pnt2d& TextureRepeatUV() const { return myUVRepeat; }
|
||||
|
||||
//! Sets the number of occurrences of the texture on each face. The texture itself is parameterized in (0,1) by (0,1).
|
||||
//! Each face of the shape to be textured is parameterized in UV space (Umin,Umax) by (Vmin,Vmax).
|
||||
void SetTextureRepeatUV (const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; }
|
||||
//! Sets the number of occurrences of the texture on each face. The texture itself is
|
||||
//! parameterized in (0,1) by (0,1). Each face of the shape to be textured is parameterized in UV
|
||||
//! space (Umin,Umax) by (Vmin,Vmax).
|
||||
void SetTextureRepeatUV(const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; }
|
||||
|
||||
//! Return texture origin UV position; (0, 0) by default.
|
||||
const gp_Pnt2d& TextureOriginUV() const { return myUVOrigin; }
|
||||
|
||||
//! Use this method to change the origin of the texture.
|
||||
//! 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.
|
||||
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.
|
||||
//! 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.
|
||||
void SetTextureScaleUV (const gp_Pnt2d& theScaleUV) { myUVScale = theScaleUV; }
|
||||
void SetTextureScaleUV(const gp_Pnt2d& theScaleUV) { myUVScale = theScaleUV; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Compute normal presentation.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute projected presentation.
|
||||
virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(TopLoc_Datum3D)& theTrsf,
|
||||
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
|
||||
virtual void computeHLR(const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(TopLoc_Datum3D)& theTrsf,
|
||||
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
|
||||
{
|
||||
if (!theTrsf.IsNull()
|
||||
&& theTrsf->Form() != gp_Identity)
|
||||
if (!theTrsf.IsNull() && theTrsf->Form() != gp_Identity)
|
||||
{
|
||||
const TopLoc_Location& aLoc = myshape.Location();
|
||||
const TopoDS_Shape aShape = myshape.Located (TopLoc_Location (theTrsf->Trsf()) * aLoc);
|
||||
computeHlrPresentation (theProjector, thePrs, aShape, myDrawer);
|
||||
const TopLoc_Location& aLoc = myshape.Location();
|
||||
const TopoDS_Shape aShape = myshape.Located(TopLoc_Location(theTrsf->Trsf()) * aLoc);
|
||||
computeHlrPresentation(theProjector, thePrs, aShape, myDrawer);
|
||||
}
|
||||
else
|
||||
{
|
||||
computeHlrPresentation (theProjector, thePrs, myshape, myDrawer);
|
||||
computeHlrPresentation(theProjector, thePrs, myshape, myDrawer);
|
||||
}
|
||||
}
|
||||
|
||||
//! Compute selection.
|
||||
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;
|
||||
|
||||
//! Create own aspects (if they do not exist) and set color to them.
|
||||
//! @return TRUE if new aspects have been created
|
||||
Standard_EXPORT bool setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const;
|
||||
|
||||
Standard_EXPORT bool setColor(const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColor) const;
|
||||
|
||||
//! Create own aspects (if they do not exist) and set width to them.
|
||||
//! @return TRUE if new aspects have been created
|
||||
Standard_EXPORT bool setWidth (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theWidth) const;
|
||||
|
||||
Standard_EXPORT 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 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 setMaterial(const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Graphic3d_MaterialAspect& theMaterial,
|
||||
const Standard_Boolean theToKeepColor,
|
||||
const Standard_Boolean theToKeepTransp) const;
|
||||
|
||||
//! Replace aspects of already computed groups from drawer link by the new own value.
|
||||
Standard_EXPORT void replaceWithNewOwnAspects();
|
||||
|
||||
public:
|
||||
|
||||
//! Compute HLR presentation for specified shape.
|
||||
Standard_EXPORT static void computeHlrPresentation (const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
Standard_EXPORT static void computeHlrPresentation(const Handle(Graphic3d_Camera)& theProjector,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer);
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
TopoDS_Shape myshape; //!< shape to display
|
||||
Bnd_Box myBB; //!< cached bounding box of the shape
|
||||
gp_Pnt2d myUVOrigin; //!< UV origin vector for generating texture coordinates
|
||||
gp_Pnt2d myUVRepeat; //!< UV repeat vector for generating texture coordinates
|
||||
gp_Pnt2d myUVScale; //!< UV scale vector for generating texture coordinates
|
||||
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)
|
||||
|
@ -14,26 +14,25 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_SignatureFilter.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#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,
|
||||
const Standard_Integer TheSignature):
|
||||
AIS_TypeFilter(TheKind),
|
||||
mySig(TheSignature){}
|
||||
const Standard_Integer TheSignature)
|
||||
: AIS_TypeFilter(TheKind),
|
||||
mySig(TheSignature)
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean AIS_SignatureFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
|
||||
Standard_Boolean AIS_SignatureFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
|
||||
{
|
||||
Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable());
|
||||
if(IO.IsNull())
|
||||
if (IO.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
return
|
||||
(IO->Signature()==mySig &&
|
||||
IO->Type()==myKind);
|
||||
|
||||
return (IO->Signature() == mySig && IO->Type() == myKind);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <AIS_KindOfInteractive.hxx>
|
||||
class SelectMgr_EntityOwner;
|
||||
|
||||
|
||||
class AIS_SignatureFilter;
|
||||
DEFINE_STANDARD_HANDLE(AIS_SignatureFilter, AIS_TypeFilter)
|
||||
|
||||
@ -60,40 +59,23 @@ class AIS_SignatureFilter : public AIS_TypeFilter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Initializes the signature filter, adding the signature
|
||||
//! specification, aGivenSignature, to that for type,
|
||||
//! aGivenKind, in AIS_TypeFilter.
|
||||
Standard_EXPORT AIS_SignatureFilter(const AIS_KindOfInteractive aGivenKind, const Standard_Integer aGivenSignature);
|
||||
|
||||
Standard_EXPORT AIS_SignatureFilter(const AIS_KindOfInteractive aGivenKind,
|
||||
const Standard_Integer aGivenSignature);
|
||||
|
||||
//! Returns False if the transient is not an AIS_InteractiveObject.
|
||||
//! Returns False if the signature of InteractiveObject
|
||||
//! is not the same as the stored one in the filter...
|
||||
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
||||
Standard_EXPORT Standard_Boolean
|
||||
IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_SignatureFilter,AIS_TypeFilter)
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_SignatureFilter, AIS_TypeFilter)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Standard_Integer mySig;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AIS_SignatureFilter_HeaderFile
|
||||
|
@ -17,16 +17,15 @@
|
||||
#ifndef _AIS_StatusOfDetection_HeaderFile
|
||||
#define _AIS_StatusOfDetection_HeaderFile
|
||||
|
||||
|
||||
enum AIS_StatusOfDetection
|
||||
{
|
||||
AIS_SOD_Error,
|
||||
AIS_SOD_Nothing,
|
||||
AIS_SOD_AllBad,
|
||||
AIS_SOD_Selected,
|
||||
AIS_SOD_OnlyOneDetected,
|
||||
AIS_SOD_OnlyOneGood,
|
||||
AIS_SOD_SeveralGood
|
||||
AIS_SOD_Error,
|
||||
AIS_SOD_Nothing,
|
||||
AIS_SOD_AllBad,
|
||||
AIS_SOD_Selected,
|
||||
AIS_SOD_OnlyOneDetected,
|
||||
AIS_SOD_OnlyOneGood,
|
||||
AIS_SOD_SeveralGood
|
||||
};
|
||||
|
||||
#endif // _AIS_StatusOfDetection_HeaderFile
|
||||
|
@ -17,14 +17,13 @@
|
||||
#ifndef _AIS_StatusOfPick_HeaderFile
|
||||
#define _AIS_StatusOfPick_HeaderFile
|
||||
|
||||
|
||||
enum AIS_StatusOfPick
|
||||
{
|
||||
AIS_SOP_Error,
|
||||
AIS_SOP_NothingSelected,
|
||||
AIS_SOP_Removed,
|
||||
AIS_SOP_OneSelected,
|
||||
AIS_SOP_SeveralSelected
|
||||
AIS_SOP_Error,
|
||||
AIS_SOP_NothingSelected,
|
||||
AIS_SOP_Removed,
|
||||
AIS_SOP_OneSelected,
|
||||
AIS_SOP_SeveralSelected
|
||||
};
|
||||
|
||||
#endif // _AIS_StatusOfPick_HeaderFile
|
||||
|
@ -32,310 +32,265 @@
|
||||
|
||||
#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()
|
||||
: myText ("?"),
|
||||
myHasOrientation3D (Standard_False),
|
||||
myHasOwnAnchorPoint (Standard_True),
|
||||
myHasFlipping (Standard_False)
|
||||
: myText("?"),
|
||||
myHasOrientation3D(Standard_False),
|
||||
myHasOwnAnchorPoint(Standard_True),
|
||||
myHasFlipping(Standard_False)
|
||||
{
|
||||
myDrawer->SetTextAspect (new Prs3d_TextAspect());
|
||||
myDrawer->SetDisplayMode (0);
|
||||
myDrawer->SetTextAspect(new Prs3d_TextAspect());
|
||||
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;
|
||||
myDrawer->SetColor (theColor);
|
||||
myDrawer->TextAspect()->SetColor (theColor);
|
||||
myDrawer->SetColor(theColor);
|
||||
myDrawer->TextAspect()->SetColor(theColor);
|
||||
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());
|
||||
aTextColor.SetAlpha (Standard_ShortReal(1.0 - theValue));
|
||||
Quantity_ColorRGBA aTextColor(myDrawer->TextAspect()->Aspect()->Color());
|
||||
aTextColor.SetAlpha(Standard_ShortReal(1.0 - theValue));
|
||||
|
||||
Quantity_ColorRGBA aSubColor (myDrawer->TextAspect()->Aspect()->ColorSubTitle());
|
||||
aSubColor.SetAlpha (aTextColor.Alpha());
|
||||
Quantity_ColorRGBA aSubColor(myDrawer->TextAspect()->Aspect()->ColorSubTitle());
|
||||
aSubColor.SetAlpha(aTextColor.Alpha());
|
||||
|
||||
myDrawer->TextAspect()->Aspect()->SetColor (aTextColor);
|
||||
myDrawer->TextAspect()->Aspect()->SetColorSubTitle (aSubColor);
|
||||
myDrawer->SetTransparency (Standard_ShortReal(theValue));
|
||||
myDrawer->TextAspect()->Aspect()->SetColor(aTextColor);
|
||||
myDrawer->TextAspect()->Aspect()->SetColorSubTitle(aSubColor);
|
||||
myDrawer->SetTransparency(Standard_ShortReal(theValue));
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetText
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetText (const TCollection_ExtendedString& theText)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetText(const TCollection_ExtendedString& 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
|
||||
//purpose :
|
||||
// function : SetVJustification
|
||||
// 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::SetVJustification (const Graphic3d_VerticalTextAlignment theVJust)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetAngle(const Standard_Real theAngle)
|
||||
{
|
||||
myDrawer->TextAspect()->SetVerticalJustification (theVJust);
|
||||
myDrawer->TextAspect()->Aspect()->SetTextAngle(theAngle * 180.0 / M_PI);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAngle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetAngle (const Standard_Real theAngle)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetZoomable(const Standard_Boolean theIsZoomable)
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetTextAngle (theAngle * 180.0 / M_PI);
|
||||
myDrawer->TextAspect()->Aspect()->SetTextZoomable(theIsZoomable == Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetZoom
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetZoomable (const Standard_Boolean theIsZoomable)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetHeight(const Standard_Real theHeight)
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetTextZoomable (theIsZoomable == Standard_True);
|
||||
myDrawer->TextAspect()->SetHeight(theHeight);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetHeight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetHeight (const Standard_Real theHeight)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetFontAspect(const Font_FontAspect theFontAspect)
|
||||
{
|
||||
myDrawer->TextAspect()->SetHeight (theHeight);
|
||||
myDrawer->TextAspect()->Aspect()->SetTextFontAspect(theFontAspect);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAngle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetFontAspect (const Font_FontAspect theFontAspect)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetFont(Standard_CString theFont)
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetTextFontAspect (theFontAspect);
|
||||
myDrawer->TextAspect()->SetFont(theFont);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFont
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetFont (Standard_CString theFont)
|
||||
{
|
||||
myDrawer->TextAspect()->SetFont (theFont);
|
||||
}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : SetOrientation3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetOrientation3D (const gp_Ax2& theOrientation)
|
||||
void AIS_TextLabel::SetOrientation3D(const gp_Ax2& theOrientation)
|
||||
{
|
||||
myHasOrientation3D = Standard_True;
|
||||
myOrientation3D = theOrientation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetOrientation3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::UnsetOrientation3D ()
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::UnsetOrientation3D()
|
||||
{
|
||||
myHasOrientation3D = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Position
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& AIS_TextLabel::Position() const
|
||||
{
|
||||
return myOrientation3D.Location();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FontName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
const TCollection_AsciiString& AIS_TextLabel::FontName() const
|
||||
{
|
||||
return myDrawer->TextAspect()->Aspect()->Font();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FontAspect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Font_FontAspect AIS_TextLabel::FontAspect() const
|
||||
{
|
||||
return myDrawer->TextAspect()->Aspect()->GetTextFontAspect();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Orientation3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Ax2& AIS_TextLabel::Orientation3D() const
|
||||
{
|
||||
return myOrientation3D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasOrientation3D
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_TextLabel::HasOrientation3D() const
|
||||
{
|
||||
return myHasOrientation3D;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFlipping
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetFlipping (const Standard_Boolean theIsFlipping)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetFlipping(const Standard_Boolean theIsFlipping)
|
||||
{
|
||||
myHasFlipping = theIsFlipping;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasFlipping
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_TextLabel::HasFlipping() const
|
||||
{
|
||||
return myHasFlipping;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDisplayType
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::SetDisplayType(const Aspect_TypeOfDisplayText 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);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TextLabel::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
|
||||
gp_Pnt aPosition = Position();
|
||||
case 0: {
|
||||
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
|
||||
gp_Pnt aPosition = Position();
|
||||
|
||||
const Standard_Boolean isTextZoomable = anAsp->Aspect()->GetTextZoomable();
|
||||
if (myHasOrientation3D)
|
||||
{
|
||||
anAsp->Aspect()->SetTextZoomable (myHasFlipping ? Standard_True : Standard_False);
|
||||
SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, aPosition));
|
||||
anAsp->Aspect()->SetTextZoomable(myHasFlipping ? Standard_True : Standard_False);
|
||||
SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, aPosition));
|
||||
aPosition = gp::Origin();
|
||||
}
|
||||
else if (isTextZoomable
|
||||
|| TransformPersistence().IsNull()
|
||||
|| TransformPersistence()->Mode() != Graphic3d_TMF_2d)
|
||||
else if (isTextZoomable || TransformPersistence().IsNull()
|
||||
|| TransformPersistence()->Mode() != Graphic3d_TMF_2d)
|
||||
{
|
||||
Handle(Graphic3d_TransformPers) aTrsfPers =
|
||||
new Graphic3d_TransformPers (isTextZoomable ? Graphic3d_TMF_RotatePers : Graphic3d_TMF_ZoomRotatePers, aPosition);
|
||||
SetTransformPersistence (aTrsfPers);
|
||||
Handle(Graphic3d_TransformPers) aTrsfPers = new Graphic3d_TransformPers(
|
||||
isTextZoomable ? Graphic3d_TMF_RotatePers : Graphic3d_TMF_ZoomRotatePers,
|
||||
aPosition);
|
||||
SetTransformPersistence(aTrsfPers);
|
||||
aPosition = gp::Origin();
|
||||
}
|
||||
|
||||
gp_Pnt aCenterOfLabel;
|
||||
gp_Pnt aCenterOfLabel;
|
||||
Standard_Real aWidth, aHeight;
|
||||
|
||||
Standard_Boolean isInit = calculateLabelParams (aPosition, aCenterOfLabel, aWidth, aHeight);
|
||||
Standard_Boolean isInit = calculateLabelParams(aPosition, aCenterOfLabel, aWidth, aHeight);
|
||||
if (myHasOrientation3D)
|
||||
{
|
||||
if (myHasFlipping)
|
||||
{
|
||||
gp_Ax2 aFlippingAxes (aCenterOfLabel, myOrientation3D.Direction(), myOrientation3D.XDirection());
|
||||
thePrs->CurrentGroup()->SetFlippingOptions (Standard_True, aFlippingAxes);
|
||||
gp_Ax2 aFlippingAxes(aCenterOfLabel,
|
||||
myOrientation3D.Direction(),
|
||||
myOrientation3D.XDirection());
|
||||
thePrs->CurrentGroup()->SetFlippingOptions(Standard_True, aFlippingAxes);
|
||||
}
|
||||
gp_Ax2 anOrientation = myOrientation3D;
|
||||
anOrientation.SetLocation (aPosition);
|
||||
anOrientation.SetLocation(aPosition);
|
||||
Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint();
|
||||
if (myHasFlipping)
|
||||
{
|
||||
aHasOwnAnchor = Standard_False; // always not using own anchor if flipping
|
||||
}
|
||||
Handle(Graphic3d_Text) aText =
|
||||
Prs3d_Text::Draw (thePrs->CurrentGroup(), anAsp, myText, anOrientation, aHasOwnAnchor);
|
||||
aText->SetTextFormatter (myFormatter);
|
||||
Handle(Graphic3d_Text) aText =
|
||||
Prs3d_Text::Draw(thePrs->CurrentGroup(), anAsp, myText, anOrientation, aHasOwnAnchor);
|
||||
aText->SetTextFormatter(myFormatter);
|
||||
if (myHasFlipping && isInit)
|
||||
{
|
||||
thePrs->CurrentGroup()->SetFlippingOptions (Standard_False, gp_Ax2());
|
||||
thePrs->CurrentGroup()->SetFlippingOptions(Standard_False, gp_Ax2());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(Graphic3d_Text) aText =
|
||||
Prs3d_Text::Draw (thePrs->CurrentGroup(), anAsp, myText, aPosition);
|
||||
aText->SetTextFormatter (myFormatter);
|
||||
Prs3d_Text::Draw(thePrs->CurrentGroup(), anAsp, myText, aPosition);
|
||||
aText->SetTextFormatter(myFormatter);
|
||||
}
|
||||
|
||||
if (isInit)
|
||||
{
|
||||
const Standard_Real aDx = aWidth * 0.5;
|
||||
const Standard_Real aDy = aHeight * 0.5;
|
||||
gp_Trsf aLabelPlane = calculateLabelTrsf (aPosition, aCenterOfLabel);
|
||||
const Standard_Real aDx = aWidth * 0.5;
|
||||
const Standard_Real aDy = aHeight * 0.5;
|
||||
gp_Trsf aLabelPlane = calculateLabelTrsf(aPosition, aCenterOfLabel);
|
||||
|
||||
gp_Pnt aMinPnt = gp_Pnt (-aDx, -aDy, 0.0).Transformed (aLabelPlane);
|
||||
gp_Pnt aMaxPnt = 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);
|
||||
|
||||
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) aMaxPnt.X(), (float) aMaxPnt.Y(), (float) aMaxPnt.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));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this, 10);
|
||||
case 0: {
|
||||
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this, 10);
|
||||
|
||||
gp_Pnt aPosition = Position();
|
||||
if (!TransformPersistence().IsNull() && TransformPersistence()->Mode() != Graphic3d_TMF_2d)
|
||||
@ -362,66 +314,67 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
|
||||
aPosition = gp::Origin();
|
||||
}
|
||||
|
||||
gp_Pnt aCenterOfLabel;
|
||||
gp_Pnt aCenterOfLabel;
|
||||
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);
|
||||
theSelection->Add (aTextSensitive);
|
||||
Handle(Select3D_SensitivePoint) aTextSensitive =
|
||||
new Select3D_SensitivePoint(anEntityOwner, aPosition);
|
||||
theSelection->Add(aTextSensitive);
|
||||
break;
|
||||
}
|
||||
|
||||
const Standard_Real aDx = aWidth * 0.5;
|
||||
const Standard_Real aDy = aHeight * 0.5;
|
||||
gp_Trsf aLabelPlane = calculateLabelTrsf (aPosition, aCenterOfLabel);
|
||||
const Standard_Real aDx = aWidth * 0.5;
|
||||
const Standard_Real aDy = aHeight * 0.5;
|
||||
gp_Trsf aLabelPlane = calculateLabelTrsf(aPosition, aCenterOfLabel);
|
||||
|
||||
// sensitive planar rectangle for text
|
||||
TColgp_Array1OfPnt aRectanglePoints (1, 5);
|
||||
aRectanglePoints.ChangeValue (1) = 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 (4) = gp_Pnt ( aDx, -aDy, 0.0).Transformed (aLabelPlane);
|
||||
aRectanglePoints.ChangeValue (5) = aRectanglePoints.Value (1);
|
||||
TColgp_Array1OfPnt aRectanglePoints(1, 5);
|
||||
aRectanglePoints.ChangeValue(1) = 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(4) = gp_Pnt(aDx, -aDy, 0.0).Transformed(aLabelPlane);
|
||||
aRectanglePoints.ChangeValue(5) = aRectanglePoints.Value(1);
|
||||
|
||||
Handle(Select3D_SensitiveFace) aTextSensitive =
|
||||
new Select3D_SensitiveFace (anEntityOwner, aRectanglePoints, Select3D_TOS_INTERIOR);
|
||||
theSelection->Add (aTextSensitive);
|
||||
new Select3D_SensitiveFace(anEntityOwner, aRectanglePoints, Select3D_TOS_INTERIOR);
|
||||
theSelection->Add(aTextSensitive);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : calculateLabelParams
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
|
||||
gp_Pnt& theCenterOfLabel,
|
||||
Standard_Real& theWidth,
|
||||
Standard_Real& theHeight) const
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean AIS_TextLabel::calculateLabelParams(const gp_Pnt& thePosition,
|
||||
gp_Pnt& theCenterOfLabel,
|
||||
Standard_Real& theWidth,
|
||||
Standard_Real& theHeight) const
|
||||
{
|
||||
// Get width and height of text
|
||||
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
|
||||
const Graphic3d_RenderingParams& aRendParams = GetContext()->CurrentViewer()->DefaultRenderingParams();
|
||||
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
|
||||
const Graphic3d_RenderingParams& aRendParams =
|
||||
GetContext()->CurrentViewer()->DefaultRenderingParams();
|
||||
Font_FTFontParams aFontParams;
|
||||
aFontParams.PointSize = (unsigned int) anAsp->Height();
|
||||
aFontParams.Resolution = aRendParams.Resolution;
|
||||
aFontParams.PointSize = (unsigned int)anAsp->Height();
|
||||
aFontParams.Resolution = aRendParams.Resolution;
|
||||
aFontParams.FontHinting = aRendParams.FontHinting;
|
||||
|
||||
Handle(Font_FTFont) aFont = Font_FTFont::FindAndCreate (anAsp->Aspect()->Font(),
|
||||
anAsp->Aspect()->GetTextFontAspect(),
|
||||
aFontParams);
|
||||
Handle(Font_FTFont) aFont = Font_FTFont::FindAndCreate(anAsp->Aspect()->Font(),
|
||||
anAsp->Aspect()->GetTextFontAspect(),
|
||||
aFontParams);
|
||||
if (aFont.IsNull())
|
||||
{
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const NCollection_String aText (myText.ToExtString());
|
||||
Font_Rect aBndBox = aFont->BoundingBox (aText, anAsp->HorizontalJustification(), anAsp->VerticalJustification());
|
||||
theWidth = Abs (aBndBox.Width());
|
||||
theHeight = Abs (aBndBox.Height());
|
||||
const NCollection_String aText(myText.ToExtString());
|
||||
Font_Rect aBndBox =
|
||||
aFont->BoundingBox(aText, anAsp->HorizontalJustification(), anAsp->VerticalJustification());
|
||||
theWidth = Abs(aBndBox.Width());
|
||||
theHeight = Abs(aBndBox.Height());
|
||||
|
||||
theCenterOfLabel = thePosition;
|
||||
if (anAsp->VerticalJustification() == Graphic3d_VTA_BOTTOM)
|
||||
@ -444,22 +397,20 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : calculateLabelTrsf
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Trsf AIS_TextLabel::calculateLabelTrsf (const gp_Pnt& thePosition, gp_Pnt& theCenterOfLabel) const
|
||||
//=================================================================================================
|
||||
|
||||
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 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;
|
||||
anOrientation.Rotate (aRotAxis, anAngle);
|
||||
theCenterOfLabel.Rotate (aRotAxis, anAngle);
|
||||
anOrientation.Rotate(aRotAxis, anAngle);
|
||||
theCenterOfLabel.Rotate(aRotAxis, anAngle);
|
||||
|
||||
gp_Trsf aLabelPlane;
|
||||
aLabelPlane.SetTransformation (anOrientation, gp::XOY());
|
||||
aLabelPlane.SetTranslationPart (theCenterOfLabel.XYZ());
|
||||
aLabelPlane.SetTransformation(anOrientation, gp::XOY());
|
||||
aLabelPlane.SetTranslationPart(theCenterOfLabel.XYZ());
|
||||
|
||||
return aLabelPlane;
|
||||
}
|
||||
|
@ -30,57 +30,59 @@ class Font_TextFormatter;
|
||||
class AIS_TextLabel : public AIS_InteractiveObject
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
Standard_EXPORT AIS_TextLabel();
|
||||
|
||||
//! Return TRUE for supported display mode.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
|
||||
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode == 0;
|
||||
}
|
||||
|
||||
//! Setup color of entire text.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
|
||||
//! 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.
|
||||
virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency (0.0); }
|
||||
virtual void UnsetTransparency() Standard_OVERRIDE { SetTransparency(0.0); }
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void SetText (const TCollection_ExtendedString& theText);
|
||||
Standard_EXPORT void SetText(const TCollection_ExtendedString& theText);
|
||||
|
||||
//! Setup position.
|
||||
Standard_EXPORT void SetPosition (const gp_Pnt& thePosition);
|
||||
Standard_EXPORT void SetPosition(const gp_Pnt& thePosition);
|
||||
|
||||
//! Setup horizontal justification.
|
||||
Standard_EXPORT void SetHJustification (const Graphic3d_HorizontalTextAlignment theHJust);
|
||||
Standard_EXPORT void SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust);
|
||||
|
||||
//! Setup vertical justification.
|
||||
Standard_EXPORT void SetVJustification (const Graphic3d_VerticalTextAlignment theVJust);
|
||||
Standard_EXPORT void SetVJustification(const Graphic3d_VerticalTextAlignment theVJust);
|
||||
|
||||
//! Setup angle.
|
||||
Standard_EXPORT void SetAngle (const Standard_Real theAngle);
|
||||
Standard_EXPORT void SetAngle(const Standard_Real theAngle);
|
||||
|
||||
//! Setup zoomable property.
|
||||
Standard_EXPORT void SetZoomable (const Standard_Boolean theIsZoomable);
|
||||
Standard_EXPORT void SetZoomable(const Standard_Boolean theIsZoomable);
|
||||
|
||||
//! Setup height.
|
||||
Standard_EXPORT void SetHeight (const Standard_Real theHeight);
|
||||
Standard_EXPORT void SetHeight(const Standard_Real theHeight);
|
||||
|
||||
//! Setup font aspect.
|
||||
Standard_EXPORT void SetFontAspect (const Font_FontAspect theFontAspect);
|
||||
Standard_EXPORT void SetFontAspect(const Font_FontAspect theFontAspect);
|
||||
|
||||
//! Setup font.
|
||||
Standard_EXPORT void SetFont (Standard_CString theFont);
|
||||
Standard_EXPORT void SetFont(Standard_CString theFont);
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void UnsetOrientation3D ();
|
||||
Standard_EXPORT void UnsetOrientation3D();
|
||||
|
||||
//! Returns position.
|
||||
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.
|
||||
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;
|
||||
|
||||
@ -108,7 +110,10 @@ public:
|
||||
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
|
||||
|
||||
//! Set flag if text uses position as point of attach
|
||||
void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
|
||||
void SetOwnAnchorPoint(const Standard_Boolean theOwnAnchorPoint)
|
||||
{
|
||||
myHasOwnAnchorPoint = theOwnAnchorPoint;
|
||||
}
|
||||
|
||||
//! Define the display type of the text.
|
||||
//!
|
||||
@ -117,41 +122,43 @@ public:
|
||||
//! TODT_DEKALE The text is displayed with a 3D style.
|
||||
//! TODT_BLEND The text is displayed in XOR.
|
||||
//! 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
|
||||
//! 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; }
|
||||
|
||||
//! Setup text formatter for presentation. It's empty by default.
|
||||
void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
|
||||
void SetTextFormatter(const Handle(Font_TextFormatter)& theFormatter)
|
||||
{
|
||||
myFormatter = theFormatter;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Compute
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& theprsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection
|
||||
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;
|
||||
|
||||
//! Calculate label center, width and height
|
||||
Standard_EXPORT Standard_Boolean calculateLabelParams (const gp_Pnt& thePosition,
|
||||
gp_Pnt& theCenterOfLabel,
|
||||
Standard_Real& theWidth,
|
||||
Standard_Real& theHeight) const;
|
||||
Standard_EXPORT Standard_Boolean calculateLabelParams(const gp_Pnt& thePosition,
|
||||
gp_Pnt& theCenterOfLabel,
|
||||
Standard_Real& theWidth,
|
||||
Standard_Real& theHeight) const;
|
||||
|
||||
//! Calculate label transformation
|
||||
Standard_EXPORT gp_Trsf calculateLabelTrsf (const gp_Pnt& thePosition,
|
||||
gp_Pnt& theCenterOfLabel) const;
|
||||
Standard_EXPORT gp_Trsf calculateLabelTrsf(const gp_Pnt& thePosition,
|
||||
gp_Pnt& theCenterOfLabel) const;
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Font_TextFormatter) myFormatter;
|
||||
|
||||
TCollection_ExtendedString myText;
|
||||
@ -161,10 +168,8 @@ protected:
|
||||
Standard_Boolean myHasFlipping;
|
||||
|
||||
public:
|
||||
|
||||
//! CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject)
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)
|
||||
|
@ -35,46 +35,40 @@
|
||||
#include <StdPrs_ToolTriangulatedShape.hxx>
|
||||
#include <StdPrs_WFShape.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_TexturedShape, AIS_Shape)
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_TexturedShape,AIS_Shape)
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_TexturedShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_TexturedShape::AIS_TexturedShape (const TopoDS_Shape& theShape)
|
||||
: AIS_Shape (theShape),
|
||||
myPredefTexture (Graphic3d_NameOfTexture2D(0)),
|
||||
myToMapTexture (Standard_True),
|
||||
myModulate (Standard_True),
|
||||
myIsCustomOrigin (Standard_True),
|
||||
myToRepeat (Standard_True),
|
||||
myToScale (Standard_True),
|
||||
myToShowTriangles (Standard_False)
|
||||
AIS_TexturedShape::AIS_TexturedShape(const TopoDS_Shape& theShape)
|
||||
: AIS_Shape(theShape),
|
||||
myPredefTexture(Graphic3d_NameOfTexture2D(0)),
|
||||
myToMapTexture(Standard_True),
|
||||
myModulate(Standard_True),
|
||||
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();
|
||||
|
||||
if (theTextureFileName.IsIntegerValue())
|
||||
{
|
||||
const Standard_Integer aValue = theTextureFileName.IntegerValue();
|
||||
if (aValue < Graphic3d_Texture2D::NumberOfTextures()
|
||||
&& aValue >= 0)
|
||||
if (aValue < Graphic3d_Texture2D::NumberOfTextures() && aValue >= 0)
|
||||
{
|
||||
myPredefTexture = Graphic3d_NameOfTexture2D (aValue);
|
||||
myPredefTexture = Graphic3d_NameOfTexture2D(aValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::SendFail (TCollection_AsciiString ("Error: texture with ID ") + theTextureFileName
|
||||
+ " is undefined. Texture 0 will be used instead.");
|
||||
myPredefTexture = Graphic3d_NameOfTexture2D (0);
|
||||
Message::SendFail(TCollection_AsciiString("Error: texture with ID ") + theTextureFileName
|
||||
+ " is undefined. Texture 0 will be used instead.");
|
||||
myPredefTexture = Graphic3d_NameOfTexture2D(0);
|
||||
}
|
||||
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;
|
||||
myTexturePixMap = theTexturePixMap;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextureRepeat
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::SetTextureRepeat (const Standard_Boolean theToRepeat,
|
||||
const Standard_Real theURepeat,
|
||||
const Standard_Real theVRepeat)
|
||||
void AIS_TexturedShape::SetTextureRepeat(const Standard_Boolean theToRepeat,
|
||||
const Standard_Real theURepeat,
|
||||
const Standard_Real theVRepeat)
|
||||
{
|
||||
myToRepeat = theToRepeat;
|
||||
myUVRepeat.SetCoord (theURepeat, theVRepeat);
|
||||
myUVRepeat.SetCoord(theURepeat, theVRepeat);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextureMapOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::SetTextureMapOn()
|
||||
{
|
||||
myToMapTexture = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextureMapOff
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::SetTextureMapOff()
|
||||
{
|
||||
myToMapTexture = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextureOrigin
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::SetTextureOrigin (const Standard_Boolean theToSetTextureOrigin,
|
||||
const Standard_Real theUOrigin,
|
||||
const Standard_Real theVOrigin)
|
||||
void AIS_TexturedShape::SetTextureOrigin(const Standard_Boolean theToSetTextureOrigin,
|
||||
const Standard_Real theUOrigin,
|
||||
const Standard_Real theVOrigin)
|
||||
{
|
||||
myIsCustomOrigin = theToSetTextureOrigin;
|
||||
myUVOrigin.SetCoord (theUOrigin, theVOrigin);
|
||||
myUVOrigin.SetCoord(theUOrigin, theVOrigin);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextureScale
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::SetTextureScale (const Standard_Boolean theToSetTextureScale,
|
||||
const Standard_Real theScaleU,
|
||||
const Standard_Real theScaleV)
|
||||
void AIS_TexturedShape::SetTextureScale(const Standard_Boolean theToSetTextureScale,
|
||||
const Standard_Real theScaleU,
|
||||
const Standard_Real theScaleV)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : EnableTextureModulate
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::EnableTextureModulate()
|
||||
{
|
||||
myModulate = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DisableTextureModulate
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::DisableTextureModulate()
|
||||
{
|
||||
myModulate = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::SetColor (const Quantity_Color& theColor)
|
||||
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)
|
||||
{
|
||||
updateAttributes (aPrsIter.Value());
|
||||
updateAttributes(aPrsIter.Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::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);
|
||||
for (PrsMgr_Presentations::Iterator aPrsIter (Presentations()); aPrsIter.More(); aPrsIter.Next())
|
||||
AIS_Shape::SetMaterial(theMat);
|
||||
for (PrsMgr_Presentations::Iterator aPrsIter(Presentations()); aPrsIter.More(); aPrsIter.Next())
|
||||
{
|
||||
if (aPrsIter.Value()->Mode() == 3)
|
||||
{
|
||||
updateAttributes (aPrsIter.Value());
|
||||
updateAttributes(aPrsIter.Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::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)
|
||||
{
|
||||
updateAttributes (aPrsIter.Value());
|
||||
updateAttributes(aPrsIter.Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateAttributes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
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())
|
||||
{
|
||||
Standard_Integer aMode;
|
||||
Standard_Integer aMode;
|
||||
Standard_ShortReal aFactor, aUnits;
|
||||
PolygonOffsets (aMode, aFactor, aUnits);
|
||||
myAspect->SetPolygonOffsets (aMode, aFactor, aUnits);
|
||||
PolygonOffsets(aMode, aFactor, aUnits);
|
||||
myAspect->SetPolygonOffsets(aMode, aFactor, aUnits);
|
||||
}
|
||||
|
||||
Standard_Boolean hasTexture = Standard_False;
|
||||
@ -278,17 +229,17 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
|
||||
TCollection_AsciiString aTextureDesc;
|
||||
if (!myTexturePixMap.IsNull())
|
||||
{
|
||||
myTexture = new Graphic3d_Texture2D (myTexturePixMap);
|
||||
myTexture = new Graphic3d_Texture2D(myTexturePixMap);
|
||||
aTextureDesc = " (custom image)";
|
||||
}
|
||||
else if (myPredefTexture != Graphic3d_NOT_2D_UNKNOWN)
|
||||
{
|
||||
myTexture = new Graphic3d_Texture2D (myPredefTexture);
|
||||
myTexture = new Graphic3d_Texture2D(myPredefTexture);
|
||||
aTextureDesc = TCollection_AsciiString(" (predefined texture ") + myTexture->GetId() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
myTexture = new Graphic3d_Texture2D (myTextureFile.ToCString());
|
||||
myTexture = new Graphic3d_Texture2D(myTextureFile.ToCString());
|
||||
aTextureDesc = TCollection_AsciiString(" (") + myTextureFile + ")";
|
||||
}
|
||||
|
||||
@ -307,11 +258,12 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::SendFail (TCollection_AsciiString ("Error: texture can not be loaded ") + aTextureDesc);
|
||||
Message::SendFail(TCollection_AsciiString("Error: texture can not be loaded ")
|
||||
+ aTextureDesc);
|
||||
}
|
||||
}
|
||||
|
||||
myAspect->SetTextureMap (myTexture);
|
||||
myAspect->SetTextureMap(myTexture);
|
||||
if (hasTexture)
|
||||
{
|
||||
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
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt(thePrs->Groups()); aGroupIt.More();
|
||||
aGroupIt.Next())
|
||||
{
|
||||
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
|
||||
aGroup->SetGroupPrimitivesAspect (myAspect);
|
||||
aGroup->SetGroupPrimitivesAspect(myAspect);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_TexturedShape::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (myshape.IsNull()
|
||||
|| (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
|
||||
if (myshape.IsNull() || (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (myshape.ShapeType() >= TopAbs_WIRE
|
||||
&& myshape.ShapeType() <= TopAbs_VERTEX)
|
||||
if (myshape.ShapeType() >= TopAbs_WIRE && myshape.ShapeType() <= TopAbs_VERTEX)
|
||||
{
|
||||
// TopAbs_WIRE -> 7, TopAbs_EDGE -> 8, TopAbs_VERTEX -> 9 (Graphic3d_DisplayPriority_Highlight)
|
||||
const Standard_Integer aPrior = (Standard_Integer )Graphic3d_DisplayPriority_Above1
|
||||
+ (Standard_Integer )myshape.ShapeType() - TopAbs_WIRE;
|
||||
thePrs->SetVisual (Graphic3d_TOS_ALL);
|
||||
thePrs->SetDisplayPriority ((Graphic3d_DisplayPriority )aPrior);
|
||||
const Standard_Integer aPrior = (Standard_Integer)Graphic3d_DisplayPriority_Above1
|
||||
+ (Standard_Integer)myshape.ShapeType() - TopAbs_WIRE;
|
||||
thePrs->SetVisual(Graphic3d_TOS_ALL);
|
||||
thePrs->SetDisplayPriority((Graphic3d_DisplayPriority)aPrior);
|
||||
}
|
||||
|
||||
if (IsInfinite())
|
||||
{
|
||||
thePrs->SetInfiniteState (Standard_True);
|
||||
thePrs->SetInfiniteState(Standard_True);
|
||||
}
|
||||
|
||||
switch (theMode)
|
||||
{
|
||||
case AIS_WireFrame:
|
||||
{
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
case AIS_WireFrame: {
|
||||
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
|
||||
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
|
||||
break;
|
||||
}
|
||||
case AIS_Shaded:
|
||||
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)
|
||||
{
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsInfinite())
|
||||
{
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
|
||||
break;
|
||||
}
|
||||
try
|
||||
@ -395,16 +343,18 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
OCC_CATCH_SIGNALS
|
||||
if (theMode == AIS_Shaded)
|
||||
{
|
||||
StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer);
|
||||
StdPrs_ShadedShape::Add(thePrs, myshape, myDrawer);
|
||||
}
|
||||
else
|
||||
{
|
||||
StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
|
||||
Standard_True,
|
||||
myIsCustomOrigin ? myUVOrigin : gp_Pnt2d (0.0, 0.0),
|
||||
myUVRepeat,
|
||||
myToScale ? myUVScale : gp_Pnt2d (1.0, 1.0));
|
||||
updateAttributes (thePrs);
|
||||
StdPrs_ShadedShape::Add(thePrs,
|
||||
myshape,
|
||||
myDrawer,
|
||||
Standard_True,
|
||||
myIsCustomOrigin ? myUVOrigin : gp_Pnt2d(0.0, 0.0),
|
||||
myUVRepeat,
|
||||
myToScale ? myUVScale : gp_Pnt2d(1.0, 1.0));
|
||||
updateAttributes(thePrs);
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure const&)
|
||||
@ -412,7 +362,7 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout << "AIS_TexturedShape::Compute() in ShadingMode failed \n";
|
||||
#endif
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -420,11 +370,11 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
{
|
||||
if (IsInfinite())
|
||||
{
|
||||
StdPrs_WFShape::Add (thePrs, myshape, myDrawer);
|
||||
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Prs3d_BndBox::Add (thePrs, BoundingBox(), myDrawer);
|
||||
Prs3d_BndBox::Add(thePrs, BoundingBox(), myDrawer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ class Graphic3d_AspectFillArea3d;
|
||||
class Graphic3d_Texture2D;
|
||||
|
||||
//! This class allows to map textures on shapes.
|
||||
//! Presentations modes AIS_WireFrame (0) and AIS_Shaded (1) behave in the same manner as in AIS_Shape,
|
||||
//! whilst new modes 2 (bounding box) and 3 (texture mapping) extends it functionality.
|
||||
//! Presentations modes AIS_WireFrame (0) and AIS_Shaded (1) behave in the same manner as in
|
||||
//! AIS_Shape, whilst new modes 2 (bounding box) and 3 (texture mapping) extends it functionality.
|
||||
//!
|
||||
//! The texture itself is parametrized in (0,1)x(0,1).
|
||||
//! Each face of a shape located in UV space is provided with these parameters:
|
||||
@ -49,20 +49,22 @@ class AIS_TexturedShape : public AIS_Shape
|
||||
{
|
||||
|
||||
public: //! @name main methods
|
||||
|
||||
//! 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.
|
||||
//! The accepted file types are those used in Image_AlienPixMap with extensions such as rgb, png, jpg and more.
|
||||
//! To specify the standard predefined texture, the <theTextureFileName> should contain integer - the Graphic3d_NameOfTexture2D enumeration index.
|
||||
//! Sets the texture source. <theTextureFileName> can specify path to texture image or one of the
|
||||
//! standard predefined textures. The accepted file types are those used in Image_AlienPixMap with
|
||||
//! extensions such as rgb, png, jpg and more. To specify the standard predefined texture, the
|
||||
//! <theTextureFileName> should contain integer - the Graphic3d_NameOfTexture2D enumeration index.
|
||||
//! Setting texture source using this method resets the source pixmap (if was set previously).
|
||||
Standard_EXPORT virtual void SetTextureFileName (const TCollection_AsciiString& theTextureFileName);
|
||||
Standard_EXPORT virtual void SetTextureFileName(
|
||||
const TCollection_AsciiString& theTextureFileName);
|
||||
|
||||
//! Sets the texture source. <theTexturePixMap> specifies image data.
|
||||
//! Please note that the data should be in Bottom-Up order, the flag of Image_PixMap::IsTopDown() will be ignored by graphic driver.
|
||||
//! Setting texture source using this method resets the source by filename (if was set previously).
|
||||
Standard_EXPORT virtual void SetTexturePixMap (const Handle(Image_PixMap)& theTexturePixMap);
|
||||
//! Please note that the data should be in Bottom-Up order, the flag of Image_PixMap::IsTopDown()
|
||||
//! will be ignored by graphic driver. Setting texture source using this method resets the source
|
||||
//! by filename (if was set previously).
|
||||
Standard_EXPORT virtual void SetTexturePixMap(const Handle(Image_PixMap)& theTexturePixMap);
|
||||
|
||||
//! @return flag to control texture mapping (for presentation mode 3)
|
||||
Standard_Boolean TextureMapState() const { return myToMapTexture; }
|
||||
@ -80,10 +82,10 @@ public: //! @name main methods
|
||||
const Handle(Image_PixMap)& TexturePixMap() const { return myTexturePixMap; }
|
||||
|
||||
public: //! @name methods to alter texture mapping properties
|
||||
|
||||
//! Use this method to display the textured shape without recomputing the whole presentation.
|
||||
//! Use this method when ONLY the texture content has been changed.
|
||||
//! If other parameters (ie: scale factors, texture origin, texture repeat...) have changed, the whole presentation has to be recomputed:
|
||||
//! If other parameters (ie: scale factors, texture origin, texture repeat...) have changed, the
|
||||
//! whole presentation has to be recomputed:
|
||||
//! @code
|
||||
//! if (myShape->DisplayMode() == 3)
|
||||
//! {
|
||||
@ -98,13 +100,14 @@ public: //! @name methods to alter texture mapping properties
|
||||
Standard_EXPORT void UpdateAttributes();
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
//! Sets the material aspect.
|
||||
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theAspect)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Removes settings for material aspect.
|
||||
Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
|
||||
@ -124,12 +127,13 @@ public: //! @name methods to alter texture mapping properties
|
||||
//! @return texture repeat V value
|
||||
Standard_Real VRepeat() const { return myUVRepeat.Y(); }
|
||||
|
||||
//! Sets the number of occurrences of the texture on each face. The texture itself is parameterized in (0,1) by (0,1).
|
||||
//! Each face of the shape to be textured is parameterized in UV space (Umin,Umax) by (Vmin,Vmax).
|
||||
//! If RepeatYN is set to false, texture coordinates are clamped in the range (0,1)x(0,1) of the face.
|
||||
Standard_EXPORT void SetTextureRepeat (const Standard_Boolean theToRepeat,
|
||||
const Standard_Real theURepeat = 1.0,
|
||||
const Standard_Real theVRepeat = 1.0);
|
||||
//! Sets the number of occurrences of the texture on each face. The texture itself is
|
||||
//! parameterized in (0,1) by (0,1). Each face of the shape to be textured is parameterized in UV
|
||||
//! space (Umin,Umax) by (Vmin,Vmax). If RepeatYN is set to false, texture coordinates are clamped
|
||||
//! in the range (0,1)x(0,1) of the face.
|
||||
Standard_EXPORT void SetTextureRepeat(const Standard_Boolean theToRepeat,
|
||||
const Standard_Real theURepeat = 1.0,
|
||||
const Standard_Real theVRepeat = 1.0);
|
||||
|
||||
//! @return true if texture UV origin has been modified
|
||||
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)
|
||||
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)
|
||||
Standard_EXPORT void SetTextureOrigin (const Standard_Boolean theToSetTextureOrigin,
|
||||
const Standard_Real theUOrigin = 0.0,
|
||||
const Standard_Real theVOrigin = 0.0);
|
||||
//! Use this method to change the origin of the texture. The texel (0,0) will be mapped to the
|
||||
//! surface (UOrigin,VOrigin)
|
||||
Standard_EXPORT void SetTextureOrigin(const Standard_Boolean theToSetTextureOrigin,
|
||||
const Standard_Real theUOrigin = 0.0,
|
||||
const Standard_Real theVOrigin = 0.0);
|
||||
|
||||
//! @return true if scale factor should be applied to texture mapping
|
||||
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.
|
||||
//! 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.
|
||||
Standard_EXPORT void SetTextureScale (const Standard_Boolean theToSetTextureScale,
|
||||
const Standard_Real theScaleU = 1.0,
|
||||
const Standard_Real theScaleV = 1.0);
|
||||
Standard_EXPORT void SetTextureScale(const Standard_Boolean theToSetTextureScale,
|
||||
const Standard_Real theScaleU = 1.0,
|
||||
const Standard_Real theScaleV = 1.0);
|
||||
|
||||
//! @return true if displaying of triangles is requested
|
||||
Standard_Boolean ShowTriangles() const { return myToShowTriangles; }
|
||||
|
||||
//! 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
|
||||
Standard_Boolean TextureModulate() const { return myModulate; }
|
||||
|
||||
//! Return true if specified display mode is supported (extends AIS_Shape with Display Mode 3).
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode >= 0 && theMode <= 3; }
|
||||
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
|
||||
{
|
||||
return theMode >= 0 && theMode <= 3;
|
||||
}
|
||||
|
||||
protected: //! @name overridden methods
|
||||
|
||||
//! Compute presentation with texture mapping support.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
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
|
||||
|
||||
Handle(Graphic3d_Texture2D) myTexture;
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
||||
|
||||
protected: //! @name texture source fields
|
||||
|
||||
Handle(Image_PixMap) myTexturePixMap;
|
||||
TCollection_AsciiString myTextureFile;
|
||||
Graphic3d_NameOfTexture2D myPredefTexture;
|
||||
Handle(Image_PixMap) myTexturePixMap;
|
||||
TCollection_AsciiString myTextureFile;
|
||||
Graphic3d_NameOfTexture2D myPredefTexture;
|
||||
|
||||
protected: //! @name texture mapping properties
|
||||
|
||||
Standard_Boolean myToMapTexture;
|
||||
Standard_Boolean myModulate;
|
||||
Standard_Boolean myIsCustomOrigin;
|
||||
Standard_Boolean myToRepeat;
|
||||
Standard_Boolean myToScale;
|
||||
Standard_Boolean myToShowTriangles;
|
||||
Standard_Boolean myToMapTexture;
|
||||
Standard_Boolean myModulate;
|
||||
Standard_Boolean myIsCustomOrigin;
|
||||
Standard_Boolean myToRepeat;
|
||||
Standard_Boolean myToScale;
|
||||
Standard_Boolean myToShowTriangles;
|
||||
|
||||
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
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include <Graphic3d_AspectFillArea3d.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)
|
||||
{
|
||||
@ -35,15 +34,13 @@ AIS_Triangulation::AIS_Triangulation(const Handle(Poly_Triangulation)& Triangula
|
||||
myFlagColor = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTransparency
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Triangulation::SetTransparency(const Standard_Real theValue)
|
||||
{
|
||||
if (!myDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||
if (myDrawer->HasLink())
|
||||
{
|
||||
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
|
||||
@ -51,47 +48,43 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
|
||||
}
|
||||
|
||||
// override transparency
|
||||
myDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
|
||||
myDrawer->SetTransparency ((Standard_ShortReal )theValue);
|
||||
myDrawer->ShadingAspect()->SetTransparency(theValue, myCurrentFacingModel);
|
||||
myDrawer->SetTransparency((Standard_ShortReal)theValue);
|
||||
|
||||
updatePresentation();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetTransparency
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Triangulation::UnsetTransparency()
|
||||
{
|
||||
myDrawer->SetTransparency (0.0f);
|
||||
myDrawer->SetTransparency(0.0f);
|
||||
if (!myDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (HasColor() || HasMaterial())
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
|
||||
myDrawer->ShadingAspect()->SetTransparency(0.0, myCurrentFacingModel);
|
||||
}
|
||||
|
||||
updatePresentation();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : updatePresentation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Triangulation::updatePresentation()
|
||||
{
|
||||
if (HasVertexColors())
|
||||
{
|
||||
SetToUpdate (AIS_WireFrame);
|
||||
SetToUpdate(AIS_WireFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
// modify shading presentation without re-computation
|
||||
const PrsMgr_Presentations& aPrsList = Presentations();
|
||||
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)
|
||||
{
|
||||
@ -99,22 +92,21 @@ void AIS_Triangulation::updatePresentation()
|
||||
}
|
||||
|
||||
const Handle(Prs3d_Presentation)& aPrs = aPrsIter.Value();
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt(aPrs->Groups()); aGroupIt.More();
|
||||
aGroupIt.Next())
|
||||
{
|
||||
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
|
||||
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
|
||||
aGroup->SetGroupPrimitivesAspect(anAreaAsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager)&,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode != 0)
|
||||
{
|
||||
@ -124,9 +116,12 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
Standard_Boolean hasVNormals = myTriangulation->HasNormals();
|
||||
Standard_Boolean hasVColors = HasVertexColors();
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (myNbNodes, myNbTriangles * 3,
|
||||
hasVNormals, hasVColors, Standard_False);
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
|
||||
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles(myNbNodes,
|
||||
myNbTriangles * 3,
|
||||
hasVNormals,
|
||||
hasVColors,
|
||||
Standard_False);
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = myDrawer->ShadingAspect()->Aspect();
|
||||
|
||||
const Standard_Real anAmbient = 1.0;
|
||||
@ -138,17 +133,18 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
||||
const TColStd_Array1OfInteger& colors = myColor->Array1();
|
||||
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter)
|
||||
{
|
||||
anArray->AddVertex (myTriangulation->Node (aNodeIter), attenuateColor (colors[aNodeIter], anAmbient));
|
||||
myTriangulation->Normal (aNodeIter, aNormal);
|
||||
anArray->SetVertexNormal (aNodeIter, aNormal.x(), aNormal.y(), aNormal.z());
|
||||
anArray->AddVertex(myTriangulation->Node(aNodeIter),
|
||||
attenuateColor(colors[aNodeIter], anAmbient));
|
||||
myTriangulation->Normal(aNodeIter, aNormal);
|
||||
anArray->SetVertexNormal(aNodeIter, aNormal.x(), aNormal.y(), aNormal.z());
|
||||
}
|
||||
}
|
||||
else // !hasVColors
|
||||
{
|
||||
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter)
|
||||
{
|
||||
anArray->AddVertex (myTriangulation->Node (aNodeIter));
|
||||
myTriangulation->Normal (aNodeIter, aNormal);
|
||||
anArray->AddVertex(myTriangulation->Node(aNodeIter));
|
||||
myTriangulation->Normal(aNodeIter, aNormal);
|
||||
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();
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
myTriangulation->Triangle (aTriIter).Get (aTriIndices[0], aTriIndices[1], aTriIndices[2]);
|
||||
anArray->AddEdge (aTriIndices[0]);
|
||||
anArray->AddEdge (aTriIndices[1]);
|
||||
anArray->AddEdge (aTriIndices[2]);
|
||||
myTriangulation->Triangle(aTriIter).Get(aTriIndices[0], aTriIndices[1], aTriIndices[2]);
|
||||
anArray->AddEdge(aTriIndices[0]);
|
||||
anArray->AddEdge(aTriIndices[1]);
|
||||
anArray->AddEdge(aTriIndices[2]);
|
||||
}
|
||||
aGroup->SetPrimitivesAspect (anAspect);
|
||||
aGroup->AddPrimitiveArray (anArray);
|
||||
aGroup->SetPrimitivesAspect(anAspect);
|
||||
aGroup->AddPrimitiveArray(anArray);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void AIS_Triangulation::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
|
||||
const Standard_Integer /*aMode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose : Set the color for each node.
|
||||
// function : SetColor
|
||||
// purpose : Set the color for each node.
|
||||
// Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
|
||||
// Order of color components is essential for further usage by OpenGL
|
||||
//=======================================================================
|
||||
void AIS_Triangulation::SetColors(const Handle(TColStd_HArray1OfInteger)& aColor)
|
||||
{
|
||||
myFlagColor = 1;
|
||||
myColor = aColor;
|
||||
myColor = aColor;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose : Get the color for each node.
|
||||
// function : GetColor
|
||||
// purpose : Get the color for each node.
|
||||
// Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
|
||||
// Order of color components is essential for further usage by OpenGL
|
||||
//=======================================================================
|
||||
@ -218,39 +212,36 @@ Handle(TColStd_HArray1OfInteger) AIS_Triangulation::GetColors() const
|
||||
return myColor;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Triangulation::SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation)
|
||||
{
|
||||
myTriangulation = aTriangulation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const{
|
||||
//=================================================================================================
|
||||
|
||||
Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const
|
||||
{
|
||||
return myTriangulation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AttenuateColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Graphic3d_Vec4ub AIS_Triangulation::attenuateColor (const Standard_Integer theColor,
|
||||
const Standard_Real theComposition)
|
||||
//=================================================================================================
|
||||
|
||||
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.
|
||||
Standard_Byte anAlpha = IsTransparent() ? static_cast<Standard_Byte> (255.0 - myDrawer->ShadingAspect()->Aspect()->FrontMaterial().Transparency() * 255.0)
|
||||
: 255;
|
||||
Standard_Byte anAlpha =
|
||||
IsTransparent()
|
||||
? static_cast<Standard_Byte>(
|
||||
255.0 - myDrawer->ShadingAspect()->Aspect()->FrontMaterial().Transparency() * 255.0)
|
||||
: 255;
|
||||
|
||||
return Graphic3d_Vec4ub ((Standard_Byte)(theComposition * anRgbx[0]),
|
||||
(Standard_Byte)(theComposition * anRgbx[1]),
|
||||
(Standard_Byte)(theComposition * anRgbx[2]),
|
||||
anAlpha);
|
||||
return Graphic3d_Vec4ub((Standard_Byte)(theComposition * anRgbx[0]),
|
||||
(Standard_Byte)(theComposition * anRgbx[1]),
|
||||
(Standard_Byte)(theComposition * anRgbx[2]),
|
||||
anAlpha);
|
||||
}
|
||||
|
@ -31,64 +31,57 @@ class AIS_Triangulation : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Constructs the Triangulation display object
|
||||
Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
|
||||
|
||||
|
||||
//! Set the color for each node.
|
||||
//! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
|
||||
//! Order of color components is essential for further usage by OpenGL
|
||||
Standard_EXPORT void SetColors (const Handle(TColStd_HArray1OfInteger)& aColor);
|
||||
|
||||
Standard_EXPORT void SetColors(const Handle(TColStd_HArray1OfInteger)& aColor);
|
||||
|
||||
//! Get the color for each node.
|
||||
//! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
|
||||
Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
|
||||
|
||||
//! Returns true if triangulation has vertex colors.
|
||||
Standard_Boolean HasVertexColors() const
|
||||
{
|
||||
return (myFlagColor == 1);
|
||||
}
|
||||
|
||||
Standard_EXPORT void SetTriangulation (const Handle(Poly_Triangulation)& aTriangulation);
|
||||
|
||||
Standard_Boolean HasVertexColors() const { return (myFlagColor == 1); }
|
||||
|
||||
Standard_EXPORT void SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation);
|
||||
|
||||
//! Returns Poly_Triangulation .
|
||||
Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT void updatePresentation();
|
||||
|
||||
private:
|
||||
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
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 ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
|
||||
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):
|
||||
//! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
|
||||
//! All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
|
||||
//! Color attenuation is applied to the vertex colors in order to have correct visual result
|
||||
//! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
|
||||
Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent);
|
||||
//! All color components are multiplied by aComponent, the result is then packed again as 32-bit
|
||||
//! integer. Color attenuation is applied to the vertex colors in order to have correct visual
|
||||
//! result after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and
|
||||
//! flat.
|
||||
Standard_EXPORT Graphic3d_Vec4ub attenuateColor(const Standard_Integer theColor,
|
||||
const Standard_Real theComponent);
|
||||
|
||||
Handle(Poly_Triangulation) myTriangulation;
|
||||
Handle(Poly_Triangulation) myTriangulation;
|
||||
Handle(TColStd_HArray1OfInteger) myColor;
|
||||
Standard_Integer myFlagColor;
|
||||
Standard_Integer myNbNodes;
|
||||
Standard_Integer myNbTriangles;
|
||||
|
||||
Standard_Integer myFlagColor;
|
||||
Standard_Integer myNbNodes;
|
||||
Standard_Integer myNbTriangles;
|
||||
};
|
||||
|
||||
#endif // _AIS_Triangulation_HeaderFile
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,21 +52,20 @@ class AIS_Trihedron : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Initializes a trihedron entity.
|
||||
Standard_EXPORT AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent);
|
||||
Standard_EXPORT AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent);
|
||||
|
||||
//! Returns datum display mode.
|
||||
Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; }
|
||||
|
||||
//! 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.
|
||||
const Handle(Geom_Axis2Placement)& Component() const { return myComponent; }
|
||||
|
||||
//! 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
|
||||
//! than the default size of 100 mm. along each axis.
|
||||
@ -76,7 +75,7 @@ public:
|
||||
Standard_EXPORT Standard_Real Size() const;
|
||||
|
||||
//! 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.
|
||||
//! If the object has 1 color, the default size of the
|
||||
@ -90,11 +89,10 @@ public:
|
||||
Standard_EXPORT Quantity_Color TextColor() const;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void SetTextColor (const Prs3d_DatumParts thePart,
|
||||
const Quantity_Color& theColor);
|
||||
Standard_EXPORT void SetTextColor(const Prs3d_DatumParts thePart, const Quantity_Color& theColor);
|
||||
|
||||
//! Returns true if trihedron has own arrow color
|
||||
Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; }
|
||||
@ -103,68 +101,68 @@ public:
|
||||
Standard_EXPORT Quantity_Color ArrowColor() const;
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT void SetArrowColor (const Prs3d_DatumParts thePart,
|
||||
const Quantity_Color& theColor);
|
||||
Standard_EXPORT void SetArrowColor(const Prs3d_DatumParts thePart,
|
||||
const Quantity_Color& theColor);
|
||||
|
||||
//! 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.
|
||||
//! If presentation is shading mode, this color is set for both sides of facing model
|
||||
Standard_EXPORT void SetDatumPartColor (const Prs3d_DatumParts thePart,
|
||||
const Quantity_Color& theColor);
|
||||
Standard_EXPORT void SetDatumPartColor(const Prs3d_DatumParts thePart,
|
||||
const Quantity_Color& theColor);
|
||||
//! Sets color of origin.
|
||||
//! 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.
|
||||
//! 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.
|
||||
//! 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.
|
||||
//! 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
|
||||
Standard_EXPORT Standard_Boolean ToDrawArrows() const;
|
||||
|
||||
//! 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
|
||||
Standard_Integer SelectionPriority (Prs3d_DatumParts thePart) { return mySelectionPriority[thePart]; }
|
||||
Standard_Integer SelectionPriority(Prs3d_DatumParts thePart)
|
||||
{
|
||||
return mySelectionPriority[thePart];
|
||||
}
|
||||
|
||||
//! Sets priority of selection for owner of the given type
|
||||
void SetSelectionPriority (Prs3d_DatumParts thePart,
|
||||
Standard_Integer thePriority)
|
||||
void SetSelectionPriority(Prs3d_DatumParts thePart, Standard_Integer thePriority)
|
||||
{
|
||||
mySelectionPriority[thePart] = thePriority;
|
||||
}
|
||||
|
||||
//! 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
|
||||
void SetLabel (const Prs3d_DatumParts thePart,
|
||||
const TCollection_ExtendedString& theName)
|
||||
void SetLabel(const Prs3d_DatumParts thePart, const TCollection_ExtendedString& theName)
|
||||
{
|
||||
myLabels[thePart] = theName;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Sets the color theColor for this trihedron object, it changes color of axes.
|
||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||
|
||||
//! 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;
|
||||
}
|
||||
@ -173,79 +171,86 @@ public:
|
||||
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; }
|
||||
|
||||
//! Indicates that the type of Interactive Object is datum.
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
|
||||
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
|
||||
{
|
||||
return AIS_KindOfInteractive_Datum;
|
||||
}
|
||||
|
||||
//! Removes the settings for color.
|
||||
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Method which clear all selected owners belonging
|
||||
//! to this selectable object ( for fast presentation draw ).
|
||||
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
|
||||
|
||||
//! Method which draws selected owners ( for fast presentation draw ).
|
||||
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const SelectMgr_SequenceOfOwner& theOwners)
|
||||
Standard_OVERRIDE;
|
||||
|
||||
//! Method which hilight an owner belonging to
|
||||
//! this selectable object ( for fast presentation draw ).
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor(
|
||||
const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Compute trihedron presentation.
|
||||
Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Compute selection.
|
||||
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;
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
|
||||
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a sensitive entity for the datum part that will be used in selection owner creation.
|
||||
Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) const;
|
||||
Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity(
|
||||
const Prs3d_DatumParts thePart,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) const;
|
||||
|
||||
//! Computes presentation for display mode equal 1.
|
||||
Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs);
|
||||
Standard_EXPORT void computePresentation(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs);
|
||||
|
||||
//! Returns own datum aspect of trihedron, create this aspect if it was not created yet.
|
||||
Standard_EXPORT void setOwnDatumAspect();
|
||||
|
||||
//! Returns primitives.
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& arrayOfPrimitives (Prs3d_DatumParts thePart) const { return myPrimitives[thePart]; }
|
||||
const Handle(Graphic3d_ArrayOfPrimitives)& arrayOfPrimitives(Prs3d_DatumParts thePart) const
|
||||
{
|
||||
return myPrimitives[thePart];
|
||||
}
|
||||
|
||||
//! Updates graphic groups for the current datum mode
|
||||
//! Parameters of datum position and orientation
|
||||
Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect,
|
||||
Prs3d_DatumMode theMode,
|
||||
const gp_Pnt& theOrigin,
|
||||
const gp_Dir& theXDir,
|
||||
const gp_Dir& theYDir,
|
||||
const gp_Dir& theZDir);
|
||||
Standard_EXPORT void updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
|
||||
Prs3d_DatumMode theMode,
|
||||
const gp_Pnt& theOrigin,
|
||||
const gp_Dir& theXDir,
|
||||
const gp_Dir& theYDir,
|
||||
const gp_Dir& theZDir);
|
||||
|
||||
protected:
|
||||
Handle(Geom_Axis2Placement) myComponent;
|
||||
Prs3d_DatumMode myTrihDispMode;
|
||||
Standard_Boolean myHasOwnSize;
|
||||
Standard_Boolean myHasOwnTextColor;
|
||||
Standard_Boolean myHasOwnArrowColor;
|
||||
Prs3d_DatumMode myTrihDispMode;
|
||||
Standard_Boolean myHasOwnSize;
|
||||
Standard_Boolean myHasOwnTextColor;
|
||||
Standard_Boolean myHasOwnArrowColor;
|
||||
|
||||
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;
|
||||
Handle(Graphic3d_AspectLine3d) myHiddenLineAspect;
|
||||
Handle(Graphic3d_AspectLine3d) myHiddenLineAspect;
|
||||
|
||||
Handle(Graphic3d_ArrayOfPrimitives) myPrimitives[Prs3d_DatumParts_NB];
|
||||
};
|
||||
|
@ -14,17 +14,17 @@
|
||||
|
||||
#include <AIS_TrihedronOwner.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (AIS_TrihedronOwner, SelectMgr_EntityOwner)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner)
|
||||
|
||||
// =======================================================================
|
||||
// function : AIS_TrihedronOwner
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
AIS_TrihedronOwner::AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Prs3d_DatumParts thePart,
|
||||
const Standard_Integer thePriority)
|
||||
: SelectMgr_EntityOwner (theSelObject, thePriority),
|
||||
myDatumPart (thePart)
|
||||
AIS_TrihedronOwner::AIS_TrihedronOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Prs3d_DatumParts thePart,
|
||||
const Standard_Integer thePriority)
|
||||
: SelectMgr_EntityOwner(theSelObject, thePriority),
|
||||
myDatumPart(thePart)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,40 +32,40 @@ AIS_TrihedronOwner::AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)
|
||||
// function : HilightWithColor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_TrihedronOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer /*theMode*/)
|
||||
void AIS_TrihedronOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer /*theMode*/)
|
||||
{
|
||||
Selectable()->HilightOwnerWithColor (thePM, theStyle, this);
|
||||
Selectable()->HilightOwnerWithColor(thePM, theStyle, this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsHilighted
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean AIS_TrihedronOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) const
|
||||
Standard_Boolean AIS_TrihedronOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) const
|
||||
{
|
||||
if (!HasSelectable())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return thePM->IsHighlighted (Selectable(), theMode);
|
||||
return thePM->IsHighlighted(Selectable(), theMode);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Unhilight
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_TrihedronOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode)
|
||||
void AIS_TrihedronOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
(void )theMode;
|
||||
(void)theMode;
|
||||
if (!HasSelectable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
thePM->Unhighlight (Selectable());
|
||||
thePM->Unhighlight(Selectable());
|
||||
}
|
||||
|
@ -24,34 +24,34 @@ class AIS_TrihedronOwner : public SelectMgr_EntityOwner
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner)
|
||||
public:
|
||||
|
||||
//! Creates an owner of AIS_Trihedron object.
|
||||
Standard_EXPORT AIS_TrihedronOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Prs3d_DatumParts theDatumPart,
|
||||
const Standard_Integer thePriority);
|
||||
Standard_EXPORT AIS_TrihedronOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
|
||||
const Prs3d_DatumParts theDatumPart,
|
||||
const Standard_Integer thePriority);
|
||||
|
||||
//! Returns the datum part identifier.
|
||||
Prs3d_DatumParts DatumPart() const { return myDatumPart; }
|
||||
|
||||
//! Highlights selectable object's presentation.
|
||||
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the presentation manager thePM
|
||||
//! highlights selections corresponding to the selection mode aMode.
|
||||
Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) const Standard_OVERRIDE;
|
||||
Standard_EXPORT Standard_Boolean
|
||||
IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
|
||||
const Standard_Integer theMode) const Standard_OVERRIDE;
|
||||
|
||||
//! Removes highlighting from the owner of a detected
|
||||
//! selectable object in the presentation manager thePM.
|
||||
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;
|
||||
|
||||
protected:
|
||||
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
|
||||
|
@ -14,20 +14,21 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_TypeFilter.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#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):
|
||||
myKind(TheKind){}
|
||||
|
||||
Standard_Boolean AIS_TypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
|
||||
AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind)
|
||||
: myKind(TheKind)
|
||||
{
|
||||
Handle(AIS_InteractiveObject) anObject =
|
||||
Handle(AIS_InteractiveObject)::DownCast (anObj->Selectable());
|
||||
return ! anObject.IsNull() && anObject->Type()== myKind;
|
||||
}
|
||||
|
||||
Standard_Boolean AIS_TypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
|
||||
{
|
||||
Handle(AIS_InteractiveObject) anObject =
|
||||
Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable());
|
||||
return !anObject.IsNull() && anObject->Type() == myKind;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <SelectMgr_Filter.hxx>
|
||||
class SelectMgr_EntityOwner;
|
||||
|
||||
|
||||
class AIS_TypeFilter;
|
||||
DEFINE_STANDARD_HANDLE(AIS_TypeFilter, SelectMgr_Filter)
|
||||
|
||||
@ -55,38 +54,21 @@ class AIS_TypeFilter : public SelectMgr_Filter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Initializes filter for type, aGivenKind.
|
||||
Standard_EXPORT AIS_TypeFilter(const AIS_KindOfInteractive aGivenKind);
|
||||
|
||||
|
||||
//! Returns False if the transient is not an Interactive
|
||||
//! Object, or if the type of the Interactive Object is not
|
||||
//! the same as that stored in the filter.
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_TypeFilter,SelectMgr_Filter)
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_TypeFilter, SelectMgr_Filter)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
AIS_KindOfInteractive myKind;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _AIS_TypeFilter_HeaderFile
|
||||
|
@ -17,25 +17,24 @@
|
||||
#ifndef _AIS_TypeOfAttribute_HeaderFile
|
||||
#define _AIS_TypeOfAttribute_HeaderFile
|
||||
|
||||
|
||||
enum AIS_TypeOfAttribute
|
||||
{
|
||||
AIS_TOA_Line,
|
||||
AIS_TOA_Dimension,
|
||||
AIS_TOA_Wire,
|
||||
AIS_TOA_Plane,
|
||||
AIS_TOA_Vector,
|
||||
AIS_TOA_UIso,
|
||||
AIS_TOA_VIso,
|
||||
AIS_TOA_Free,
|
||||
AIS_TOA_UnFree,
|
||||
AIS_TOA_Section,
|
||||
AIS_TOA_Hidden,
|
||||
AIS_TOA_Seen,
|
||||
AIS_TOA_FaceBoundary,
|
||||
AIS_TOA_FirstAxis,
|
||||
AIS_TOA_SecondAxis,
|
||||
AIS_TOA_ThirdAxis
|
||||
AIS_TOA_Line,
|
||||
AIS_TOA_Dimension,
|
||||
AIS_TOA_Wire,
|
||||
AIS_TOA_Plane,
|
||||
AIS_TOA_Vector,
|
||||
AIS_TOA_UIso,
|
||||
AIS_TOA_VIso,
|
||||
AIS_TOA_Free,
|
||||
AIS_TOA_UnFree,
|
||||
AIS_TOA_Section,
|
||||
AIS_TOA_Hidden,
|
||||
AIS_TOA_Seen,
|
||||
AIS_TOA_FaceBoundary,
|
||||
AIS_TOA_FirstAxis,
|
||||
AIS_TOA_SecondAxis,
|
||||
AIS_TOA_ThirdAxis
|
||||
};
|
||||
|
||||
#endif // _AIS_TypeOfAttribute_HeaderFile
|
||||
|
@ -20,10 +20,10 @@
|
||||
//! Declares the type of axis.
|
||||
enum AIS_TypeOfAxis
|
||||
{
|
||||
AIS_TOAX_Unknown,
|
||||
AIS_TOAX_XAxis,
|
||||
AIS_TOAX_YAxis,
|
||||
AIS_TOAX_ZAxis
|
||||
AIS_TOAX_Unknown,
|
||||
AIS_TOAX_XAxis,
|
||||
AIS_TOAX_YAxis,
|
||||
AIS_TOAX_ZAxis
|
||||
};
|
||||
|
||||
#endif // _AIS_TypeOfAxis_HeaderFile
|
||||
|
@ -20,9 +20,9 @@
|
||||
//! Declares the type of isoparameter displayed.
|
||||
enum AIS_TypeOfIso
|
||||
{
|
||||
AIS_TOI_IsoU,
|
||||
AIS_TOI_IsoV,
|
||||
AIS_TOI_Both
|
||||
AIS_TOI_IsoU,
|
||||
AIS_TOI_IsoV,
|
||||
AIS_TOI_Both
|
||||
};
|
||||
|
||||
#endif // _AIS_TypeOfIso_HeaderFile
|
||||
|
@ -20,10 +20,10 @@
|
||||
//! Declares the type of plane.
|
||||
enum AIS_TypeOfPlane
|
||||
{
|
||||
AIS_TOPL_Unknown,
|
||||
AIS_TOPL_XYPlane,
|
||||
AIS_TOPL_XZPlane,
|
||||
AIS_TOPL_YZPlane
|
||||
AIS_TOPL_Unknown,
|
||||
AIS_TOPL_XYPlane,
|
||||
AIS_TOPL_XZPlane,
|
||||
AIS_TOPL_YZPlane
|
||||
};
|
||||
|
||||
#endif // _AIS_TypeOfPlane_HeaderFile
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user