1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
dkulikov
e7031bbfab Data Exchange - Update Readers with ShapeHealing parameters #247
All instances of using XSAlgo_AlgoContainer are replaced with
XSAlgo_ShapeProcessor.

Parameters for XSAlgo_ShapeProcessor operations are now can be passes
via the updated interface of respective classes.

Staqtic function to read processing parameters from file is added to
XSAlgo_ShapeProcessor.
2025-01-22 11:52:48 +00:00
14024 changed files with 1192811 additions and 1270850 deletions

View File

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

View File

@@ -1,2 +0,0 @@
# Global formatting with new rules using clang-format 18.1.8
a5a7b3185b83c39d5b26cfaf138b9b87b5776e59

View File

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

View File

@@ -38,17 +38,17 @@ If HTML documentation is not available in your package, you can:
- **Generate together with sources:** You need to have CMake and 1.8.4 (or above) installed on your system. Enable `BUILD_DOC_Overview` CMake parameter and set the path to Doxygen `3RDPARTY_DOXYGEN_EXECUTABLE`. Then build ALL or only `Overview`.
- **Read documentation in source plain text (Markdown) format** found in the subfolder `dox` or [GitHub Wiki](https://github.com/Open-Cascade-SAS/OCCT/wiki).
See [dox/build/build_documentation/building_documentation.md](dox/build/build_documentation/building_documentation.md) or [Building Documentation](https://dev.opencascade.org/doc/occt-7.8.0/overview/html/build_upgrade__building_documentation.html) for details.
See `dox/dev_guides/documentation/documentation.md` or [Building Documentation](https://dev.opencascade.org/doc/occt-7.8.0/overview/html/build_upgrade__building_documentation.html) for details.
## Building
In most cases, you need to rebuild OCCT on your platform (OS, compiler) before using it in your project to ensure binary compatibility.
Consult the file [dox/build/build_occt/building_occt.md](dox/build/build_occt/building_occt.md) or [Building OCCT](https://dev.opencascade.org/doc/overview/html/build_upgrade__building_occt.html) or [Building OCCT Wiki](https://github.com/Open-Cascade-SAS/OCCT/wiki/build_upgrade) for instructions on building OCCT from sources on supported platforms.
Consult the file `dox/dev_guides/building/building.md` or [Building OCCT](https://dev.opencascade.org/doc/overview/html/build_upgrade__building_occt.html) or [Building OCCT Wiki](https://github.com/Open-Cascade-SAS/OCCT/wiki/build_upgrade) for instructions on building OCCT from sources on supported platforms.
## Version
The current version of OCCT can be found in the file [`src/Standard/Standard_Version.hxx`](src/Standard/Standard_Version.hxx).
The current version of OCCT can be found in the file `src/Standard/Standard_Version.hxx`.
## Development

View File

@@ -32,12 +32,7 @@ function (JEMALLOC_LIB_SEARCH MMGR_LIB PREFIX)
list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_JEMALLOC_LIBRARY_DIR_${MMGR_LIB} PARENT_SCOPE)
set (3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB} "" PARENT_SCOPE)
endif()
set(JEMALLOC_IS_STATIC_LIB FALSE)
if ("${PREFIX}" STREQUAL "STATIC")
set(JEMALLOC_IS_STATIC_LIB TRUE)
endif()
set (JEMALLOC_IS_STATIC_LIB ("${PREFIX}" STREQUAL "STATIC"))
if (${JEMALLOC_IS_STATIC_LIB})
set (OLD_CSF_MMGR ${CSF_MMGR})
list (APPEND OLD_CSF_MMGR "${3RDPARTY_JEMALLOC_LIBRARY_${PREFIX}_${MMGR_LIB}}")

View File

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

View File

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

View File

@@ -28,12 +28,7 @@ struct AIS_AnimationProgress
Standard_Real LocalNormalized; //!< normalized position within current animation within 0..1 range
// clang-format on
AIS_AnimationProgress()
: Pts(-1.0),
LocalPts(-1.0),
LocalNormalized(-1.0)
{
}
AIS_AnimationProgress() : Pts (-1.0), LocalPts (-1.0), LocalNormalized (-1.0) {}
};
DEFINE_STANDARD_HANDLE(AIS_Animation, Standard_Transient)
@@ -43,41 +38,36 @@ 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);
@@ -88,6 +78,7 @@ public:
const TCollection_AsciiString& Name() const { return myName; }
public:
//! @return start time of the animation in the timeline
Standard_Real StartPts() const { return myPtsStart; }
@@ -134,14 +125,13 @@ public:
const NCollection_Sequence<Handle(AIS_Animation)>& Children() const { return myAnimations; }
public:
//! Start animation with internally defined timer instance.
//! Calls ::Start() internally.
//!
//! Note, that this method initializes a timer calculating an elapsed time (presentation
//! timestamps within AIS_Animation::UpdateTimer()), not a multimedia timer executing Viewer
//! updates at specific intervals! Viewer redrawing should be managed at application level, so
//! that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer
//! content.
//! Note, that this method initializes a timer calculating an elapsed time (presentation timestamps within AIS_Animation::UpdateTimer()),
//! not a multimedia timer executing Viewer updates at specific intervals!
//! Viewer redrawing should be managed at application level, so that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer content.
//!
//! @param theStartPts starting timer position (presentation timestamp)
//! @param thePlaySpeed playback speed (1.0 means normal speed)
@@ -166,6 +156,7 @@ public:
void SetTimer (const Handle(Media_Timer)& theTimer) { myTimer = theTimer; }
public:
//! Start animation. This method changes status of the animation to Started.
//! This status defines whether animation is to be performed in the timeline or not.
//! @param theToUpdate call Update() method
@@ -188,14 +179,16 @@ public:
Standard_EXPORT virtual Standard_Boolean Update (const Standard_Real thePts);
protected:
//! Process one step of the animation according to the input time progress, including all
//! children. Calls also ::update() to update own animation.
//! Process one step of the animation according to the input time progress, including all children.
//! Calls also ::update() to update own animation.
Standard_EXPORT virtual void updateWithChildren (const AIS_AnimationProgress& thePosition);
//! Update the own animation to specified position - should be overridden by sub-class.
virtual void update (const AIS_AnimationProgress& theProgress) { (void )theProgress; }
protected:
//! Defines animation state.
enum AnimationState
{
@@ -205,15 +198,18 @@ protected:
};
protected:
Handle(Media_Timer) myTimer;
TCollection_AsciiString myName; //!< animation name
NCollection_Sequence<Handle(AIS_Animation)> myAnimations; //!< sequence of child animations
NCollection_Sequence<Handle(AIS_Animation)>
myAnimations; //!< sequence of child animations
AnimationState myState; //!< animation state - started, stopped of paused
Standard_Real myPtsStart; //!< time of start in the timeline
Standard_Real myOwnDuration; //!< duration of animation excluding children
Standard_Real myChildrenDuration; //!< duration of animation including children
};
#endif // _AIS_Animation_HeaderFile

View File

@@ -15,10 +15,11 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
//=================================================================================================
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation(
const TCollection_AsciiString& theAnimationName,
//=============================================================================
//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,
@@ -32,8 +33,10 @@ AIS_AnimationAxisRotation::AIS_AnimationAxisRotation(
//
}
//=================================================================================================
//=============================================================================
//function : update
//purpose :
//=============================================================================
void AIS_AnimationAxisRotation::update (const AIS_AnimationProgress& theProgress)
{
if (myObject.IsNull())
@@ -42,8 +45,7 @@ void AIS_AnimationAxisRotation::update(const AIS_AnimationProgress& theProgress)
}
gp_Trsf aTrsf;
Standard_Real aCurrentAngle =
(1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
Standard_Real aCurrentAngle = (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
aTrsf.SetRotation (myRotAxis, aCurrentAngle);
updateTrsf (aTrsf);
}

View File

@@ -22,6 +22,7 @@ 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
@@ -37,13 +38,16 @@ public:
const Standard_Real theAngleEnd);
protected:
//! Update the progress.
Standard_EXPORT virtual void update (const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
gp_Ax1 myRotAxis; //!< rotation axis
Standard_Real myAngleStart; //!< start angle for rotation
Standard_Real myAngleEnd; //!< end angle for rotation
};
#endif // _AIS_AnimationAxisRotation_HeaderFile

View File

@@ -18,8 +18,10 @@
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),
@@ -28,11 +30,15 @@ AIS_AnimationCamera::AIS_AnimationCamera(const TCollection_AsciiString& theAnima
//
}
//=================================================================================================
//=============================================================================
//function : update
//purpose :
//=============================================================================
void AIS_AnimationCamera::update (const AIS_AnimationProgress& theProgress)
{
if (myView.IsNull() || myCamStart.IsNull() || myCamEnd.IsNull())
if (myView.IsNull()
|| myCamStart.IsNull()
|| myCamEnd.IsNull())
{
return;
}

View File

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

View File

@@ -16,8 +16,10 @@
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,
@@ -29,8 +31,10 @@ AIS_AnimationObject::AIS_AnimationObject(const TCollection_AsciiString& t
//
}
//=================================================================================================
//=============================================================================
//function : update
//purpose :
//=============================================================================
void AIS_AnimationObject::update (const AIS_AnimationProgress& theProgress)
{
if (myObject.IsNull())

View File

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

View File

@@ -14,6 +14,7 @@
// 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>
@@ -21,30 +22,26 @@
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),
AIS_AttributeFilter::AIS_AttributeFilter():
hasC(Standard_False),
hasW(Standard_True)
{
}
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
{
Handle(AIS_InteractiveObject) aSelectable(
Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable()));
Handle(AIS_InteractiveObject) aSelectable (Handle(AIS_InteractiveObject)::DownCast (anObj->Selectable()));
if (aSelectable.IsNull())
return Standard_False;

View File

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

View File

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

View File

@@ -38,13 +38,13 @@ class AIS_Axis : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
public:
//! Initializes the line aComponent
Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent);
//! initializes the axis2 position
//! aComponent. The coordinate system used is right-handed.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType);
//! Initializes the axis1 position anAxis.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis);
@@ -69,8 +69,7 @@ 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);
@@ -88,15 +87,11 @@ 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;
@@ -110,6 +105,7 @@ 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;
@@ -120,6 +116,7 @@ private:
Standard_EXPORT void ComputeFields();
private:
Handle(Geom_Line) myComponent;
Handle(Geom_Axis2Placement) myAx2;
gp_Pnt myPfirst;
@@ -130,6 +127,7 @@ private:
Standard_Real myVal;
Standard_CString myText;
Handle(Prs3d_LineAspect) myLineAspect;
};
DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject)

View File

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

View File

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

View File

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

View File

@@ -22,6 +22,7 @@ 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
@@ -34,12 +35,15 @@ protected:
Standard_EXPORT void updateTrsf (const gp_Trsf& theTrsf);
private:
//! Invalidate the viewer for proper update.
Standard_EXPORT void invalidateViewer();
protected:
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
};
#endif // _AIS_BaseAnimationObject_HeaderFile

View File

@@ -14,6 +14,7 @@
// 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>
@@ -28,50 +29,53 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_C0RegularityFilter,SelectMgr_Filter)
//=================================================================================================
//=======================================================================
//function : AIS_C0RegularityFilter
//purpose :
//=======================================================================
AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
{
TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
Standard_Boolean Ok;
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++)
{
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
Ok = Standard_False;
TopTools_ListIteratorOfListOfShape it(SubShapes(i));
TopoDS_Face Face1, Face2;
if (it.More())
{
if (it.More()) {
Face1 = TopoDS::Face(it.Value());
it.Next();
if (it.More())
{
if (it.More()) {
Face2 = TopoDS::Face(it.Value());
it.Next();
if (!it.More())
{
if (!it.More()) {
GeomAbs_Shape ShapeContinuity =
BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
Ok = (ShapeContinuity == GeomAbs_C0);
}
}
}
if (Ok)
{
if (Ok) {
const TopoDS_Shape& curEdge = SubShapes.FindKey( i );
myMapOfEdges.Add(curEdge);
}
}
}
//=================================================================================================
//=======================================================================
//function : ActsOn
//purpose :
//=======================================================================
Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
return (aType == TopAbs_EDGE);
}
//=================================================================================================
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{

View File

@@ -25,26 +25,45 @@
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 ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter,SelectMgr_Filter)
protected:
private:
TopTools_MapOfShape myMapOfEdges;
};
#endif // _AIS_C0RegularityFilter_HeaderFile

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -33,17 +33,20 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject)
//=================================================================================================
AIS_ConnectedInteractive::AIS_ConnectedInteractive(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: AIS_InteractiveObject(aTypeOfPresentation3d)
//=======================================================================
//function : AIS_ConnectedInteractive
//purpose :
//=======================================================================
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)
{
@@ -53,8 +56,7 @@ void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theA
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;
@@ -65,8 +67,7 @@ void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theA
}
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())
@@ -75,15 +76,17 @@ void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theA
&& myReference->GetContext()->DisplayStatus (myReference) != AIS_DS_None)
{
myReference.Nullify();
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should "
"NOT be displayed in context");
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should NOT be displayed in context");
}
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
}
setLocalTransformation (theLocation);
}
//=================================================================================================
//=======================================================================
//function : Disconnect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Disconnect()
{
@@ -96,9 +99,10 @@ void AIS_ConnectedInteractive::Disconnect()
}
}
}
//=================================================================================================
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@@ -125,13 +129,16 @@ void AIS_ConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)&
}
}
//=================================================================================================
//=======================================================================
//function : computeHLR
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& theProjector,
const Handle(TopLoc_Datum3D)& theTransformation,
const Handle(Prs3d_Presentation)& thePresentation)
{
const bool hasTrsf = !theTransformation.IsNull() && theTransformation->Form() != gp_Identity;
const bool hasTrsf = !theTransformation.IsNull()
&& theTransformation->Form() != gp_Identity;
updateShape (!hasTrsf);
if (myShape.IsNull())
{
@@ -149,8 +156,10 @@ void AIS_ConnectedInteractive::computeHLR(const Handle(Graphic3d_Camera)& theP
}
}
//=================================================================================================
//=======================================================================
//function : updateShape
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::updateShape (const Standard_Boolean isWithLocation)
{
Handle(AIS_Shape) anAisShape = Handle(AIS_Shape)::DownCast (myReference);
@@ -175,8 +184,10 @@ void AIS_ConnectedInteractive::updateShape(const Standard_Boolean isWithLocation
}
}
//=================================================================================================
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
@@ -207,10 +218,7 @@ void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection
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())
{
@@ -224,14 +232,16 @@ void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection
}
}
//=================================================================================================
void AIS_ConnectedInteractive::computeSubShapeSelection(
const Handle(SelectMgr_Selection)& theSelection,
//=======================================================================
//function : ComputeSubShapeSelection
//purpose :
//=======================================================================
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))
{
@@ -246,15 +256,11 @@ void AIS_ConnectedInteractive::computeSubShapeSelection(
// 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))
@@ -270,11 +276,7 @@ void AIS_ConnectedInteractive::computeSubShapeSelection(
for (Shapes2EntitiesMap::Iterator aMapIt (aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
{
const SensitiveList& aSEList = aMapIt.Value();
Handle(StdSelect_BRepOwner) anOwner =
new StdSelect_BRepOwner(aMapIt.Key(),
this,
aSEList.First()->OwnerId()->Priority(),
Standard_True);
Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner (aMapIt.Key(), this, aSEList.First()->OwnerId()->Priority(), Standard_True);
anOwner->SetLocation (Transformation());
for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next())
{

View File

@@ -37,45 +37,34 @@ 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)());
}
//! 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) { 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 Handle(TopLoc_Datum3D)& theLocation)
{
connect(theAnotherObj, theLocation);
}
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); }
//! Returns true if there is a connection established
//! between the presentation and its source reference.
@@ -99,10 +88,12 @@ public:
//! Return true if reference presentation accepts specified display mode.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
{
return myReference.IsNull() || myReference->AcceptDisplayMode(theMode);
return myReference.IsNull()
|| myReference->AcceptDisplayMode (theMode);
}
protected:
//! Calculates the view aPresentation and its updates.
//! The latter are managed by aPresentationManager.
//! The display mode aMode is 0 by default.
@@ -119,20 +110,17 @@ protected:
//! Computes the presentation according to a point of view.
Standard_EXPORT virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs)
Standard_OVERRIDE;
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
//! Generates sensitive entities by copying
//! them from myReference selection, creates and sets an entity
//! owner for this entities and adds them to theSelection
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
//! Generates sensitive entities by copying
//! them from myReference sub shapes selection, creates and sets an entity
//! owner for this entities and adds them to theSelection
Standard_EXPORT void computeSubShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True);
@@ -140,8 +128,10 @@ protected:
const Handle(TopLoc_Datum3D)& theLocation);
protected:
Handle(AIS_InteractiveObject) myReference;
TopoDS_Shape myShape;
};
DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)

View File

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

View File

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

View File

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

View File

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

View File

@@ -14,6 +14,7 @@
// 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>
@@ -23,16 +24,18 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_ExclusionFilter,SelectMgr_Filter)
//=================================================================================================
AIS_ExclusionFilter::AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn)
: myIsExclusionFlagOn(ExclusionFlagOn)
//=======================================================================
//function : AIS_ExclusionFilter
//purpose : Constructors
//=======================================================================
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);
@@ -40,16 +43,18 @@ AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclu
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType,
const Standard_Boolean ExclusionFlagOn)
: myIsExclusionFlagOn(ExclusionFlagOn)
const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
{
TColStd_ListOfInteger L;
L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
}
//=================================================================================================
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude)
{
if(IsStored(TypeToExclude))
@@ -62,8 +67,7 @@ Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExcl
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType)
{
if (!IsStored(TypeToExclude))
{
if(!IsStored(TypeToExclude)){
TColStd_ListOfInteger L;
L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L);
@@ -74,12 +78,14 @@ Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExcl
return Standard_True;
}
//=================================================================================================
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude)
{
if (!IsStored(TypeToExclude))
return Standard_False;
if(!IsStored(TypeToExclude)) return Standard_False;
myStoredTypes((Standard_Integer)TypeToExclude).Clear();
myStoredTypes.UnBind((Standard_Integer)TypeToExclude);
return Standard_True;
@@ -88,13 +94,10 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType)
{
if (!IsStored(TypeToExclude))
return Standard_False;
if(!IsStored(TypeToExclude)) return Standard_False;
TColStd_ListOfInteger& LL = myStoredTypes.ChangeFind((Standard_Integer)TypeToExclude);
for (TColStd_ListIteratorOfListOfInteger it(LL); it.More(); it.Next())
{
if (it.Value() == SignatureInType)
{
for(TColStd_ListIteratorOfListOfInteger it(LL);it.More();it.Next()){
if(it.Value()==SignatureInType){
LL.Remove(it);
return Standard_True;
}
@@ -102,7 +105,11 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
return Standard_False;
}
//=================================================================================================
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void AIS_ExclusionFilter::Clear()
{
@@ -112,30 +119,37 @@ void AIS_ExclusionFilter::Clear()
myStoredTypes.Clear();
}
//=================================================================================================
//=======================================================================
//function : IsStored
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsStored(const AIS_KindOfInteractive aType) const
{
return myStoredTypes.IsBound(Standard_Integer(aType));
}
//=================================================================================================
//=======================================================================
//function : IsSignatureIn
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsSignatureIn(const AIS_KindOfInteractive aType,
const Standard_Integer SignatureInType) const
{
if (!myStoredTypes.IsBound(aType))
return Standard_False;
for (TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType)); Lit.More();
Lit.Next())
{
if(!myStoredTypes.IsBound(aType)) return Standard_False;
for(TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType));
Lit.More();
Lit.Next()){
if(Lit.Value()==SignatureInType)
return Standard_True;
}
return Standard_False;
}
//=================================================================================================
//=======================================================================
//function : ListOfStoredTypes
//purpose :
//=======================================================================
void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) const
{
@@ -145,10 +159,12 @@ void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) cons
TheList.Append(MIT.Key());
}
//=================================================================================================
//=======================================================================
//function : ListOfSignature
//purpose :
//=======================================================================
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,
TColStd_ListOfInteger& TheStoredList) const
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,TColStd_ListOfInteger& TheStoredList) const
{
TheStoredList.Clear();
if(IsStored(aType))
@@ -156,7 +172,10 @@ void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,
TheStoredList.Append(it.Value());
}
//=================================================================================================
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
@@ -181,3 +200,10 @@ Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
return myIsExclusionFlagOn;
}

View File

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

View File

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

View File

@@ -14,6 +14,7 @@
// 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>
@@ -67,17 +68,14 @@ static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
return bid;
}
Quantity_NameOfColor AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
{
Quantity_Color color;
GetLineColor(Dr,Att,color);
return color.Name();
}
void AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att,
Quantity_Color& aColor)
void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
{
aColor = GetLineAspect(Dr,Att)->Aspect()->Color();
}
@@ -88,7 +86,6 @@ Standard_Real AIS_GraphicTool::GetLineWidth(const Handle(Prs3d_Drawer)& Dr,
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
return LA->Aspect()->Width();
}
Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
@@ -96,6 +93,7 @@ Aspect_TypeOfLine AIS_GraphicTool::GetLineType(const Handle(Prs3d_Drawer)& Dr,
return LA->Aspect()->Type();
}
void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att,
Quantity_NameOfColor& Col,

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -27,26 +27,24 @@ 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; }
@@ -81,8 +79,7 @@ public:
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx);
//! Returns true if the object has an owner attributed to it.
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is
//! composed of, and takes the form of a transient.
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is composed of, and takes the form of a transient.
Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
//! Returns the owner of the Interactive Object.
@@ -100,13 +97,10 @@ 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.
@@ -117,8 +111,7 @@ public:
//! @param[in] theDragTo drag end point
//! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
const Handle(AIS_InteractiveContext)& theCtx,
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom,
@@ -126,6 +119,7 @@ public:
const AIS_DragAction theAction);
public:
//! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
@@ -140,23 +134,23 @@ public:
Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect);
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
//! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependent on the view of Display.
Standard_EXPORT AIS_InteractiveObject(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Set presentation display status.
Standard_EXPORT void SetDisplayStatus (PrsMgr_DisplayStatus theStatus);
protected:
// clang-format off
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
// clang-format on
Handle(Standard_Transient) myOwner; //!< application-specific owner object
};
DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,22 +29,19 @@ 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; }
@@ -86,6 +83,7 @@ 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;
@@ -104,10 +102,12 @@ private:
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
private:
Handle(Geom_Line) myComponent;
Handle(Geom_Point) myStartPoint;
Handle(Geom_Point) myEndPoint;
Standard_Boolean myLineIsSegment;
};
DEFINE_STANDARD_HANDLE(AIS_Line, AIS_InteractiveObject)

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,9 +16,10 @@
#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,
@@ -30,8 +31,10 @@ AIS_ManipulatorOwner::AIS_ManipulatorOwner(const Handle(SelectMgr_SelectableObje
//
}
//=================================================================================================
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
void AIS_ManipulatorOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode)
@@ -45,8 +48,10 @@ void AIS_ManipulatorOwner::HilightWithColor(const Handle(PrsMgr_PresentationMana
Selectable()->HilightOwnerWithColor (thePM, theStyle, this);
}
//=================================================================================================
//=======================================================================
//function : IsHilighted
//purpose :
//=======================================================================
Standard_Boolean AIS_ManipulatorOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer /*theMode*/) const
{
@@ -58,8 +63,10 @@ Standard_Boolean AIS_ManipulatorOwner::IsHilighted(const Handle(PrsMgr_Presentat
return thePM->IsHighlighted (Selectable(), myMode);
}
//=================================================================================================
//=======================================================================
//function : Unhilight
//purpose :
//=======================================================================
void AIS_ManipulatorOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer /*theMode*/)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -47,22 +47,21 @@
//! 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);
@@ -71,22 +70,13 @@ 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; }
@@ -124,14 +114,12 @@ public:
//! coefficient aCoefficient and the previous deviation
//! coefficient aPreviousCoefficient. If these values are
//! not already set, false is returned.
Standard_EXPORT Standard_Boolean
OwnDeviationCoefficient(Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
Standard_EXPORT Standard_Boolean OwnDeviationCoefficient (Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
//! Returns true and the values of the deviation angle
//! anAngle and the previous deviation angle aPreviousAngle.
//! If these values are not already set, false is returned.
Standard_EXPORT Standard_Boolean OwnDeviationAngle(Standard_Real& anAngle,
Standard_Real& aPreviousAngle) const;
Standard_EXPORT Standard_Boolean OwnDeviationAngle (Standard_Real& anAngle, Standard_Real& aPreviousAngle) const;
//! Sets the type of HLR algorithm used by the shape
void SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR) { myDrawer->SetTypeOfHLR (theTypeOfHLR); }
@@ -202,24 +190,15 @@ public:
{
switch (theSelMode)
{
case 1:
return TopAbs_VERTEX;
case 2:
return TopAbs_EDGE;
case 3:
return TopAbs_WIRE;
case 4:
return TopAbs_FACE;
case 5:
return TopAbs_SHELL;
case 6:
return TopAbs_SOLID;
case 7:
return TopAbs_COMPSOLID;
case 8:
return TopAbs_COMPOUND;
case 0:
return TopAbs_SHAPE;
case 1: return TopAbs_VERTEX;
case 2: return TopAbs_EDGE;
case 3: return TopAbs_WIRE;
case 4: return TopAbs_FACE;
case 5: return TopAbs_SHELL;
case 6: return TopAbs_SOLID;
case 7: return TopAbs_COMPSOLID;
case 8: return TopAbs_COMPOUND;
case 0: return TopAbs_SHAPE;
}
return TopAbs_SHAPE;
}
@@ -229,35 +208,26 @@ public:
{
switch (theShapeType)
{
case TopAbs_VERTEX:
return 1;
case TopAbs_EDGE:
return 2;
case TopAbs_WIRE:
return 3;
case TopAbs_FACE:
return 4;
case TopAbs_SHELL:
return 5;
case TopAbs_SOLID:
return 6;
case TopAbs_COMPSOLID:
return 7;
case TopAbs_COMPOUND:
return 8;
case TopAbs_SHAPE:
return 0;
case TopAbs_VERTEX: return 1;
case TopAbs_EDGE: return 2;
case TopAbs_WIRE: return 3;
case TopAbs_FACE: return 4;
case TopAbs_SHELL: return 5;
case TopAbs_SOLID: return 6;
case TopAbs_COMPSOLID: return 7;
case TopAbs_COMPOUND: return 8;
case TopAbs_SHAPE: return 0;
}
return 0;
}
public: //! @name methods to alter texture mapping properties
//! Return texture repeat UV values; (1, 1) by default.
const gp_Pnt2d& TextureRepeatUV() const { return myUVRepeat; }
//! Sets the number of occurrences of the texture on each face. The texture itself is
//! parameterized in (0,1) by (0,1). Each face of the shape to be textured is parameterized in UV
//! space (Umin,Umax) by (Vmin,Vmax).
//! Sets the number of occurrences of the texture on each face. The texture itself is parameterized in (0,1) by (0,1).
//! Each face of the shape to be textured is parameterized in UV space (Umin,Umax) by (Vmin,Vmax).
void SetTextureRepeatUV (const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; }
//! Return texture origin UV position; (0, 0) by default.
@@ -277,6 +247,7 @@ public: //! @name methods to alter texture mapping properties
void SetTextureScaleUV (const gp_Pnt2d& theScaleUV) { myUVScale = theScaleUV; }
protected:
//! Compute normal presentation.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@@ -287,7 +258,8 @@ protected:
const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
{
if (!theTrsf.IsNull() && theTrsf->Form() != gp_Identity)
if (!theTrsf.IsNull()
&& theTrsf->Form() != gp_Identity)
{
const TopLoc_Location& aLoc = myshape.Location();
const TopoDS_Shape aShape = myshape.Located (TopLoc_Location (theTrsf->Trsf()) * aLoc);
@@ -305,26 +277,21 @@ protected:
//! Create own aspects (if they do not exist) and set color to them.
//! @return TRUE if new aspects have been created
Standard_EXPORT bool setColor(const Handle(Prs3d_Drawer)& theDrawer,
const Quantity_Color& theColor) const;
Standard_EXPORT bool setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const;
//! Create own aspects (if they do not exist) and set width to them.
//! @return TRUE if new aspects have been created
Standard_EXPORT bool setWidth(const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theWidth) const;
Standard_EXPORT bool setWidth (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theWidth) const;
Standard_EXPORT void setTransparency(const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theValue) const;
Standard_EXPORT void setTransparency (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theValue) const;
Standard_EXPORT void setMaterial(const Handle(Prs3d_Drawer)& theDrawer,
const Graphic3d_MaterialAspect& theMaterial,
const Standard_Boolean theToKeepColor,
const Standard_Boolean theToKeepTransp) const;
Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
//! Replace aspects of already computed groups from drawer link by the new own value.
Standard_EXPORT void replaceWithNewOwnAspects();
public:
//! Compute HLR presentation for specified shape.
Standard_EXPORT static void computeHlrPresentation (const Handle(Graphic3d_Camera)& theProjector,
const Handle(Prs3d_Presentation)& thePrs,
@@ -332,10 +299,10 @@ public:
const Handle(Prs3d_Drawer)& theDrawer);
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
TopoDS_Shape myshape; //!< shape to display
Bnd_Box myBB; //!< cached bounding box of the shape
gp_Pnt2d myUVOrigin; //!< UV origin vector for generating texture coordinates
@@ -343,6 +310,7 @@ protected:
gp_Pnt2d myUVScale; //!< UV scale vector for generating texture coordinates
Standard_Real myInitAng;
Standard_Boolean myCompBB; //!< if TRUE, then bounding box should be recomputed
};
DEFINE_STANDARD_HANDLE(AIS_Shape, AIS_InteractiveObject)

View File

@@ -14,6 +14,7 @@
// 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>
@@ -22,11 +23,9 @@
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
{
@@ -34,5 +33,7 @@ Standard_Boolean AIS_SignatureFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
if(IO.IsNull())
return Standard_False;
return (IO->Signature() == mySig && IO->Type() == myKind);
return
(IO->Signature()==mySig &&
IO->Type()==myKind);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -30,14 +30,12 @@ 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;
@@ -110,10 +108,7 @@ 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.
//!
@@ -128,17 +123,14 @@ public:
//! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
Standard_EXPORT void SetColorSubTitle (const Quantity_Color& theColor);
//! Returns text presentation formatter; NULL by default, which means standard text formatter will
//! be used.
//! Returns text presentation formatter; NULL by default, which means standard text formatter will be used.
const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
//! Setup text formatter for presentation. It's empty by default.
void SetTextFormatter(const Handle(Font_TextFormatter)& theFormatter)
{
myFormatter = theFormatter;
}
void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
protected:
//! Compute
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& theprsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@@ -159,6 +151,7 @@ protected:
gp_Pnt& theCenterOfLabel) const;
protected:
Handle(Font_TextFormatter) myFormatter;
TCollection_ExtendedString myText;
@@ -168,8 +161,10 @@ protected:
Standard_Boolean myHasFlipping;
public:
//! CASCADE RTTI
DEFINE_STANDARD_RTTIEXT(AIS_TextLabel,AIS_InteractiveObject)
};
DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,6 +24,7 @@ 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,
@@ -39,8 +40,7 @@ public:
//! Returns true if the presentation manager thePM
//! highlights selections corresponding to the selection mode aMode.
Standard_EXPORT Standard_Boolean
IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const Standard_OVERRIDE;
//! Removes highlighting from the owner of a detected

View File

@@ -14,6 +14,7 @@
// 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>
@@ -21,10 +22,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_TypeFilter,SelectMgr_Filter)
AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind)
: myKind(TheKind)
{
}
AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind):
myKind(TheKind){}
Standard_Boolean AIS_TypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

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