1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

Compare commits

..

71 Commits

Author SHA1 Message Date
Pasukhin Dmitry
858dd02fed Coding - Bump version to 7.9.0 stable release #380 2025-02-17 22:00:23 +00:00
Pasukhin Dmitry
7f7e7df782 Documentation - Update coding rules and formatting guidelines #379 2025-02-17 22:00:07 +00:00
dpasukhi
20c7202089 Testing - Remove unstable test cases 2025-02-17 18:15:58 +00:00
Zernova Marina
8fb662b0aa Visualization - NCollection_DataMap::Find() exception from AIS_Selection::Select() #375
Problem with NCollection_DataMap::Find() exception during multiple selection in OCC viewer.
Incorrect call is made from AIS_Selection::Select() method at line:
AIS_NListOfEntityOwner::Iterator aListIter = myResultMap.Find (theOwner);
Original issue: 0033742
2025-02-17 15:52:24 +00:00
jfa
e375bd7c3e Modeling Algorithms - UnifySameDomain improvement #371
Extend ShapeUpgrade_UnifySameDomain algorithm working on cases,
  where SurfaceOfRevolution or SurfaceOfLinearExtrusion was made on basis of TrimmedCurve.
Original issue: 0033328
2025-02-17 14:12:49 +00:00
astromko
4c5f9c77cb Modeling - Removing surface after transformation #374
Old surface is not removed after translation or rotation with geometry copying
Removed unnecessary condition that was added by an earlier fix.
Added a test case.
Original issue: 0033591
2025-02-17 14:12:43 +00:00
Pasukhin Dmitry
ed6005b75a Testing - Summarize only with success reference #377
Fix GitHub Actions workflow to filter completed runs by success status
2025-02-17 14:11:03 +00:00
Pasukhin Dmitry
04a15e36f7 Testing - Remove installation of Visual C++ 2010 #376 2025-02-17 14:10:48 +00:00
jfa
0a73cac759 Configuration - CMake symbol isolation issue on Windows #373
Fixed Salome compilation problem on Windows by M.Bernhard
2025-02-17 12:52:41 +00:00
jfa
6f42ada2e6 Modeling - SIGSEGV BRepAdaptor_Curve2d and UnifySameDomain #372
SIGSEGV with MakeVertexInsideFace.
Fixed exceptions with loading null curve and using out of range index.
By K.Leontev. [bos #37951]
2025-02-17 11:12:21 +00:00
Pasukhin Dmitry
5b574af01f Testing - WebAssembly build validation #256
Add WebAssembly build workflow for Ubuntu and update CMake warnings for OpenGL usage
Add workaround for platform-specific macros setup before project command
Update CMake configuration for Emscripten and Android toolchains;
Disable default features for vcpkg manifest
Update GitHub workflows to support multiple build types and improve compiler flag handling
Disabled DETools module for Emscripten support in CMake configuration
2025-02-14 16:08:45 +00:00
Pasukhin Dmitry
67bd61d4d3 Data Exchange - IGES Import Degenerated BSpline crash #368
Degenerated bspline leads to null dereference
Fix BSpline curve check and improve exception handling in TransferBSplineCurve
2025-02-14 13:13:53 +00:00
Pasukhin Dmitry
425f88e63a CMake - Disable building Overview by default #369
Updated default behavior to not build documentation
  when find doxygen (in case of windows it ofter exist in env variables).
Fixed issue when not defined BUILD_DOC_Overview, but found doxygen cmake issue.
2025-02-14 10:47:45 +00:00
Pasukhin Dmitry
5a186c7b1a Testing - Update GH testing to filter completed reference branch testing #365 2025-02-13 10:24:12 +00:00
Pasukhin Dmitry
fb73c3b712 Coding - Initialize member variables with default values #362
Clang-tidy applying rule for cppcoreguidelines-pro-type-member-init.
Updated: TKernel and TKMath
Update constructor in some classes instead of direct initialization
Refactor Bnd_BoundSortBox and Bnd_Box constructors to initialize member variables directly
2025-02-12 14:26:00 +00:00
Pasukhin Dmitry
a8950426b5 Data Exchange - Step Import metadata crash protecting #357
Fix null checks and improve attribute handling in STEPCAFControl_Reader
2025-02-12 14:25:19 +00:00
luzpaz
f423143109 Documentation - Fix various typos found in codebase #361
Found via `codespell -q 3 -S "*.fr" -L aadd,abnd,abord,acount,adn,afile,aline,alo,alocation,alog,als,anc,ane,anid,anormal,anout,ans,anumber,aother,aparent,apoints,aprogram,asender,asign,asnd,ba,bbuild,bloc,bord,bu,caf,cas,childrens,childs,classe,clen,commun,cylindre,don,dout,dum,ede,entites,fo,fonction,guid,hist,identic,ii,indx,inout,invalide,ist,iterm,llength,lod,mape,modeling,methode,mye,myu,nam,nd,nin,normale,normales,ons,parametre,parametres,periode,pres,reste,resul,secont,serie,shs,slin,som,somme,syntaxe,sur,te,thei,theis,ther,theres,thes,thev,thex,thet,tol,transfert,va,vas,verifie,vertexes,weight`
2025-02-11 12:38:56 +00:00
dpasukhi
87c04f1833 Coding - Bump version to 7.9.0.beta2 #359 2025-02-10 20:27:33 +00:00
Pasukhin Dmitry
49ae0d106f Data Exchange, Step Import - Disable Product Metadata mode by default #358
Add default initialization for myProductMetaMode in STEPCAFControl_Reader
2025-02-10 19:39:41 +00:00
Pasukhin Dmitry
fd03c58d3b Data Exchange - STEP Export ignore write schema #355
Refactor StepData_StepModel constructor and initialization logic for write unit
2025-02-10 15:26:39 +00:00
Pasukhin Dmitry
a5aa7bcd91 Testing - Samples build on GH #331
Add GitHub Action to build CSharp sample on Windows
Add MFC and Qt sample build actions
Improve CASROOT assignment logic in env.build.sh and env.install.sh for better compatibility with binary directories
2025-02-09 23:00:37 +00:00
Pasukhin Dmitry
9d727d09f4 Testing - Update GH Action for 7.9.0 #340
Update CAD files with new public data
Update 3rd-party archives with new versions of dependencies
Disable signal catching in bug28054_2
2025-02-09 21:20:05 +00:00
Pasukhin Dmitry
bd77f8af4a Coding - Refactor ShapeHealingMap to NCollection #346
Update container type to OCCT to avoid allocation on creating.
Refactor shape processing parameter handling to use XSAlgo_ShapeProcessor for consistency.
2025-02-08 21:01:14 +00:00
luzpaz
7e3d063cae Documentation - Fix various typos found in codebase #350 2025-02-08 09:44:51 +00:00
Zernova Marina
a1d887e0c4 Data Exchange - Fix GLTF Export for vertices and edges #348
Only free vertices and edges are exported now
2025-02-07 16:06:47 +00:00
Zernova Marina
85b40aba2a Data Exchange, GLTF Import - Fix visualization of colors #347
Fixed issue with material color space
2025-02-07 10:13:54 +00:00
oan
62e085c5ed Configuration - regression in wasm build #342
Quick fix absent definitions
2025-02-04 16:30:14 +00:00
Pasukhin Dmitry
10d1902820 Data Exchange - Schema missed during export #343
Refactor model creating to apply schema based on DE parameters.
New model creating stage no more inject header info.
2025-02-04 16:27:16 +00:00
Zernova Marina
6c77143364 Data Exchange - Fix GLTF Export Materials for edges #341
Fixed issue with edge colors
2025-02-04 09:22:45 +00:00
Zernova Marina
4b318b8bf6 Data Exchange - RWMesh_CafReader deferred loading issue for no faces #339
Fixed issue when trying to apply deferred loading for edges or vertexes.
2025-02-03 22:29:33 +00:00
Pasukhin Dmitry
bfb00b243e Configuration - TCL OCCT version extraction issue #337
Enhance version detection in OCCDoc_DetectCasVersion
Refactor documentation build workflow and integrate into multiplatform CI
2025-02-03 22:25:29 +00:00
dpasukhi
cc30b93700 Coding - Bump version to 7.9.0.beta1 #335 2025-02-03 13:35:09 +00:00
Pasukhin Dmitry
1f386af59f Coding - Update method guards for consistency #333
Apply new regex replacement with method's guards in .cxx
Update GH workflow with style checking
2025-02-03 11:16:00 +00:00
Pasukhin Dmitry
3ce9ec7651 Testing - Marking failed code formatting #332 2025-02-03 09:26:58 +00:00
mzernova
b9429d0708 GLTF Import - Edge and Vertex support #242
Added functionality to import Points and Lines from GLTF format
2025-02-02 21:30:21 +00:00
mzernova
174b985fd5 GLTF Export - Edge and Vertex support #243
Added functionality to export TopoDS_Vertex and TopoDS_Edge to GLTF format
2025-02-02 21:25:53 +00:00
Pasukhin Dmitry
053e01ec68 Testing - Inspector building on GH #329
Add GitHub Actions for TInspector build and clang-format check
Reorganize QT search to work with native Linux packages
Reorganize build-and-test workflow to have actions
2025-02-02 15:35:20 +00:00
Pasukhin Dmitry
16d36a47fc Testing - Disable summarization on cancellation #330 2025-02-02 10:34:32 +00:00
Pasukhin Dmitry
68a9da9f37 Testing - Summary image diff keeping #326
Add script to clean unused test images and update workflow to include it
2025-02-01 19:57:50 +00:00
Zernova Marina
fda875b293 Visualization - Add test for flipped view #328
Test case for #312
2025-02-01 19:56:25 +00:00
Zernova Marina
98a28c41a8 Visualization - flat skin for AIS_Manipulator presentation #321
Created flat skin for AIS_Manipulator presentation
Added "-flat" option to vmanipulator command
Added functionality to transform the manipulator depending on the camera rotation.
Added local transformation for Graphic3d_Group.
Added RecomputeTransformation method to PrsMgr_PresentableObject.
When overloading this method, you can set a transformation for an object depending on the rotation of the camera.
v3d/manipulator/flat: test case added
2025-02-01 17:20:22 +00:00
Pasukhin Dmitry
159f5b82aa Data Exchange - StepExport non-manifold missed parameter #324
Added missed configuration for non-manifold topology writing
2025-02-01 17:17:46 +00:00
Pasukhin Dmitry
afb0a7e4c4 Testing - GH Summary disabling for cancellation #325 2025-02-01 17:17:21 +00:00
Pasukhin Dmitry
45a52dfce7 Configuration - Git commit info missed #323
Fixed issue with missed git info as a part of dev version.
Add option to enable/disable git hash extraction in version string.
2025-02-01 17:16:58 +00:00
Dmitrii Kulikov
4b608f0bf8 Data Exchange, Step Import - Adding product attributes to metadata #315
Product attributes metadata for step files is now handled during import.
Attribute ReadProductMetadata is added to DESTEP_Parameters.
Method STEPCAFControl_Reader::ReadMetadata() is partially refactored.
Metadata tests for STEP are updated with new data.
Metadata tests for GLTF are updated with new data (since original
metadata in those tests is acquired from STEP files).
2025-02-01 17:16:21 +00:00
oan
60360e3204 Foundation Classes - BVH surface area calculation for transformed boxes #322
BVH::SurfaceCalculator::Area() fails to calculate area of transformed box.
Use absolute values of intermediate calculations to
  compute surface area of a box, so they do not diminish each other.
2025-02-01 00:22:19 +00:00
Pasukhin Dmitry
4012dc463e Testing - Marking Win retesting failed #314 2025-01-31 23:04:55 +00:00
Pasukhin Dmitry
8a067c43b7 Configuration - Version detection on MacOS #313
Improve version extraction and add error handling for missing version file
2025-01-31 23:04:27 +00:00
Pasukhin Dmitry
2027acc3de Configuration - Message about compiler limitation #311
Build System - Add compiler version checks for C++17 support
2025-01-31 23:04:01 +00:00
Kirill Gavrilov
73fcf4b4ed Coding, Emscripten - fix runtime crashes on WASM64 (-sMEMORY64=1) #320
by explicitly casting between BigInt and Number within EM_JS() blocks.
2025-01-31 21:06:18 +00:00
Kirill Gavrilov
69281b1bac Configuration, TKV3d - remove redundant dependency from OpenGL #319 2025-01-31 15:43:10 +00:00
Kirill Gavrilov
fb3c2c739c Visualization, OpenGl_GraduatedTrihedron - fix misprint in drawing line within OOZ_XOZ orientation #318 2025-01-31 15:41:02 +00:00
Kirill Gavrilov
104c5f4261 Data Exchange, XCAFDoc_ColorTool::AddColor() - fix generated HEX name of a color #317
Quantity_ColorRGBA::ColorToHex() is now used for consistent HEX formatting of RGBA colors.
2025-01-31 15:38:07 +00:00
Kirill Gavrilov
2d4070bed7 Visualization, Aspect_OpenVRSession - fix JSON file path when it is located relative to executable #316 2025-01-31 15:33:13 +00:00
Zernova Marina
c8c36fda1c Visualization - Implement interface to change myToFlipOutput of OpenGl_View #312 2025-01-31 13:44:31 +00:00
Pasukhin Dmitry
fbee65efd6 Configuration - Static library warning #310
Add warning message about LGPL 2.1 licensing limitations for static linking
2025-01-31 13:37:12 +00:00
Pasukhin Dmitry
d65feb6928 Configuration - Version information update #308
Refactor version handling to use version.cmake and update related scripts.
Created new symbols to extract information by C function
2025-01-31 13:17:38 +00:00
Zernova Marina
491e742d67 Visualization - AIS_Manipulator is unusable when attaching to objects with Graphic3d_TMF_ZoomPers #309
Recalculation of manipulator position if attached object has zoom transform persistence
  as well as set its anchor point in Transformation.
2025-01-31 11:26:31 +00:00
Dmitrii Kulikov
870d891898 Data Exchange - Step thread safety improvement #307
Mutex is added to XSControl_WorkSession to prevent data races
  during reading and writing.
Tests are added to check the behavior of STEP readers/writers in
  multithreading environment.
2025-01-30 17:42:07 +00:00
dpasukhi
2889518f7a Modeling - Degenerated curve on offset #301
Skip degenerated curves in BRepOffset_Tool::TryProject to improve robustness
2025-01-28 16:37:58 +00:00
dpasukhi
22126df210 Modeling - Add boundary check in BRepFill_Filling to handle empty boundaries #300 2025-01-28 16:29:56 +00:00
dpasukhi
d409a3642d Modeling - Add warning for incomplete wire detection in WireFromList #299 2025-01-28 15:49:11 +00:00
dpasukhi
8caf5157dd Modeling - Enhance intersection handling for closed curves in IntPatch_Intersection #298 2025-01-28 12:21:26 +00:00
dpasukhi
cde7baba0d Modeling - Add closed state handling in BRepLib_MakeEdge #297 2025-01-28 12:17:02 +00:00
dpasukhi
16ed3b4ced Modeling - Resetting Plane YVector #296
Fix calculation of myOY in GeomPlate_BuildAveragePlane to use cross product with OZ
2025-01-28 12:11:53 +00:00
dpasukhi
78fb1869fe Modeling - NURB Convert fix for degenerated #295
Fix logic for processing degenerated edges in NewPolygon function
2025-01-28 10:41:23 +00:00
dpasukhi
16d112481e Documentation - Update links in README #293 2025-01-27 12:37:08 +00:00
dpasukhi
bef42e89ef Revert "Configuration - Single config lib direct linking #289"
This reverts commit 81a807b6cf.
2025-01-26 18:29:45 +00:00
dpasukhi
81a807b6cf Configuration - Single config lib direct linking #289
Enhance PROCESS_CSF_LIBRARIES function to track last detected library for improved directory handling
2025-01-26 13:04:23 +00:00
dpasukhi
398c507264 Coding - Add .git-blame-ignore-revs for global formatting #288 2025-01-26 10:59:36 +00:00
dpasukhi
a5a7b3185b Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
2025-01-26 00:43:57 +00:00
14133 changed files with 1283456 additions and 1207346 deletions

View File

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

2
.git-blame-ignore-revs Normal file
View File

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

View File

@@ -1,27 +1,14 @@
# This workflow builds the OCCT reference manual and overview documentations.
# It is triggered on pushes to the 'master' branch.
# The workflow includes steps to checkout the repository, install dependencies, build the documentation, and upload the generated documentation and logs as artifacts.
name: Build Documentation name: Build Documentation
description: 'Build OCCT documentation using doxygen'
on: runs:
push: using: composite
branches: steps:
- 'master'
jobs:
build:
name: Build Refman Documentation
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.1
- name: Install dependencies - name: Install dependencies
run: | run: |
choco install -y graphviz choco install -y graphviz
choco install -y doxygen.install choco install -y doxygen.install
shell: pwsh
- name: Build refman documentation - name: Build refman documentation
run: | run: |

View File

@@ -0,0 +1,57 @@
name: 'Build CSharp Sample'
description: 'Build CSharp sample using OCCT installation'
inputs:
platform:
description: 'Build platform (windows)'
required: true
install-artifact-name:
description: 'OCCT installation artifact name'
required: true
runs:
using: "composite"
steps:
- name: Download OCCT installation
uses: actions/download-artifact@v4.1.7
with:
name: ${{ inputs.install-artifact-name }}
path: occt-install
- name: Build CSharp Sample
if: inputs.platform == 'windows'
shell: cmd
run: |
REM Setup environment
call "${{ github.workspace }}\occt-install\env.bat" vc14 win64 Release
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64
set "PATH=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;%PATH%"
cd ${{ github.workspace }}/samples/CSharp
REM First upgrade solutions to VS2022
echo "Upgrading solution files to VS2022..."
devenv.exe CSharp.sln /upgrade
devenv.exe CSharp_D3D.sln /upgrade
REM Update project platform toolset
powershell -Command "(Get-Content OCCTProxy\OCCTProxy.vcxproj) -replace '<PlatformToolset>v100</PlatformToolset>', '<PlatformToolset>v143</PlatformToolset>' | Set-Content OCCTProxy\OCCTProxy.vcxproj"
powershell -Command "(Get-Content OCCTProxy_D3D\OCCTProxy_D3D.vcxproj) -replace '<PlatformToolset>v100</PlatformToolset>', '<PlatformToolset>v143</PlatformToolset>' | Set-Content OCCTProxy_D3D\OCCTProxy_D3D.vcxproj"
REM Restore NuGet packages
echo "Upgrading solution files..."
msbuild.exe CSharp.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=restore_csharp.log;Verbosity=detailed
msbuild.exe CSharp_D3D.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=restore_d3d.log;Verbosity=detailed
REM Build solutions with real-time console output
echo "Building CSharp.sln..."
msbuild.exe CSharp.sln /p:Configuration=Release /p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=build_csharp.log;Verbosity=detailed /m
echo "Building CSharp_D3D.sln..."
msbuild.exe CSharp_D3D.sln /p:Configuration=Release /p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=build_d3d.log;Verbosity=detailed /m
- name: Upload CSharp Sample
uses: actions/upload-artifact@v4.4.3
with:
name: csharp-sample-${{ inputs.platform }}-x64
path: samples/CSharp
retention-days: 7

View File

@@ -0,0 +1,54 @@
name: 'Build MFC Sample'
description: 'Build MFC sample using OCCT installation'
inputs:
platform:
description: 'Build platform (windows)'
required: true
install-artifact-name:
description: 'OCCT installation artifact name'
required: true
runs:
using: "composite"
steps:
- name: Download OCCT installation
uses: actions/download-artifact@v4.1.7
with:
name: ${{ inputs.install-artifact-name }}
path: occt-install
- name: Build MFC Sample
if: inputs.platform == 'windows'
shell: cmd
run: |
REM Setup environment
call "${{ github.workspace }}\occt-install\env.bat" vc14 win64 Release
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64
cd ${{ github.workspace }}/samples/mfc/standard
set "PATH=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;%PATH%"
REM First restore the solution
echo "Restoring solution..."
msbuild.exe ALL-vc14.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=restore.log;Verbosity=detailed
REM Build solution with detailed logging
echo "Building solution..."
msbuild.exe ALL-vc14.sln /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=build.log;Verbosity=detailed /m
REM Display logs if build fails
if errorlevel 1 (
echo "Build failed. Contents of restore.log:"
type restore.log
echo "Contents of build.log:"
type build.log
exit /b 1
)
- name: Upload MFC Sample
uses: actions/upload-artifact@v4.4.3
with:
name: mfc-sample-${{ inputs.platform }}-x64
path: samples/mfc/
retention-days: 7

View File

@@ -0,0 +1,108 @@
name: 'Build Qt Sample'
description: 'Build Qt samples using OCCT installation'
inputs:
platform:
description: 'Build platform (windows/linux)'
required: true
install-artifact-name:
description: 'OCCT installation artifact name'
required: true
thirdparty_url:
description: 'URL to download 3rdparty dependencies'
required: false
default: 'https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip'
runs:
using: "composite"
steps:
- name: Download OCCT installation
uses: actions/download-artifact@v4.1.7
with:
name: ${{ inputs.install-artifact-name }}
path: occt-install
- name: Install Windows dependencies
if: inputs.platform == 'windows'
shell: pwsh
run: |
Invoke-WebRequest -Uri ${{ inputs.thirdparty_url }} -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip
- name: Install Linux dependencies
if: inputs.platform == 'linux'
shell: bash
run: sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake gcc g++ make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev qtbase5-dev qt5-qmake qtbase5-dev-tools qtdeclarative5-dev qttools5-dev qttools5-dev-tools
- name: Setup MSBuild
if: inputs.platform == 'windows'
uses: microsoft/setup-msbuild@v2
- name: Build Qt Samples - Windows
if: inputs.platform == 'windows'
shell: cmd
run: |
REM Setup environment
cd ${{ github.workspace }}/occt-install/
call env.bat vc14 win64 Release
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64
REM Setup Qt environment
set "QTDIR=${{ github.workspace }}\3rdparty-vc14-64\qt5.11.2-vc14-64"
set "PATH=%QTDIR%\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;%PATH%"
cd ${{ github.workspace }}/samples/qt
for %%s in (IESample Tutorial FuncDemo) do (
cd %%s
echo "Generating project for %%s..."
qmake -tp vc -r -o %%s.sln %%s0.pro
echo "Restoring %%s..."
msbuild.exe %%s.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=%%s_restore.log;Verbosity=detailed
echo "Building %%s..."
msbuild.exe %%s.sln /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=%%s_build.log;Verbosity=detailed /m
REM Display logs if build fails
if errorlevel 1 (
echo "Build failed for %%s. Contents of restore log:"
type %%s_restore.log
echo "Contents of build log:"
type %%s_build.log
exit /b 1
)
cd ..
)
- name: Build Qt Samples - Linux
if: inputs.platform == 'linux'
shell: bash
run: |
cd ${{ github.workspace }}/occt-install/bin
source env.sh
cd ${{ github.workspace }}/samples/qt
for sample in IESample Tutorial FuncDemo; do
cd $sample
aQMakePath=`which qmake`
host=`uname -s`
export STATION=$host
export RES_DIR="${{ github.workspace }}/samples/qt/${sample}/result"
qmake $sample.pro
aNbJobs="$(getconf _NPROCESSORS_ONLN)"
make -j$aNbJobs release
cd ..
done
- name: Upload Qt Samples
uses: actions/upload-artifact@v4.4.3
with:
name: qt-samples-${{ inputs.platform }}-x64
path: |
samples/qt/
samples/qt/
retention-days: 7

View File

@@ -0,0 +1,86 @@
name: 'Build TInspector'
description: 'Build TInspector using OCCT installation as a separate job'
inputs:
platform:
description: 'Build platform (windows/linux)'
required: true
install-artifact-name:
description: 'OCCT installation artifact name'
required: true
thirdparty_url:
description: 'URL to download 3rdparty dependencies'
required: false
default: 'https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip'
runs:
using: "composite"
steps:
- name: Download OCCT installation
uses: actions/download-artifact@v4.1.7
with:
name: ${{ inputs.install-artifact-name }}
path: occt-install
- name: Install Windows dependencies
if: inputs.platform == 'windows'
shell: pwsh
run: |
Invoke-WebRequest -Uri ${{ inputs.thirdparty_url }} -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip
- name: Install Linux dependencies
if: inputs.platform == 'linux'
shell: bash
run: sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake gcc g++ make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev qtbase5-dev qt5-qmake qtbase5-dev-tools qtdeclarative5-dev qttools5-dev qttools5-dev-tools
- name: Configure TInspector - Windows
if: inputs.platform == 'windows'
shell: pwsh
run: |
cd tools
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 `
-D CMAKE_BUILD_TYPE=Release `
-D BUILD_SHARED_LIBS=ON `
-D 3RDPARTY_DIR=${{ github.workspace }}//3rdparty-vc14-64 `
-D OpenCASCADE_DIR=${{ github.workspace }}/occt-install `
-D INSTALL_DIR=${{ github.workspace }}/tools/install `
..
- name: Configure TInspector - Linux
if: inputs.platform == 'linux'
shell: bash
run: |
cd tools
mkdir build
cd build
cmake -G "Unix Makefiles" \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
-D OpenCASCADE_DIR=${{ github.workspace }}/occt-install \
-D INSTALL_DIR=${{ github.workspace }}/tools/install \
..
- name: Build TInspector - Windows
if: inputs.platform == 'windows'
shell: pwsh
run: |
cd tools/build
cmake --build . --config Release --target install
- name: Build TInspector - Linux
if: inputs.platform == 'linux'
shell: bash
run: |
cd tools/build
make install -j$(nproc)
- name: Upload TInspector installation
uses: actions/upload-artifact@v4.4.3
with:
name: inspector-${{ inputs.platform }}-x64
path: tools/install
retention-days: 7

View File

@@ -0,0 +1,83 @@
name: 'Clang-Format Code Check'
description: 'Check code formatting of changed files using clang-format'
inputs:
base-ref:
description: 'Base reference to compare changes against'
required: true
default: 'master'
file-pattern:
description: 'Pattern to match files for formatting check'
required: false
default: '^(src|tools)/.*\.(cpp|hxx|cxx|lxx|h|pxx|hpp)$'
clang-format-version:
description: 'Required clang-format version'
required: false
default: '18.1.8'
outputs:
has-changes:
description: 'Whether any files needed formatting'
value: ${{ steps.git-check.outputs.has_changes }}
runs:
using: "composite"
steps:
- name: Check clang-format version
shell: pwsh
run: |
$version = clang-format --version
Write-Output "Detected clang-format version: $version"
$version | Select-String "${{ inputs.clang-format-version }}" >$null
if ($LASTEXITCODE -ne 0) {
echo "::error::Wrong clang-format version. Expected ${{ inputs.clang-format-version }}"
Write-Output "Error: Version mismatch - expected ${{ inputs.clang-format-version }}"
exit 1
}
- name: Get changed files
id: changed-files
shell: pwsh
run: |
$changedFiles = git diff --name-only origin/${{ inputs.base-ref }} HEAD |
Where-Object { $_ -match '${{ inputs.file-pattern }}' }
$changedFiles | Set-Content "changed_files.txt"
if ($changedFiles.Count -gt 0) {
echo "has_files=true" >> $env:GITHUB_OUTPUT
}
- name: Check formatting
if: steps.changed-files.outputs.has_files == 'true'
shell: pwsh
run: |
$files = Get-Content "changed_files.txt"
$files | ForEach-Object -ThrottleLimit 8 -Parallel {
clang-format -i -style=file $_
}
- name: Check git status
id: git-check
if: steps.changed-files.outputs.has_files == 'true'
shell: pwsh
run: |
git diff > format.patch
if ((Get-Item format.patch).length -gt 0) {
echo "has_changes=true" >> $env:GITHUB_OUTPUT
}
- name: Upload patch
if: steps.git-check.outputs.has_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: format-patch
path: format.patch
- name: Failing step for formatting issues
if: steps.git-check.outputs.has_changes == 'true'
shell: pwsh
run: |
echo "::error::Files need formatting. To fix: 1. Download format.patch 2. \"git apply format.patch\" 3. Commit and push"
exit 1
branding:
icon: 'check-square'
color: 'green'

View File

@@ -0,0 +1,90 @@
import os
import re
from bs4 import BeautifulSoup
from pathlib import Path
import glob
import os.path
def get_referenced_images(html_file):
# Get the directory containing the HTML file
html_dir = os.path.dirname(os.path.abspath(html_file))
with open(html_file, 'r', encoding='utf-8') as f:
soup = BeautifulSoup(f.read(), 'html.parser')
images = set()
# Extract direct image references
for img in soup.find_all('img'):
if src := img.get('src'):
# Convert relative path to absolute
abs_path = os.path.normpath(os.path.join(html_dir, src))
images.add(abs_path)
# Extract toggle references
for elem in soup.find_all(attrs={'onclick': True}):
onclick = elem['onclick']
paths = re.findall(r'diffimage_toggle\(this,"([^"]+)","([^"]+)"\)', onclick)
for src1, src2 in paths:
# Convert relative paths to absolute
abs_path1 = os.path.normpath(os.path.join(html_dir, src1))
abs_path2 = os.path.normpath(os.path.join(html_dir, src2))
images.add(abs_path1)
images.add(abs_path2)
return images
def cleanup_platform_images(results_dir, platform):
html_file = f"{results_dir}/current/{platform}/diff-*.html"
html_files = glob.glob(html_file)
if not html_files:
print(f"No diff HTML found for {platform}")
return
# Get referenced images from HTML
referenced = set()
for html in html_files:
images = get_referenced_images(html)
referenced.update(images)
# Convert relative paths to absolute
base_dir = Path(results_dir)
current_dir = base_dir / "current" / platform
master_dir = base_dir / "master" / platform
# Find all PNGs
png_files = set()
for directory in [current_dir, master_dir]:
for root, _, files in os.walk(directory):
for file in files:
if file.lower().endswith('.png'):
png_files.add(Path(root) / file)
# Remove unreferenced PNGs
for png in png_files:
if str(png) not in referenced:
try:
png.unlink()
except OSError as e:
print(f"Error removing {png}: {e}")
def main():
platforms = [
"windows-x64",
"windows-clang-x64",
"macos-x64",
"macos-gcc-x64",
"linux-clang-x64",
"linux-gcc-x64"
]
results_dir = Path("./").resolve()
for platform in platforms:
print(f"\nProcessing {platform}...")
cleanup_platform_images(results_dir, platform)
if __name__ == "__main__":
main()

View File

@@ -18,6 +18,32 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
clang-format:
name: Check code formatting
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: Run clang-format check
uses: ./.github/actions/clang-format-check
with:
base-ref: ${{ github.event.pull_request.base.ref || 'master' }}
documentation:
name: Build Documentation
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.1
- name: Build documentation
uses: ./.github/actions/build-docs
prepare-and-build-windows-x64: prepare-and-build-windows-x64:
name: Prepare and Build on Windows with MSVC (x64) name: Prepare and Build on Windows with MSVC (x64)
runs-on: windows-2022 runs-on: windows-2022
@@ -29,7 +55,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -59,6 +85,7 @@ jobs:
-D CMAKE_BUILD_TYPE=Release ` -D CMAKE_BUILD_TYPE=Release `
-D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 ` -D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 `
-D INSTALL_DIR=${{ github.workspace }}/install ` -D INSTALL_DIR=${{ github.workspace }}/install `
-D USE_D3D=ON `
-D USE_DRACO=ON ` -D USE_DRACO=ON `
-D USE_FFMPEG=ON ` -D USE_FFMPEG=ON `
-D USE_FREEIMAGE=ON ` -D USE_FREEIMAGE=ON `
@@ -95,7 +122,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -133,6 +160,7 @@ jobs:
-D CMAKE_BUILD_TYPE=Release ` -D CMAKE_BUILD_TYPE=Release `
-D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 ` -D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 `
-D INSTALL_DIR=${{ github.workspace }}/install ` -D INSTALL_DIR=${{ github.workspace }}/install `
-D USE_D3D=ON `
-D USE_DRACO=ON ` -D USE_DRACO=ON `
-D USE_FFMPEG=ON ` -D USE_FFMPEG=ON `
-D USE_FREEIMAGE=ON ` -D USE_FREEIMAGE=ON `
@@ -374,6 +402,96 @@ jobs:
path: install path: install
retention-days: 7 retention-days: 7
build-inspector-windows:
name: Build TInspector on Windows
needs: prepare-and-build-windows-x64
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Build TInspector
uses: ./.github/actions/build-tinspector
with:
platform: windows
install-artifact-name: install-windows-x64
build-inspector-linux:
name: Build TInspector on Linux
needs: prepare-and-build-linux-clang-x64
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Build TInspector
uses: ./.github/actions/build-tinspector
with:
platform: linux
install-artifact-name: install-linux-clang-x64
build-csharp-windows:
name: Build CSharp Sample on Windows
needs: prepare-and-build-windows-x64
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Build CSharp Sample
uses: ./.github/actions/build-sample-csharp
with:
platform: windows
install-artifact-name: install-windows-x64
build-mfc-windows:
name: Build MFC Sample on Windows
needs: prepare-and-build-windows-x64
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Build MFC Sample
uses: ./.github/actions/build-sample-mfc
with:
platform: windows
install-artifact-name: install-windows-x64
build-qt-windows:
name: Build Qt Sample on Windows
needs: prepare-and-build-windows-x64
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Build Qt Sample
uses: ./.github/actions/build-sample-qt
with:
platform: windows
install-artifact-name: install-windows-x64
build-qt-linux:
name: Build Qt Sample on Linux
needs: prepare-and-build-linux-clang-x64
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Build Qt Sample
uses: ./.github/actions/build-sample-qt
with:
platform: linux
install-artifact-name: install-linux-clang-x64
test-windows-x64: test-windows-x64:
name: Test on Windows (x64) name: Test on Windows (x64)
runs-on: windows-2022 runs-on: windows-2022
@@ -385,7 +503,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -393,9 +511,9 @@ jobs:
- name: Download and extract test data - name: Download and extract test data
run: | run: |
cd data cd data
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.zip -OutFile opencascade-dataset-7.8.0.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.zip -OutFile opencascade-dataset-7.9.0.zip
Expand-Archive -Path opencascade-dataset-7.8.0.zip -DestinationPath . Expand-Archive -Path opencascade-dataset-7.9.0.zip -DestinationPath .
Remove-Item opencascade-dataset-7.8.0.zip Remove-Item opencascade-dataset-7.9.0.zip
shell: pwsh shell: pwsh
- name: Download and extract install directory - name: Download and extract install directory
@@ -416,12 +534,6 @@ jobs:
.\systemwidedeploy.cmd 5 .\systemwidedeploy.cmd 5
shell: cmd shell: cmd
- name: Install Visual C++ 2010 Redistributable
run: |
choco install -y vcredist2010
refreshenv
shell: cmd
- name: Install CJK Fonts - name: Install CJK Fonts
run: | run: |
Invoke-WebRequest -Uri https://noto-website-2.storage.googleapis.com/pkgs/Noto-hinted.zip -OutFile Noto-hinted.zip Invoke-WebRequest -Uri https://noto-website-2.storage.googleapis.com/pkgs/Noto-hinted.zip -OutFile Noto-hinted.zip
@@ -498,7 +610,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -507,9 +619,9 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd data cd data
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.zip -OutFile opencascade-dataset-7.8.0.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.zip -OutFile opencascade-dataset-7.9.0.zip
Expand-Archive -Path opencascade-dataset-7.8.0.zip -DestinationPath . Expand-Archive -Path opencascade-dataset-7.9.0.zip -DestinationPath .
Remove-Item opencascade-dataset-7.8.0.zip Remove-Item opencascade-dataset-7.9.0.zip
shell: pwsh shell: pwsh
- name: Download and extract install directory - name: Download and extract install directory
@@ -533,13 +645,6 @@ jobs:
.\systemwidedeploy.cmd 5 .\systemwidedeploy.cmd 5
shell: cmd shell: cmd
- name: Install Visual C++ 2010 Redistributable
if: steps.check_failures.outputs.failed_count > 0
run: |
choco install -y vcredist2010
refreshenv
shell: cmd
- name: Install CJK Fonts - name: Install CJK Fonts
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
@@ -596,8 +701,15 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd install/results/windows-x64-retest cd install/results/windows-x64-retest
$failedCount = 0
if (Test-Path tests.log) { if (Test-Path tests.log) {
$failedCount = (Select-String -Path tests.log -Pattern "Total cases:.*FAILED" | ForEach-Object { $_.Matches } | ForEach-Object { $_.Groups[1].Value }) -as [int] $content = Get-Content tests.log
$totalLine = $content | Select-String "Total cases:"
if ($totalLine) {
if ($totalLine -match "FAILED") {
$failedCount = ($totalLine | ForEach-Object { $_.Line -replace '.*?(\d+) FAILED.*','$1' }) -as [int]
}
}
if ($failedCount -gt 0) { if ($failedCount -gt 0) {
Write-Error "Number of FAILED tests ($failedCount) exceeds threshold of 0" Write-Error "Number of FAILED tests ($failedCount) exceeds threshold of 0"
echo "FAILED_COUNT=$failedCount" >> $env:GITHUB_ENV echo "FAILED_COUNT=$failedCount" >> $env:GITHUB_ENV
@@ -619,7 +731,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -627,9 +739,9 @@ jobs:
- name: Download and extract test data - name: Download and extract test data
run: | run: |
cd data cd data
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.zip -OutFile opencascade-dataset-7.8.0.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.zip -OutFile opencascade-dataset-7.9.0.zip
Expand-Archive -Path opencascade-dataset-7.8.0.zip -DestinationPath . Expand-Archive -Path opencascade-dataset-7.9.0.zip -DestinationPath .
Remove-Item opencascade-dataset-7.8.0.zip Remove-Item opencascade-dataset-7.9.0.zip
shell: pwsh shell: pwsh
- name: Download and extract install directory - name: Download and extract install directory
@@ -650,12 +762,6 @@ jobs:
.\systemwidedeploy.cmd 5 .\systemwidedeploy.cmd 5
shell: cmd shell: cmd
- name: Install Visual C++ 2010 Redistributable
run: |
choco install -y vcredist2010
refreshenv
shell: cmd
- name: Install CJK Fonts - name: Install CJK Fonts
run: | run: |
Invoke-WebRequest -Uri https://noto-website-2.storage.googleapis.com/pkgs/Noto-hinted.zip -OutFile Noto-hinted.zip Invoke-WebRequest -Uri https://noto-website-2.storage.googleapis.com/pkgs/Noto-hinted.zip -OutFile Noto-hinted.zip
@@ -732,7 +838,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -741,9 +847,9 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd data cd data
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.zip -OutFile opencascade-dataset-7.8.0.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.zip -OutFile opencascade-dataset-7.9.0.zip
Expand-Archive -Path opencascade-dataset-7.8.0.zip -DestinationPath . Expand-Archive -Path opencascade-dataset-7.9.0.zip -DestinationPath .
Remove-Item opencascade-dataset-7.8.0.zip Remove-Item opencascade-dataset-7.9.0.zip
shell: pwsh shell: pwsh
- name: Download and extract install directory - name: Download and extract install directory
@@ -767,13 +873,6 @@ jobs:
.\systemwidedeploy.cmd 5 .\systemwidedeploy.cmd 5
shell: cmd shell: cmd
- name: Install Visual C++ 2010 Redistributable
if: steps.check_failures.outputs.failed_count > 0
run: |
choco install -y vcredist2010
refreshenv
shell: cmd
- name: Install CJK Fonts - name: Install CJK Fonts
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
@@ -830,8 +929,15 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd install/results/windows-clang-x64-retest cd install/results/windows-clang-x64-retest
$failedCount = 0
if (Test-Path tests.log) { if (Test-Path tests.log) {
$failedCount = (Select-String -Path tests.log -Pattern "Total cases:.*FAILED" | ForEach-Object { $_.Matches } | ForEach-Object { $_.Groups[1].Value }) -as [int] $content = Get-Content tests.log
$totalLine = $content | Select-String "Total cases:"
if ($totalLine) {
if ($totalLine -match "FAILED") {
$failedCount = ($totalLine | ForEach-Object { $_.Line -replace '.*?(\d+) FAILED.*','$1' }) -as [int]
}
}
if ($failedCount -gt 0) { if ($failedCount -gt 0) {
Write-Error "Number of FAILED tests ($failedCount) exceeds threshold of 0" Write-Error "Number of FAILED tests ($failedCount) exceeds threshold of 0"
echo "FAILED_COUNT=$failedCount" >> $env:GITHUB_ENV echo "FAILED_COUNT=$failedCount" >> $env:GITHUB_ENV
@@ -860,8 +966,8 @@ jobs:
- name: Download test data - name: Download test data
run: | run: |
cd data cd data
curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
uses: actions/download-artifact@v4.1.7 uses: actions/download-artifact@v4.1.7
@@ -954,8 +1060,8 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd data cd data
curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
@@ -1051,8 +1157,8 @@ jobs:
- name: Download test data - name: Download test data
run: | run: |
cd data cd data
curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
uses: actions/download-artifact@v4.1.7 uses: actions/download-artifact@v4.1.7
@@ -1145,8 +1251,8 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd data cd data
curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz curl -L -O https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
@@ -1241,8 +1347,8 @@ jobs:
- name: Download test data - name: Download test data
run: | run: |
cd data cd data
wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
uses: actions/download-artifact@v4.1.7 uses: actions/download-artifact@v4.1.7
@@ -1334,8 +1440,8 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd data cd data
wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
@@ -1427,8 +1533,8 @@ jobs:
- name: Download test data - name: Download test data
run: | run: |
cd data cd data
wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
uses: actions/download-artifact@v4.1.7 uses: actions/download-artifact@v4.1.7
@@ -1520,8 +1626,8 @@ jobs:
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
run: | run: |
cd data cd data
wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/opencascade-dataset-7.9.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz tar -xf opencascade-dataset-7.9.0.tar.xz
- name: Download and extract install directory - name: Download and extract install directory
if: steps.check_failures.outputs.failed_count > 0 if: steps.check_failures.outputs.failed_count > 0
@@ -1597,7 +1703,7 @@ jobs:
test-summary: test-summary:
name: 'Summarize Test Results' name: 'Summarize Test Results'
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
if: always() && github.event_name == 'pull_request' if: ${{ !cancelled() && github.event_name == 'pull_request' }}
needs: [retest-windows-x64, retest-windows-clang-x64, retest-macos-x64, retest-macos-gcc-x64, retest-linux-clang-x64, retest-linux-gcc-x64] needs: [retest-windows-x64, retest-windows-clang-x64, retest-macos-x64, retest-macos-gcc-x64, retest-linux-clang-x64, retest-linux-gcc-x64]
steps: steps:
@@ -1629,7 +1735,7 @@ jobs:
run: | run: |
response=$(curl -s \ response=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs?branch=${{ github.event.pull_request.base.ref }}") "https://api.github.com/repos/${{ github.repository }}/actions/runs?branch=${{ github.event.pull_request.base.ref }}&status=success")
latest_run_id=$(echo "$response" | jq -r '.workflow_runs[] | select(.name=="Build and Test OCCT on Multiple Platforms") | .id' | head -n 1) latest_run_id=$(echo "$response" | jq -r '.workflow_runs[] | select(.name=="Build and Test OCCT on Multiple Platforms") | .id' | head -n 1)
echo "latest_run_id=$latest_run_id" >> $GITHUB_ENV echo "latest_run_id=$latest_run_id" >> $GITHUB_ENV
@@ -1661,13 +1767,25 @@ jobs:
done done
wait wait
- name: Install BeautifulSoup
run: pip install beautifulsoup4
- name: Clean unused test images
run: |
# copy to the install/bin/results directory
cp ${{ github.workspace }}/.github/actions/scripts/cleanup_test_images.py install/bin/results
cd install/bin/results
python cleanup_test_images.py
- name: Upload comparison results - name: Upload comparison results
uses: actions/upload-artifact@v4.4.3 uses: actions/upload-artifact@v4.4.3
with: with:
name: test-compare-results name: test-compare-results
retention-days: 15
overwrite: true overwrite: true
path: | path: |
install/bin/results/current/**/diff-*.html install/bin/results/**/diff-*.html
install/bin/results/current/**/diff-*.log install/bin/results/**/diff-*.log
install/bin/results/current/**/summary.html install/bin/results/**/summary.html
install/bin/results/current/**/tests.log install/bin/results/**/tests.log
install/bin/results/**/*.png

View File

@@ -27,6 +27,7 @@ jobs:
cxx: "x86_64-w64-mingw32-g++", cxx: "x86_64-w64-mingw32-g++",
package: "mingw-w64-x86_64-toolchain", package: "mingw-w64-x86_64-toolchain",
thirdparty_dir: "/mingw64", thirdparty_dir: "/mingw64",
compiler_flags: "",
dependencies: "mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-rapidjson mingw-w64-x86_64-freetype mingw-w64-x86_64-draco mingw-w64-x86_64-freeimage mingw-w64-x86_64-tbb mingw-w64-x86_64-tk mingw-w64-x86_64-tcl mingw-w64-x86_64-openvr mingw-w64-x86_64-jemalloc mingw-w64-x86_64-mesa mingw-w64-x86_64-angleproject mingw-w64-x86_64-llvm-openmp mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libwinpthread-git mingw-w64-cross-mingwarm64-winpthreads" dependencies: "mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-rapidjson mingw-w64-x86_64-freetype mingw-w64-x86_64-draco mingw-w64-x86_64-freeimage mingw-w64-x86_64-tbb mingw-w64-x86_64-tk mingw-w64-x86_64-tcl mingw-w64-x86_64-openvr mingw-w64-x86_64-jemalloc mingw-w64-x86_64-mesa mingw-w64-x86_64-angleproject mingw-w64-x86_64-llvm-openmp mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libwinpthread-git mingw-w64-cross-mingwarm64-winpthreads"
} }
- { - {
@@ -35,6 +36,7 @@ jobs:
cxx: "clang++", cxx: "clang++",
package: "mingw-w64-clang-x86_64-toolchain", package: "mingw-w64-clang-x86_64-toolchain",
thirdparty_dir: "/clang64", thirdparty_dir: "/clang64",
compiler_flags: "-D CMAKE_CXX_FLAGS=\"-Wall -Wextra\" -D CMAKE_C_FLAGS=\"-Wall -Wextra\"",
dependencies: "mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-ninja mingw-w64-clang-x86_64-rapidjson mingw-w64-clang-x86_64-freetype mingw-w64-clang-x86_64-draco mingw-w64-clang-x86_64-freeimage mingw-w64-clang-x86_64-tbb mingw-w64-clang-x86_64-tk mingw-w64-clang-x86_64-tcl mingw-w64-clang-x86_64-openvr mingw-w64-clang-x86_64-jemalloc mingw-w64-clang-x86_64-mesa mingw-w64-clang-x86_64-angleproject mingw-w64-clang-x86_64-llvm-openmp mingw-w64-clang-x86_64-winpthreads-git mingw-w64-clang-x86_64-libwinpthread-git mingw-w64-cross-mingwarm64-winpthreads" dependencies: "mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-ninja mingw-w64-clang-x86_64-rapidjson mingw-w64-clang-x86_64-freetype mingw-w64-clang-x86_64-draco mingw-w64-clang-x86_64-freeimage mingw-w64-clang-x86_64-tbb mingw-w64-clang-x86_64-tk mingw-w64-clang-x86_64-tcl mingw-w64-clang-x86_64-openvr mingw-w64-clang-x86_64-jemalloc mingw-w64-clang-x86_64-mesa mingw-w64-clang-x86_64-angleproject mingw-w64-clang-x86_64-llvm-openmp mingw-w64-clang-x86_64-winpthreads-git mingw-w64-clang-x86_64-libwinpthread-git mingw-w64-cross-mingwarm64-winpthreads"
} }
- { - {
@@ -43,8 +45,10 @@ jobs:
cxx: "x86_64-w64-mingw32-g++", cxx: "x86_64-w64-mingw32-g++",
package: "mingw-w64-ucrt-x86_64-toolchain", package: "mingw-w64-ucrt-x86_64-toolchain",
thirdparty_dir: "/ucrt64", thirdparty_dir: "/ucrt64",
compiler_flags: "",
dependencies: "mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-gcc-libs mingw-w64-ucrt-x86_64-omp mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-rapidjson mingw-w64-ucrt-x86_64-freetype mingw-w64-ucrt-x86_64-draco mingw-w64-ucrt-x86_64-freeimage mingw-w64-ucrt-x86_64-tbb mingw-w64-ucrt-x86_64-tk mingw-w64-ucrt-x86_64-tcl mingw-w64-ucrt-x86_64-openvr mingw-w64-ucrt-x86_64-jemalloc mingw-w64-ucrt-x86_64-mesa mingw-w64-ucrt-x86_64-angleproject mingw-w64-ucrt-x86_64-llvm-openmp mingw-w64-ucrt-x86_64-winpthreads-git mingw-w64-ucrt-x86_64-libwinpthread-git mingw-w64-cross-mingwarm64-winpthreads" dependencies: "mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-gcc-libs mingw-w64-ucrt-x86_64-omp mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-rapidjson mingw-w64-ucrt-x86_64-freetype mingw-w64-ucrt-x86_64-draco mingw-w64-ucrt-x86_64-freeimage mingw-w64-ucrt-x86_64-tbb mingw-w64-ucrt-x86_64-tk mingw-w64-ucrt-x86_64-tcl mingw-w64-ucrt-x86_64-openvr mingw-w64-ucrt-x86_64-jemalloc mingw-w64-ucrt-x86_64-mesa mingw-w64-ucrt-x86_64-angleproject mingw-w64-ucrt-x86_64-llvm-openmp mingw-w64-ucrt-x86_64-winpthreads-git mingw-w64-ucrt-x86_64-libwinpthread-git mingw-w64-cross-mingwarm64-winpthreads"
} }
build_type: [Debug, Release]
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -77,14 +81,14 @@ jobs:
-D CMAKE_C_COMPILER=${{ matrix.config.cc }} \ -D CMAKE_C_COMPILER=${{ matrix.config.cc }} \
-D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \ -D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
-D CMAKE_PREFIX_PATH=$MSYSTEM_PREFIX \ -D CMAKE_PREFIX_PATH=$MSYSTEM_PREFIX \
-D CMAKE_CXX_FLAGS="-Wall -Wextra" \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D CMAKE_C_FLAGS="-Wall -Wextra" .. ${{ matrix.config.compiler_flags }} ..
- name: Build basic - name: Build basic
shell: msys2 {0} shell: msys2 {0}
run: | run: |
cd build cd build
cmake --build . -- -j 4 cmake --build . --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
shell: pwsh shell: pwsh
@@ -105,9 +109,9 @@ jobs:
-D BUILD_OPT_PROFILE=Production \ -D BUILD_OPT_PROFILE=Production \
-D BUILD_LIBRARY_TYPE=Shared \ -D BUILD_LIBRARY_TYPE=Shared \
-D USE_TK=ON \ -D USE_TK=ON \
-D CMAKE_BUILD_TYPE=Debug \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D USE_MMGR_TYPE=JEMALLOC \ -D USE_MMGR_TYPE=JEMALLOC \
-D INSTALL_DIR="${{ github.workspace }}/install" \ -D INSTALL_DIR="${{ github.workspace }}/install-${{ matrix.build_type }}" \
-D USE_FREETYPE=ON \ -D USE_FREETYPE=ON \
-D USE_DRACO=ON \ -D USE_DRACO=ON \
-D USE_FFMPEG=OFF \ -D USE_FFMPEG=OFF \
@@ -118,20 +122,19 @@ jobs:
-D USE_TBB=OFF \ -D USE_TBB=OFF \
-D USE_RAPIDJSON=ON \ -D USE_RAPIDJSON=ON \
-D USE_OPENGL=ON \ -D USE_OPENGL=ON \
-D CMAKE_CXX_FLAGS="-Wall -Wextra" \ ${{ matrix.config.compiler_flags }} ..
-D CMAKE_C_FLAGS="-Wall -Wextra" ..
- name: Build full shared - name: Build full shared
shell: msys2 {0} shell: msys2 {0}
run: | run: |
cd build cd build
cmake --build . --target install --config Debug -- -j 4 cmake --build . --target install --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
shell: pwsh shell: pwsh
run: | run: |
Remove-Item -Recurse -Force build Remove-Item -Recurse -Force build
Remove-Item -Recurse -Force ${{ github.workspace }}/install Remove-Item -Recurse -Force ${{ github.workspace }}/install-${{ matrix.build_type }}
- name: Configure full static - name: Configure full static
shell: msys2 {0} shell: msys2 {0}
@@ -144,12 +147,12 @@ jobs:
-D CMAKE_PREFIX_PATH=$MSYSTEM_PREFIX \ -D CMAKE_PREFIX_PATH=$MSYSTEM_PREFIX \
-D BUILD_USE_PCH=OFF \ -D BUILD_USE_PCH=OFF \
-D BUILD_INCLUDE_SYMLINK=ON \ -D BUILD_INCLUDE_SYMLINK=ON \
-D BUILD_OPT_PROFILE=Production \ -D BUILD_OPT_PROFILE=Default \
-D BUILD_LIBRARY_TYPE=Static \ -D BUILD_LIBRARY_TYPE=Static \
-D USE_TK=ON \ -D USE_TK=ON \
-D CMAKE_BUILD_TYPE=Debug \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D USE_MMGR_TYPE=JEMALLOC \ -D USE_MMGR_TYPE=JEMALLOC \
-D INSTALL_DIR="${{ github.workspace }}/install" \ -D INSTALL_DIR="${{ github.workspace }}/install-${{ matrix.build_type }}" \
-D USE_FREETYPE=ON \ -D USE_FREETYPE=ON \
-D USE_DRACO=ON \ -D USE_DRACO=ON \
-D USE_FFMPEG=OFF \ -D USE_FFMPEG=OFF \
@@ -160,20 +163,19 @@ jobs:
-D USE_TBB=OFF \ -D USE_TBB=OFF \
-D USE_RAPIDJSON=ON \ -D USE_RAPIDJSON=ON \
-D USE_OPENGL=ON \ -D USE_OPENGL=ON \
-D CMAKE_CXX_FLAGS="-Wall -Wextra" \ ${{ matrix.config.compiler_flags }} ..
-D CMAKE_C_FLAGS="-Wall -Wextra" ..
- name: Build full static - name: Build full static
shell: msys2 {0} shell: msys2 {0}
run: | run: |
cd build cd build
cmake --build . --target install --config Debug -- -j 4 cmake --build . --target install --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
shell: pwsh shell: pwsh
run: | run: |
Remove-Item -Recurse -Force build Remove-Item -Recurse -Force build
Remove-Item -Recurse -Force ${{ github.workspace }}/install Remove-Item -Recurse -Force ${{ github.workspace }}/install-${{ matrix.build_type }}
- name: Configure full with DEBUG define - name: Configure full with DEBUG define
shell: msys2 {0} shell: msys2 {0}
@@ -190,8 +192,8 @@ jobs:
-D BUILD_OPT_PROFILE=Production \ -D BUILD_OPT_PROFILE=Production \
-D BUILD_LIBRARY_TYPE=Shared \ -D BUILD_LIBRARY_TYPE=Shared \
-D USE_TK=ON \ -D USE_TK=ON \
-D CMAKE_BUILD_TYPE=Debug \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D INSTALL_DIR="${{ github.workspace }}/install" \ -D INSTALL_DIR="${{ github.workspace }}/install-${{ matrix.build_type }}" \
-D USE_FREETYPE=ON \ -D USE_FREETYPE=ON \
-D USE_DRACO=ON \ -D USE_DRACO=ON \
-D USE_FFMPEG=OFF \ -D USE_FFMPEG=OFF \
@@ -201,16 +203,17 @@ jobs:
-D USE_VTK=OFF \ -D USE_VTK=OFF \
-D USE_TBB=OFF \ -D USE_TBB=OFF \
-D USE_RAPIDJSON=ON \ -D USE_RAPIDJSON=ON \
-D USE_OPENGL=ON .. -D USE_OPENGL=ON \
${{ matrix.config.compiler_flags }} ..
- name: Build full with DEBUG define - name: Build full with DEBUG define
shell: msys2 {0} shell: msys2 {0}
run: | run: |
cd build cd build
cmake --build . --target install --config Debug -- -j 4 cmake --build . --target install --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
shell: pwsh shell: pwsh
run: | run: |
Remove-Item -Recurse -Force build Remove-Item -Recurse -Force build
Remove-Item -Recurse -Force ${{ github.workspace }}/install Remove-Item -Recurse -Force ${{ github.workspace }}/install-${{ matrix.build_type }}

View File

@@ -51,7 +51,7 @@ jobs:
- name: Download and extract 3rdparty dependencies - name: Download and extract 3rdparty dependencies
run: | run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath . Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip Remove-Item 3rdparty-vc14-64.zip
shell: pwsh shell: pwsh
@@ -141,7 +141,7 @@ jobs:
-D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} ` -D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} `
-D BUILD_USE_PCH=OFF ` -D BUILD_USE_PCH=OFF `
-D BUILD_INCLUDE_SYMLINK=ON ` -D BUILD_INCLUDE_SYMLINK=ON `
-D BUILD_OPT_PROFILE=Production ` -D BUILD_OPT_PROFILE=Default `
-D BUILD_LIBRARY_TYPE=Static ` -D BUILD_LIBRARY_TYPE=Static `
-D CMAKE_BUILD_TYPE=Debug ` -D CMAKE_BUILD_TYPE=Debug `
-D INSTALL_DIR=${{ github.workspace }}/install ` -D INSTALL_DIR=${{ github.workspace }}/install `

View File

@@ -24,13 +24,16 @@ jobs:
- { - {
name: "GCC", name: "GCC",
cc: "gcc", cc: "gcc",
cxx: "g++" cxx: "g++",
compiler_flags: ""
} }
- { - {
name: "Clang", name: "Clang",
cc: "clang", cc: "clang",
cxx: "clang++" cxx: "clang++",
compiler_flags: "-D CMAKE_CXX_FLAGS=\"-Werror -Wall -Wextra\" -D CMAKE_C_FLAGS=\"-Werror -Wall -Wextra\""
} }
build_type: [Debug, Release]
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -51,13 +54,13 @@ jobs:
cmake -G "Ninja" \ cmake -G "Ninja" \
-D CMAKE_C_COMPILER=${{ matrix.config.cc }} \ -D CMAKE_C_COMPILER=${{ matrix.config.cc }} \
-D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \ -D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" .. ${{ matrix.config.compiler_flags }} ..
- name: Build basic - name: Build basic
run: | run: |
cd build cd build
cmake --build . -- -j 4 cmake --build . --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
run: | run: |
@@ -75,9 +78,9 @@ jobs:
-D BUILD_OPT_PROFILE=Production \ -D BUILD_OPT_PROFILE=Production \
-D BUILD_LIBRARY_TYPE=Shared \ -D BUILD_LIBRARY_TYPE=Shared \
-D USE_TK=ON \ -D USE_TK=ON \
-D CMAKE_BUILD_TYPE=Debug \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D USE_MMGR_TYPE=JEMALLOC \ -D USE_MMGR_TYPE=JEMALLOC \
-D INSTALL_DIR=${{ github.workspace }}/install \ -D INSTALL_DIR=${{ github.workspace }}/install-${{ matrix.build_type }} \
-D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \ -D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \
-D USE_FREETYPE=ON \ -D USE_FREETYPE=ON \
-D USE_DRACO=ON \ -D USE_DRACO=ON \
@@ -89,18 +92,17 @@ jobs:
-D USE_TBB=ON \ -D USE_TBB=ON \
-D USE_RAPIDJSON=ON \ -D USE_RAPIDJSON=ON \
-D USE_OPENGL=ON \ -D USE_OPENGL=ON \
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ ${{ matrix.config.compiler_flags }} ..
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ..
- name: Build full shared - name: Build full shared
run: | run: |
cd build cd build
cmake --build . --target install --config Debug -- -j 4 cmake --build . --target install --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
run: | run: |
rm -rf build rm -rf build
rm -rf ${{ github.workspace }}/install rm -rf ${{ github.workspace }}/install-${{ matrix.build_type }}
- name: Configure full static - name: Configure full static
run: | run: |
@@ -111,12 +113,12 @@ jobs:
-D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \ -D CMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
-D BUILD_USE_PCH=OFF \ -D BUILD_USE_PCH=OFF \
-D BUILD_INCLUDE_SYMLINK=ON \ -D BUILD_INCLUDE_SYMLINK=ON \
-D BUILD_OPT_PROFILE=Production \ -D BUILD_OPT_PROFILE=Default \
-D BUILD_LIBRARY_TYPE=Static \ -D BUILD_LIBRARY_TYPE=Static \
-D USE_TK=ON \ -D USE_TK=ON \
-D CMAKE_BUILD_TYPE=Debug \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D USE_MMGR_TYPE=JEMALLOC \ -D USE_MMGR_TYPE=JEMALLOC \
-D INSTALL_DIR=${{ github.workspace }}/install \ -D INSTALL_DIR=${{ github.workspace }}/install-${{ matrix.build_type }} \
-D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \ -D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \
-D USE_FREETYPE=ON \ -D USE_FREETYPE=ON \
-D USE_DRACO=ON \ -D USE_DRACO=ON \
@@ -128,18 +130,17 @@ jobs:
-D USE_TBB=ON \ -D USE_TBB=ON \
-D USE_RAPIDJSON=ON \ -D USE_RAPIDJSON=ON \
-D USE_OPENGL=ON \ -D USE_OPENGL=ON \
-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ ${{ matrix.config.compiler_flags }} ..
-D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ..
- name: Build full static - name: Build full static
run: | run: |
cd build cd build
cmake --build . --target install --config Debug -- -j 4 cmake --build . --target install --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
run: | run: |
rm -rf build rm -rf build
rm -rf ${{ github.workspace }}/install rm -rf ${{ github.workspace }}/install-${{ matrix.build_type }}
- name: Configure full with DEBUG define - name: Configure full with DEBUG define
run: | run: |
@@ -154,8 +155,8 @@ jobs:
-D BUILD_OPT_PROFILE=Production \ -D BUILD_OPT_PROFILE=Production \
-D BUILD_LIBRARY_TYPE=Shared \ -D BUILD_LIBRARY_TYPE=Shared \
-D USE_TK=ON \ -D USE_TK=ON \
-D CMAKE_BUILD_TYPE=Debug \ -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-D INSTALL_DIR=${{ github.workspace }}/install \ -D INSTALL_DIR=${{ github.workspace }}/install-${{ matrix.build_type }} \
-D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \ -D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \
-D USE_FREETYPE=ON \ -D USE_FREETYPE=ON \
-D USE_DRACO=ON \ -D USE_DRACO=ON \
@@ -171,9 +172,9 @@ jobs:
- name: Build full with DEBUG define - name: Build full with DEBUG define
run: | run: |
cd build cd build
cmake --build . --target install --config Debug -- -j 4 cmake --build . --target install --config ${{ matrix.build_type }} -- -j 4
- name: Clear up after build - name: Clear up after build
run: | run: |
rm -rf build rm -rf build
rm -rf ${{ github.workspace }}/install rm -rf ${{ github.workspace }}/install-${{ matrix.build_type }}

View File

@@ -0,0 +1,102 @@
# This workflow validates the WebAssembly build on Ubuntu.
# It is triggered on pushes to the master branch.
# The workflow includes steps to install dependencies, configure, build, and clean up the project.
name: WebAssembly build (Ubuntu)
on:
push:
branches:
- 'master'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
env:
USERNAME: Open-Cascade-SAS
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: https://nuget.pkg.github.com/Open-Cascade-SAS/index.json
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/Open-Cascade-SAS/index.json,readwrite"
EMSDK_VERSION: 3.1.74
jobs:
wasm-build:
name: WebAssembly Build
runs-on: ubuntu-24.04
strategy:
matrix:
build_type: [Debug, Release]
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential ninja-build curl zip unzip tar nasm autoconf mono-complete
sudo apt-get install -y libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev
- name: Setup vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
- name: Add NuGet sources
run: |
mono $(${VCPKG_EXE} fetch nuget | tail -n 1) \
sources add \
-Source "${FEED_URL}" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${USERNAME}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono $(${VCPKG_EXE} fetch nuget | tail -n 1) \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-Source "${FEED_URL}"
- name: Setup Emscripten
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${EMSDK_VERSION}
./emsdk activate ${EMSDK_VERSION}
echo "EMSDK=${{ github.workspace }}/emsdk" >> $GITHUB_ENV
echo "${{ github.workspace }}/emsdk" >> $GITHUB_PATH
echo "${{ github.workspace }}/emsdk/upstream/emscripten" >> $GITHUB_PATH
- name: Configure OCCT with vcpkg
run: |
source "${{ github.workspace }}/emsdk/emsdk_env.sh"
mkdir -p "build-${{ matrix.build_type }}"
cd "build-${{ matrix.build_type }}"
export VCPKG_ROOT="${{ github.workspace }}/vcpkg"
emcmake cmake -G "Ninja" \
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=wasm32-emscripten \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DBUILD_USE_VCPKG=ON \
-DUSE_MMGR_TYPE=NATIVE \
-DBUILD_LIBRARY_TYPE=Static \
-DBUILD_MODULE_Draw=OFF \
-DUSE_FREETYPE=OFF \
-DUSE_TK=OFF \
-DUSE_TCL=OFF \
-DUSE_DRACO=ON \
-DUSE_FFMPEG=OFF \
-DUSE_FREEIMAGE=OFF \
-DUSE_OPENVR=OFF \
-DUSE_VTK=OFF \
-DUSE_TBB=OFF \
-DUSE_RAPIDJSON=ON \
-DINSTALL_DIR="${{ github.workspace }}/install-wasm-${{ matrix.build_type }}" \
-DCMAKE_CXX_FLAGS="-s WASM=1 -s EXPORTED_RUNTIME_METHODS=['ccall','cwrap'] -s ALLOW_MEMORY_GROWTH=1" \
-DCMAKE_EXECUTABLE_SUFFIX=".js" ..
- name: Build
run: |
cd build-${{ matrix.build_type }}
cmake --build . --config ${{ matrix.build_type }} --target install -- -j4

View File

@@ -25,7 +25,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04, windows-2022, windows-2019, macos-15, macos-14, macos-13] os: [ubuntu-24.04, ubuntu-22.04, windows-2022, windows-2019, macos-15, macos-14, macos-13]
build_type: [Debug, Release] build_type: [Debug, Release]
steps: steps:

3
.gitignore vendored
View File

@@ -54,4 +54,5 @@ win64
/libtool /libtool
/stamp* /stamp*
/build* /build*
/install /install*
/tools/build*

View File

@@ -32,6 +32,30 @@ if (BUILD_USE_VCPKG)
endif() endif()
set (VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/adm/vcpkg") set (VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/adm/vcpkg")
# Disable default features for vcpkg manifest
set (VCPKG_MANIFEST_NO_DEFAULT_FEATURES 1)
# detection for Emscripten toolchain
if(CMAKE_TOOLCHAIN_FILE MATCHES ".*mscripten\.cmake$" OR "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" MATCHES ".*mscripten\.cmake$")
set(EMSCRIPTEN 1)
endif()
# detection for Android toolchain
if(CMAKE_TOOLCHAIN_FILE MATCHES ".*ndroid\.toolchain\.cmake$" OR "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" MATCHES ".*ndroid\.toolchain\.cmake$")
set(ANDROID 1)
endif()
# detection for android common variables
if (NOT "${CMAKE_ANDROID_NDK}" STREQUAL "" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Android" OR NOT "${ANDROID_NDK}" STREQUAL "")
set (ANDROID 1)
endif()
else()
# Setting up the system and compiler specific variables.
# Can't be done on early stages with VCPKG enabled.
# VCPKG installing dependencies as soon as call PROJECT,
# but for then moment need to define required list of dependencies.
PROJECT (OCCT)
endif() endif()
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake") set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake")
@@ -93,8 +117,17 @@ if ("${BUILD_LIBRARY_TYPE}" STREQUAL "Shared")
set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE) set (BUILD_SHARED_LIBRARY_NAME_POSTFIX "" CACHE STRING "${BUILD_SHARED_LIBRARY_NAME_POSTFIX_DESCR}" FORCE)
endif() endif()
else() else()
message(AUTHOR_WARNING "OCCT is licensed under LGPL 2.1, which has limitations on"
"static linking with proprietary software."
"OCCT3D offers commercial licensing exceptions to LGPL 2.1."
"Please use our contact form at https://occt3d.com/")
unset (BUILD_SHARED_LIBS) unset (BUILD_SHARED_LIBS)
unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX) unset (BUILD_SHARED_LIBRARY_NAME_POSTFIX)
if (BUILD_OPT_PROFILE STREQUAL "Production")
set (BUILD_OPT_PROFILE "Default" CACHE STRING "Select profile for compiler and linker." FORCE)
message(WARNING "Static libraries are not optimized for production builds. "
"Please use shared libraries for production builds.")
endif()
endif() endif()
if (WIN32) if (WIN32)
@@ -191,6 +224,11 @@ if (NOT DEFINED BUILD_INCLUDE_SYMLINK)
set (BUILD_INCLUDE_SYMLINK OFF CACHE BOOL "${BUILD_INCLUDE_SYMLINK_DESCR}") set (BUILD_INCLUDE_SYMLINK OFF CACHE BOOL "${BUILD_INCLUDE_SYMLINK_DESCR}")
endif() endif()
# Overview
if (NOT DEFINED BUILD_DOC_Overview)
set (BUILD_DOC_Overview OFF CACHE BOOL "${BUILD_DOC_Overview_DESCR}")
endif()
if (CMAKE_VERSION VERSION_LESS "3.14") if (CMAKE_VERSION VERSION_LESS "3.14")
OCCT_CHECK_AND_UNSET (BUILD_INCLUDE_SYMLINK) OCCT_CHECK_AND_UNSET (BUILD_INCLUDE_SYMLINK)
endif() endif()
@@ -369,6 +407,10 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND BUILD_MODULE_Draw)
message (STATUS "Info. Draw module is turned off due to it is not supported on UWP") message (STATUS "Info. Draw module is turned off due to it is not supported on UWP")
set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE) set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
endif() endif()
if (EMSCRIPTEN AND BUILD_MODULE_DETools)
message (STATUS "Info. DETools module is turned off due to it is not supported on Emscripten")
set (BUILD_MODULE_DETools OFF CACHE BOOL "${BUILD_MODULE_DETools_DESCR}" FORCE)
endif()
# accumulate used toolkits (first level) in BUILD_TOOLKITS variable # accumulate used toolkits (first level) in BUILD_TOOLKITS variable
list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS}) list (APPEND BUILD_TOOLKITS ${BUILD_ADDITIONAL_TOOLKITS})
@@ -578,7 +620,9 @@ if (CAN_USE_GLES2 AND USE_GLES2)
if (NOT IOS) if (NOT IOS)
list (APPEND OCCT_3RDPARTY_CMAKE_LIST "adm/cmake/egl") list (APPEND OCCT_3RDPARTY_CMAKE_LIST "adm/cmake/egl")
list (APPEND OCCT_3RDPARTY_CMAKE_LIST "adm/cmake/gles2") list (APPEND OCCT_3RDPARTY_CMAKE_LIST "adm/cmake/gles2")
OCCT_ADD_VCPKG_FEATURE ("angle") if (NOT EMSCRIPTEN)
OCCT_ADD_VCPKG_FEATURE ("angle")
endif()
endif() endif()
else() else()
if (NOT CAN_USE_GLES2) if (NOT CAN_USE_GLES2)
@@ -720,8 +764,12 @@ else()
OCCT_CHECK_AND_UNSET ("INSTALL_QT") OCCT_CHECK_AND_UNSET ("INSTALL_QT")
endif() endif()
# the name of the project # VCPKG require delayed processing of 3rdparty.
project (OCCT) # That is why we delay the creating project and setting up
# the platform specific variables.
if (BUILD_USE_VCPKG)
project (OCCT)
endif()
# copying clang-format file to the root of the project # copying clang-format file to the root of the project
file(COPY ${CMAKE_SOURCE_DIR}/.clang-format DESTINATION ${CMAKE_SOURCE_DIR}) file(COPY ${CMAKE_SOURCE_DIR}/.clang-format DESTINATION ${CMAKE_SOURCE_DIR})
@@ -864,19 +912,6 @@ if(APPLE)
set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)") set (INSTALL_NAME_DIR "" CACHE STRING "install_name library suffix on OS X (e.g. @executable_path/../Frameworks)")
endif() endif()
# Overview
if (NOT DEFINED BUILD_DOC_Overview)
set (DO_ONLY_CHECK_FOR_DOXYGEN ON)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
set (DO_ONLY_CHECK_FOR_DOXYGEN OFF)
if (CAN_DOXYGEN_BE_USED)
message (STATUS "Info. Overview building is turned on")
endif()
set (BUILD_DOC_Overview ${CAN_DOXYGEN_BE_USED} CACHE BOOL "${BUILD_DOC_Overview_DESCR}")
endif()
# include the patched or original list of definitions and flags # include the patched or original list of definitions and flags
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags") OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_defs_flags")
@@ -975,6 +1010,9 @@ message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header fi
# collect all the headers to <binary dir>/inc folder # collect all the headers to <binary dir>/inc folder
COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "src" "${INSTALL_DIR_INCLUDE}") COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "src" "${INSTALL_DIR_INCLUDE}")
# Create and install Standard_Version.hxx
CONFIGURE_AND_INSTALL_VERSION_HEADER()
string(TIMESTAMP CURRENT_TIME "%H:%M:%S") string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting") message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")

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`. - **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). - **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/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. 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.
## Building ## Building
In most cases, you need to rebuild OCCT on your platform (OS, compiler) before using it in your project to ensure binary compatibility. 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/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. 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.
## Version ## Version
The current version of OCCT can be found in the file `src/Standard/Standard_Version.hxx`. The current version of OCCT can be found in the file [`adm/cmake/version.cmake`](adm/cmake/version.cmake).
## Development ## Development

View File

@@ -26,7 +26,7 @@ endif()
if (MSVC) if (MSVC)
# suppress C26812 on VS2019/C++20 (prefer 'enum class' over 'enum') # suppress C26812 on VS2019/C++20 (prefer 'enum class' over 'enum')
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise /wd\"26812\"") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise /wd26812")
# suppress warning on using portable non-secure functions in favor of non-portable secure ones # suppress warning on using portable non-secure functions in favor of non-portable secure ones
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
else() else()

View File

@@ -75,6 +75,10 @@ endmacro()
# COMPILER variable # COMPILER variable
macro (OCCT_MAKE_COMPILER_SHORT_NAME) macro (OCCT_MAKE_COMPILER_SHORT_NAME)
if (MSVC) if (MSVC)
if (MSVC_VERSION LESS 1914)
message (AUTHOR_WARNING "Microsoft Visual C++ 19.14 (VS 2017 15.7) or newer is required for C++17 support")
endif()
if ((MSVC_VERSION EQUAL 1300) OR (MSVC_VERSION EQUAL 1310)) if ((MSVC_VERSION EQUAL 1300) OR (MSVC_VERSION EQUAL 1310))
set (COMPILER vc7) set (COMPILER vc7)
elseif (MSVC_VERSION EQUAL 1400) elseif (MSVC_VERSION EQUAL 1400)
@@ -92,20 +96,39 @@ macro (OCCT_MAKE_COMPILER_SHORT_NAME)
elseif ((MSVC_VERSION GREATER 1900) AND (MSVC_VERSION LESS 2000)) elseif ((MSVC_VERSION GREATER 1900) AND (MSVC_VERSION LESS 2000))
# Since Visual Studio 15 (2017), its version diverged from version of # Since Visual Studio 15 (2017), its version diverged from version of
# compiler which is 14.1; as that compiler uses the same run-time as 14.0, # compiler which is 14.1; as that compiler uses the same run-time as 14.0,
# we keep its id as "vc14" to be compatibille # we keep its id as "vc14" to be compatible
set (COMPILER vc14) set (COMPILER vc14)
else() else()
message (FATAL_ERROR "Unrecognized MSVC_VERSION") message (FATAL_ERROR "Unrecognized MSVC_VERSION")
endif() endif()
elseif (DEFINED CMAKE_COMPILER_IS_GNUCC) elseif (DEFINED CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message (AUTHOR_WARNING "GCC version 8.0 or newer is required for C++17 support")
endif()
set (COMPILER gcc) set (COMPILER gcc)
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX) elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
message (AUTHOR_WARNING "GCC version 8.0 or newer is required for C++17 support")
endif()
set (COMPILER gxx) set (COMPILER gxx)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]") elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
if(APPLE)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.0)
message (AUTHOR_WARNING "Apple Clang version 11.0.0 or newer is required for C++17 support")
endif()
else()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message (AUTHOR_WARNING "Clang version 7.0 or newer is required for C++17 support")
endif()
endif()
set (COMPILER clang) set (COMPILER clang)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Ii][Nn][Tt][Ee][Ll]") elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Ii][Nn][Tt][Ee][Ll]")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.1.1)
message (AUTHOR_WARNING "Intel C++ Compiler version 17.1.1 or newer is required for C++17 support")
endif()
set (COMPILER icc) set (COMPILER icc)
else() else()
message (AUTHOR_WARNING "Unknown compiler - please verify C++17 support")
set (COMPILER ${CMAKE_GENERATOR}) set (COMPILER ${CMAKE_GENERATOR})
string (REGEX REPLACE " " "" COMPILER ${COMPILER}) string (REGEX REPLACE " " "" COMPILER ${COMPILER})
endif() endif()
@@ -458,6 +481,18 @@ function (COLLECT_AND_INSTALL_OCCT_HEADER_FILES THE_ROOT_TARGET_OCCT_DIR THE_OCC
install (FILES ${OCCT_HEADER_FILES_INSTALLATION} DESTINATION "${INSTALL_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}") install (FILES ${OCCT_HEADER_FILES_INSTALLATION} DESTINATION "${INSTALL_DIR}/${THE_OCCT_INSTALL_DIR_PREFIX}")
endfunction() endfunction()
# Macro to configure and install Standard_Version.hxx file
macro (CONFIGURE_AND_INSTALL_VERSION_HEADER)
if (DEFINED BUILD_OCCT_VERSION_EXT AND "${BUILD_OCCT_VERSION_EXT}" STREQUAL "${OCC_VERSION_STRING_EXT}" AND EXISTS "${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/Standard_Version.hxx")
install(FILES "${OCCT_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/Standard_Version.hxx" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_INCLUDE}")
else()
set(BUILD_OCCT_VERSION_EXT "${OCC_VERSION_STRING_EXT}" CACHE STRING "OCCT Version string. Used only for caching, can't impact on build. For modification of version, please check adm/cmake/version.cmake" FORCE)
mark_as_advanced(BUILD_OCCT_VERSION_EXT)
string(TIMESTAMP OCCT_VERSION_DATE "%Y-%m-%d" UTC)
OCCT_CONFIGURE_AND_INSTALL ("adm/templates/Standard_Version.hxx.in" "${INSTALL_DIR_INCLUDE}/Standard_Version.hxx" "Standard_Version.hxx" "${INSTALL_DIR}/${INSTALL_DIR_INCLUDE}")
endif()
endmacro()
function(ADD_PRECOMPILED_HEADER INPUT_TARGET PRECOMPILED_HEADER THE_IS_PRIVATE) function(ADD_PRECOMPILED_HEADER INPUT_TARGET PRECOMPILED_HEADER THE_IS_PRIVATE)
if (NOT BUILD_USE_PCH) if (NOT BUILD_USE_PCH)
return() return()
@@ -550,42 +585,80 @@ function (OCCT_MODULES_AND_TOOLKITS FILE_NAME TOOLKITS_NAME_SUFFIX MODULE_LIST)
set (${MODULE_LIST} ${${MODULE_LIST}} PARENT_SCOPE) set (${MODULE_LIST} ${${MODULE_LIST}} PARENT_SCOPE)
endfunction() endfunction()
# Returns OCC version string from file Standard_Version.hxx (if available)
# Macro to extract git hash from the source directory
# and store it in the variable GIT_HASH
# in case if git is not found or error occurs, GIT_HASH is set to empty string
macro(OCCT_GET_GIT_HASH)
set(GIT_HASH "")
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH
ERROR_VARIABLE GIT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_ERROR)
# Check if working directory is clean
execute_process(
COMMAND ${GIT_EXECUTABLE} status --porcelain
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_STATUS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT "${GIT_STATUS}" STREQUAL "")
message(DEBUG "Git working directory is not clean. Git hash may be incorrect.")
endif()
else()
set(GIT_HASH "")
endif()
endif()
endmacro()
# Returns OCC version string
function (OCC_VERSION OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT) function (OCC_VERSION OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
set (OCC_VERSION_MAJOR 7) include (version)
set (OCC_VERSION_MINOR 0) set (OCC_VERSION_COMPLETE "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
set (OCC_VERSION_MAINTENANCE 0) set (OCC_VERSION_STRING_EXT "${OCC_VERSION_COMPLETE}")
set (OCC_VERSION_DEVELOPMENT dev)
set (OCC_VERSION_COMPLETE "7.0.0")
set (STANDARD_VERSION_FILE "${CMAKE_SOURCE_DIR}/src/Standard/Standard_Version.hxx")
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/Standard/Standard_Version.hxx")
set (STANDARD_VERSION_FILE "${BUILD_PATCH}/src/Standard/Standard_Version.hxx")
endif()
if (EXISTS "${STANDARD_VERSION_FILE}")
foreach (SOUGHT_VERSION OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE)
file (STRINGS "${STANDARD_VERSION_FILE}" ${SOUGHT_VERSION} REGEX "^#define ${SOUGHT_VERSION} .*")
string (REGEX REPLACE ".*${SOUGHT_VERSION} .*([^ ]+).*" "\\1" ${SOUGHT_VERSION} "${${SOUGHT_VERSION}}" )
endforeach()
foreach (SOUGHT_VERSION OCC_VERSION_DEVELOPMENT OCC_VERSION_COMPLETE)
file (STRINGS "${STANDARD_VERSION_FILE}" ${SOUGHT_VERSION} REGEX "^#define ${SOUGHT_VERSION} .*")
string (REGEX REPLACE ".*${SOUGHT_VERSION} .*\"([^ ]+)\".*" "\\1" ${SOUGHT_VERSION} "${${SOUGHT_VERSION}}" )
endforeach()
endif()
set (OCC_VERSION_MAJOR "${OCC_VERSION_MAJOR}" PARENT_SCOPE) set (OCC_VERSION_MAJOR "${OCC_VERSION_MAJOR}" PARENT_SCOPE)
set (OCC_VERSION_MINOR "${OCC_VERSION_MINOR}" PARENT_SCOPE) set (OCC_VERSION_MINOR "${OCC_VERSION_MINOR}" PARENT_SCOPE)
set (OCC_VERSION_MAINTENANCE "${OCC_VERSION_MAINTENANCE}" PARENT_SCOPE) set (OCC_VERSION_MAINTENANCE "${OCC_VERSION_MAINTENANCE}" PARENT_SCOPE)
set (OCC_VERSION_DEVELOPMENT "${OCC_VERSION_DEVELOPMENT}" PARENT_SCOPE) set (OCCT_ON_DEVELOPMENT OFF)
if (NOT "${OCC_VERSION_DEVELOPMENT}" STREQUAL "" AND NOT "${OCC_VERSION_DEVELOPMENT}" STREQUAL "OCC_VERSION_DEVELOPMENT")
if (OCC_VERSION_DEVELOPMENT AND OCC_VERSION_COMPLETE) set (OCCT_ON_DEVELOPMENT ON)
set (OCC_VERSION_STRING_EXT "${OCC_VERSION_COMPLETE}.${OCC_VERSION_DEVELOPMENT}" PARENT_SCOPE)
else()
set (OCC_VERSION_STRING_EXT "${OCC_VERSION_COMPLETE}" PARENT_SCOPE)
endif() endif()
if (${OCCT_ON_DEVELOPMENT})
set (OCC_VERSION_DEVELOPMENT "${OCC_VERSION_DEVELOPMENT}" PARENT_SCOPE)
endif()
set (SET_OCC_VERSION_DEVELOPMENT "")
if (${OCCT_ON_DEVELOPMENT})
# Use special flag from cache to turn on or off git hash extraction
if (NOT DEFINED USE_GIT_HASH)
set (USE_GIT_HASH ON CACHE BOOL "Use git hash in version string")
endif()
if (${USE_GIT_HASH})
OCCT_GET_GIT_HASH()
endif()
if (NOT "${GIT_HASH}" STREQUAL "")
set (OCC_VERSION_DEVELOPMENT "${OCC_VERSION_DEVELOPMENT}-${GIT_HASH}")
set (OCC_VERSION_DEVELOPMENT "${OCC_VERSION_DEVELOPMENT}" PARENT_SCOPE)
else()
set (OCC_VERSION_DEVELOPMENT "${OCC_VERSION_DEVELOPMENT}")
endif()
set (OCC_VERSION_STRING_EXT "${OCC_VERSION_COMPLETE}.${OCC_VERSION_DEVELOPMENT}")
set (OCC_VERSION_STRING_EXT "${OCC_VERSION_STRING_EXT}" PARENT_SCOPE)
set (SET_OCC_VERSION_DEVELOPMENT "#define OCC_VERSION_DEVELOPMENT \"${OCC_VERSION_DEVELOPMENT}\"")
set (SET_OCC_VERSION_DEVELOPMENT "${SET_OCC_VERSION_DEVELOPMENT}" PARENT_SCOPE)
else()
OCCT_CHECK_AND_UNSET(USE_GIT_HASH)
endif()
set (OCC_VERSION_STRING_EXT "${OCC_VERSION_STRING_EXT}" PARENT_SCOPE)
endfunction() endfunction()
macro (CHECK_PATH_FOR_CONSISTENCY THE_ROOT_PATH_NAME THE_BEING_CHECKED_PATH_NAME THE_VAR_TYPE THE_MESSAGE_OF_BEING_CHECKED_PATH) macro (CHECK_PATH_FOR_CONSISTENCY THE_ROOT_PATH_NAME THE_BEING_CHECKED_PATH_NAME THE_VAR_TYPE THE_MESSAGE_OF_BEING_CHECKED_PATH)

View File

@@ -3,37 +3,40 @@
# Qt is searched manually first (just determine root) # Qt is searched manually first (just determine root)
message (STATUS "Processing Qt 3-rd party") message (STATUS "Processing Qt 3-rd party")
set (USE_QT_FROM_3RDPARTY_DIR TRUE)
if (NOT DEFINED ${3RDPARTY_QT_DIR} AND ${3RDPARTY_QT_DIR} STREQUAL "") if (NOT DEFINED ${3RDPARTY_QT_DIR} AND ${3RDPARTY_QT_DIR} STREQUAL "")
FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" Qt 3RDPARTY_QT_DIR_NAME) FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" Qt 3RDPARTY_QT_DIR_NAME)
if (NOT DEFINED ${3RDPARTY_QT_DIR_NAME} AND ${3RDPARTY_QT_DIR_NAME} STREQUAL "") if (NOT DEFINED ${3RDPARTY_QT_DIR_NAME} AND ${3RDPARTY_QT_DIR_NAME} STREQUAL "")
set (3RDPARTY_QT_DIR "" CACHE PATH "The directory containing qt") set (3RDPARTY_QT_DIR "" CACHE PATH "The directory containing qt")
message (FATAL_ERROR "Could not find used third-party product: 3RDPARTY_QT_DIR") set (USE_QT_FROM_3RDPARTY_DIR FALSE)
else()
# Combine directory name with absolute path and show in GUI
set (3RDPARTY_QT_DIR "${3RDPARTY_DIR}/${3RDPARTY_QT_DIR_NAME}" CACHE PATH "The directory containing Qt" FORCE)
endif() endif()
# Combine directory name with absolute path and show in GUI
set (3RDPARTY_QT_DIR "${3RDPARTY_DIR}/${3RDPARTY_QT_DIR_NAME}" CACHE PATH "The directory containing Qt" FORCE)
message (STATUS "Info: Qt is used from folder: ${3RDPARTY_QT_DIR}")
endif() endif()
set (USED_3RDPARTY_QT_DIR "${3RDPARTY_QT_DIR}") if (${USE_QT_FROM_3RDPARTY_DIR})
# Now set CMAKE_PREFIX_PATH to point to local Qt installation.
# Now set CMAKE_PREFIX_PATH to point to local Qt installation. # Without this setting find_package() will not work
# Without this setting find_package() will not work set(CMAKE_PREFIX_PATH ${3RDPARTY_QT_DIR})
set(CMAKE_PREFIX_PATH ${3RDPARTY_QT_DIR})
# Now we can apply standard CMake finder for Qt5. We do this mostly
# Now we can apply standard CMake finder for Qt5. We do this mostly # to have qt5_wrap_cpp() function available and Qt5_FOUND variable filled
# to have qt5_wrap_cpp() function available and Qt5_FOUND variable filled find_package(Qt5 QUIET COMPONENTS Widgets Quick Xml PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH)
find_package(Qt5 QUIET COMPONENTS Widgets Quick Xml PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH) else()
find_package(Qt5 QUIET COMPONENTS Widgets Quick Xml)
endif()
if (NOT ${Qt5_FOUND}) if (NOT ${Qt5_FOUND})
# Now we can apply standard CMake finder for Qt. We do this mostly # Now we can apply standard CMake finder for Qt. We do this mostly
# to have qt4_wrap_cpp() function available # to have qt4_wrap_cpp() function available
find_package(Qt4) find_package(Qt4)
#message (STATUS "Qt4 cmake configuration")
else() else()
#message (STATUS "Qt5 cmake configuration") set (3RDPARTY_QT_DIR ${Qt5_DIR} CACHE PATH "The directory containing Qt" FORCE)
endif() endif()
set (USED_3RDPARTY_QT_DIR "${3RDPARTY_QT_DIR}")
if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}") if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin") list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
else() else()

22
adm/cmake/version.cmake Normal file
View File

@@ -0,0 +1,22 @@
#======================================================================
#
# Purpose: Defines macros identifying current version of Open CASCADE
#
# OCC_VERSION_MAJOR : (integer) number identifying major version
# OCC_VERSION_MINOR : (integer) number identifying minor version
# OCC_VERSION_MAINTENANCE : (integer) number identifying maintenance version
# OCC_VERSION_DEVELOPMENT : (string) if defined, indicates development or modified version
# in case of release, remove the value
#
# Sample values of OCC_VERSION_DEVELOPMENT:
# - "dev" for development version between releases
# - "beta..." or "rc..." for beta releases or release candidates
# - "project..." for version containing project-specific fixes
#
# For development version git commit hash can be added to the version string
#======================================================================
set (OCC_VERSION_MAJOR 7 )
set (OCC_VERSION_MINOR 9 )
set (OCC_VERSION_MAINTENANCE 0 )
set (OCC_VERSION_DEVELOPMENT )

View File

@@ -26,7 +26,7 @@ endif()
# include occt macros. compiler_bitness, os_wiht_bit, compiler # include occt macros. compiler_bitness, os_wiht_bit, compiler
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
# specify VTK folder in connectin with 3RDPARTY_DIR # specify VTK folder in connection with 3RDPARTY_DIR
if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}") if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
#CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_VTK_DIR PATH "The directory containing VTK") #CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_VTK_DIR PATH "The directory containing VTK")

View File

@@ -142,19 +142,41 @@ proc OCCDoc_GetRelPath {thePathFrom thePathTo} {
return $thePathTo return $thePathTo
} }
# Returns OCCT version string from file Standard_Version.hxx (if available) # Returns OCCT version string from version.cmake (if available)
proc OCCDoc_DetectCasVersion {} { proc OCCDoc_DetectCasVersion {} {
set occt_ver 6.7.0 # Default version in case the file is not found or readable
set occt_ver "7.8.0"
set occt_ver_add "" set occt_ver_add ""
set filename "[OCCDoc_GetSourceDir]/Standard/Standard_Version.hxx"
if { [file exists $filename] } { # Construct path to version.cmake relative to script location
set fh [open $filename "r"] set filename "[file normalize [file dirname [info script]]/cmake/version.cmake]"
set fh_loaded [read $fh]
close $fh if { [file exists $filename] && [file readable $filename] } {
regexp {[^/]\s*#\s*define\s+OCC_VERSION_COMPLETE\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver if {[catch {
regexp {[^/]\s*#\s*define\s+OCC_VERSION_DEVELOPMENT\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver_add set fh [open $filename "r"]
if { "$occt_ver_add" != "" } { set occt_ver ${occt_ver}.$occt_ver_add } set fh_loaded [read $fh]
close $fh
# Use more robust regular expressions
regexp {OCC_VERSION_MAJOR\s+(\d+)} $fh_loaded -> major
regexp {OCC_VERSION_MINOR\s+(\d+)} $fh_loaded -> minor
regexp {OCC_VERSION_MAINTENANCE\s+(\d+)} $fh_loaded -> maint
regexp {OCC_VERSION_DEVELOPMENT\s+\"([^\"]+)\"} $fh_loaded -> occt_ver_add
if {[info exists major] && [info exists minor] && [info exists maint]} {
puts "Info: Open CASCADE Technology version $major.$minor.$maint"
set occt_ver "$major.$minor.$maint"
if { [info exists occt_ver_add] && $occt_ver_add != "" } {
set occt_ver ${occt_ver}.$occt_ver_add
}
}
} err]} {
puts "Warning: Error reading version from $filename: $err"
}
} else {
puts "Warning: Version file $filename not found or not readable"
} }
return $occt_ver return $occt_ver
} }

View File

@@ -67,8 +67,9 @@ if ["%toCMake%"] == ["1"] (
set "anOcctVerSuffix=" set "anOcctVerSuffix="
set "anOcctVersion=0.0.0" set "anOcctVersion=0.0.0"
set "aGitBranch=" set "aGitBranch="
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_DEVELOPMENT" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVerSuffix=%%i" ) rem Get OCCT version
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_COMPLETE" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVersion=%%i" ) call "%~dp0build_common.bat"
set "aGitBranch="
for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" ) for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" )
for %%s in (%anNdkAbiList%) do ( for %%s in (%anNdkAbiList%) do (

View File

@@ -0,0 +1,8 @@
@echo OFF
rem Extract version info from version.cmake
for /f tokens^=2^ delims^=^" %%i in ('findstr OCC_VERSION_DEVELOPMENT "%~dp0\..\cmake\version.cmake"') do ( set "anOcctVerSuffix=%%i" )
for /f tokens^=3 %%i in ('findstr OCC_VERSION_MAJOR "%~dp0\..\cmake\version.cmake"') do ( set "OCC_VERSION_MAJOR=%%i" )
for /f tokens^=3 %%i in ('findstr OCC_VERSION_MINOR "%~dp0\..\cmake\version.cmake"') do ( set "OCC_VERSION_MINOR=%%i" )
for /f tokens^=3 %%i in ('findstr OCC_VERSION_MAINTENANCE "%~dp0\..\cmake\version.cmake"') do ( set "OCC_VERSION_MAINTENANCE=%%i" )
set "anOcctVersion=%OCC_VERSION_MAJOR%.%OCC_VERSION_MINOR%.%OCC_VERSION_MAINTENANCE%"

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Ensure script dir is defined
if [ -z "$aScriptDir" ]; then
aScriptDir=$(dirname "$0")
fi
# Check if version file exists
versionFile="$aScriptDir/../cmake/version.cmake"
if [ ! -f "$versionFile" ]; then
echo "Error: version.cmake not found"
exit 1
fi
# Extract version info from version.cmake
OCC_VERSION_MAJOR=$(awk '/set.*OCC_VERSION_MAJOR/ {print $3}' "$versionFile")
OCC_VERSION_MINOR=$(awk '/set.*OCC_VERSION_MINOR/ {print $3}' "$versionFile")
OCC_VERSION_MAINTENANCE=$(awk '/set.*OCC_VERSION_MAINTENANCE/ {print $3}' "$versionFile")
anOcctVerSuffix=$(awk '/set.*OCC_VERSION_DEVELOPMENT/ {
if (NF > 2) {
gsub(/[)" ]/, "", $3)
print $3
} else {
print ""
}
}' "$versionFile")
# Combine version string
anOcctVersion="${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}"

View File

@@ -49,8 +49,7 @@ if [[ -f "${aScriptDir}/ios_custom.sh" ]]; then
source "${aScriptDir}/ios_custom.sh" source "${aScriptDir}/ios_custom.sh"
fi fi
anOcctVerSuffix=`grep -e "#define OCC_VERSION_DEVELOPMENT" "$aCasSrc/src/Standard/Standard_Version.hxx" | awk '{print $3}' | xargs` source "${aScriptDir}/build_common.sh"
anOcctVersion=`grep -e "#define OCC_VERSION_COMPLETE" "$aCasSrc/src/Standard/Standard_Version.hxx" | awk '{print $3}' | xargs`
aGitBranch=`git symbolic-ref --short HEAD` aGitBranch=`git symbolic-ref --short HEAD`
YEAR=$(date +"%Y") YEAR=$(date +"%Y")

View File

@@ -51,8 +51,7 @@ if [[ -f "${aScriptDir}/macos_custom.sh" ]]; then
source "${aScriptDir}/macos_custom.sh" source "${aScriptDir}/macos_custom.sh"
fi fi
anOcctVerSuffix=`grep -e "#define OCC_VERSION_DEVELOPMENT" "$aCasSrc/src/Standard/Standard_Version.hxx" | awk '{print $3}' | xargs` source "${aScriptDir}/build_common.sh"
anOcctVersion=`grep -e "#define OCC_VERSION_COMPLETE" "$aCasSrc/src/Standard/Standard_Version.hxx" | awk '{print $3}' | xargs`
aGitBranch=`git symbolic-ref --short HEAD` aGitBranch=`git symbolic-ref --short HEAD`
YEAR=$(date +"%Y") YEAR=$(date +"%Y")

View File

@@ -53,9 +53,8 @@ if not ["%aCmakeBin%"] == [""] ( set "PATH=%aCmakeBin%;%PATH%" )
set "anOcctVerSuffix=" set "anOcctVerSuffix="
set "anOcctVersion=0.0.0" set "anOcctVersion=0.0.0"
call "%~dp0build_common.bat"
set "aGitBranch=" set "aGitBranch="
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_DEVELOPMENT" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVerSuffix=%%i" )
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_COMPLETE" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVersion=%%i" )
for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" ) for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" )
set "aBuildType=Release" set "aBuildType=Release"

View File

@@ -55,8 +55,8 @@ if not ["%aCmakeBin%"] == [""] ( set "PATH=%aCmakeBin%;%PATH%" )
set "anOcctVerSuffix=" set "anOcctVerSuffix="
set "anOcctVersion=0.0.0" set "anOcctVersion=0.0.0"
set "aGitBranch=" set "aGitBranch="
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_DEVELOPMENT" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVerSuffix=%%i" ) call "%~dp0build_common.bat"
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_COMPLETE" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVersion=%%i" ) set "aGitBranch="
for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" ) for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" )
set "aBuildType=Release" set "aBuildType=Release"

View File

@@ -1,6 +1,5 @@
// Created on: 2002-07-09 // Created on: @OCCT_VERSION_DATE@
// Created by: Andrey BETENEV // Copyright (c) 2002-2025 OPEN CASCADE SAS
// Copyright (c) 2002-2014 OPEN CASCADE SAS
// //
// This file is part of Open CASCADE Technology software library. // This file is part of Open CASCADE Technology software library.
// //
@@ -14,49 +13,53 @@
// commercial license or contractual agreement. // commercial license or contractual agreement.
/*====================================================================== /*======================================================================
// //
// Purpose: Defines macros identifying current version of Open CASCADE // Purpose: Defines macros identifying current version of Open CASCADE
// //
// OCC_VERSION_MAJOR : (integer) number identifying major version // OCC_VERSION_MAJOR : (integer) number identifying major version
// OCC_VERSION_MINOR : (integer) number identifying minor version // OCC_VERSION_MINOR : (integer) number identifying minor version
// OCC_VERSION_MAINTENANCE : (integer) number identifying maintenance version // OCC_VERSION_MAINTENANCE : (integer) number identifying maintenance version
// OCC_VERSION_DEVELOPMENT : (string) if defined, indicates development or modified version // OCC_VERSION_DEVELOPMENT : (string) if defined, indicates development or modified
version
// OCC_VERSION : (real) complete number (major.minor) // OCC_VERSION : (real) complete number (major.minor)
// OCC_VERSION_STRING : (string) short version number ("major.minor") // OCC_VERSION_STRING : (string) short version number ("major.minor")
// OCC_VERSION_COMPLETE : (string) complete version number ("major.minor.maintenance") // OCC_VERSION_COMPLETE : (string) complete version number
// OCC_VERSION_STRING_EXT : (string) extended version ("major.minor.maintenance.development") ("major.minor.maintenance")
// OCC_VERSION_HEX : (hex) complete number as hex, two positions per each of major, minor, and patch number // OCC_VERSION_STRING_EXT : (string) extended version
// ("major.minor.maintenance.development")
// OCC_VERSION_HEX : (hex) complete number as hex, two positions per each of
major, minor, and patch number
//
//======================================================================*/ //======================================================================*/
#ifndef _Standard_Version_HeaderFile #ifndef _Standard_Version_HeaderFile
#define _Standard_Version_HeaderFile #define _Standard_Version_HeaderFile
// Primary definitions // Primary definitions
#define OCC_VERSION_MAJOR 7 #define OCC_VERSION_MAJOR @OCC_VERSION_MAJOR@
#define OCC_VERSION_MINOR 8 #define OCC_VERSION_MINOR @OCC_VERSION_MINOR@
#define OCC_VERSION_MAINTENANCE 2 #define OCC_VERSION_MAINTENANCE @OCC_VERSION_MAINTENANCE@
//! This macro must be commented in official release, and set to non-empty //! This macro must be commented in official release, and set to non-empty
//! string in other situations, to identify specifics of the version, e.g.: //! string in other situations, to identify specifics of the version, e.g.:
//! - "dev" for development version between releases //! - "dev" for development version between releases
//! - "beta..." or "rc..." for beta releases or release candidates //! - "beta..." or "rc..." for beta releases or release candidates
//! - "project..." for version containing project-specific fixes //! - "project..." for version containing project-specific fixes
#define OCC_VERSION_DEVELOPMENT "dev" @SET_OCC_VERSION_DEVELOPMENT@
// Derived (manually): version as real and string (major.minor) // Derived (manually): version as real and string (major.minor)
#define OCC_VERSION 7.8 #define OCC_VERSION @OCC_VERSION_MAJOR@.@OCC_VERSION_MINOR@
#define OCC_VERSION_STRING "7.8" #define OCC_VERSION_STRING "@OCC_VERSION_MAJOR@.@OCC_VERSION_MINOR@"
#define OCC_VERSION_COMPLETE "7.8.2" #define OCC_VERSION_COMPLETE "@OCC_VERSION_MAJOR@.@OCC_VERSION_MINOR@.@OCC_VERSION_MAINTENANCE@"
//! Derived: extended version as string ("major.minor.maintenance.dev") //! Derived: extended version as string ("major.minor.maintenance.dev")
#ifdef OCC_VERSION_DEVELOPMENT #ifdef OCC_VERSION_DEVELOPMENT
#define OCC_VERSION_STRING_EXT OCC_VERSION_COMPLETE "." OCC_VERSION_DEVELOPMENT #define OCC_VERSION_STRING_EXT OCC_VERSION_COMPLETE "." OCC_VERSION_DEVELOPMENT
#else #else
#define OCC_VERSION_STRING_EXT OCC_VERSION_COMPLETE #define OCC_VERSION_STRING_EXT OCC_VERSION_COMPLETE
#endif #endif
// Derived: complete version as hex (0x0'major'0'minor'0'maintenance') // Derived: complete version as hex (0x0'major'0'minor'0'maintenance')
#define OCC_VERSION_HEX (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) #define OCC_VERSION_HEX (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE)
#endif /* _Standard_Version_HeaderFile */ #endif /* _Standard_Version_HeaderFile */

View File

@@ -23,7 +23,7 @@ if [ "$1" == "@BIN_LETTER@" ]; then
export CSF_OCCTBinPath="@CMAKE_RUNTIME_OUTPUT_DIRECTORY@" export CSF_OCCTBinPath="@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
export CSF_OCCTLibPath="@CMAKE_ARCHIVE_OUTPUT_DIRECTORY@" export CSF_OCCTLibPath="@CMAKE_ARCHIVE_OUTPUT_DIRECTORY@"
export CSF_OCCTIncludePath="@CMAKE_BINARY_DIR@/inc" export CSF_OCCTIncludePath="@CMAKE_BINARY_DIR@/@INSTALL_DIR_INCLUDE@"
export CSF_OCCTResourcePath="@CMAKE_SOURCE_DIR@/src" export CSF_OCCTResourcePath="@CMAKE_SOURCE_DIR@/src"
export CSF_OCCTDataPath="@CMAKE_SOURCE_DIR@/data" export CSF_OCCTDataPath="@CMAKE_SOURCE_DIR@/data"
export CSF_OCCTSamplesPath="@CMAKE_SOURCE_DIR@/samples" export CSF_OCCTSamplesPath="@CMAKE_SOURCE_DIR@/samples"

View File

@@ -1,10 +1,21 @@
#!/bin/bash #!/bin/bash
aCurrentPath="$PWD"
aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD"; aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
cd ${aCurrentPath}
# ----- For compatibility with external application using CASROOT ----- # ----- For compatibility with external application using CASROOT -----
if [ "${CASROOT}" == "" ]; then if [ "${CASROOT}" == "" ]; then
export CASROOT="${aScriptPath}" # Get the last directory name from the path
lastDir=$(basename "$aScriptPath")
# Check if last directory is exactly bin, bind, or bini
if [ "$lastDir" = "bin" ] || [ "$lastDir" = "bind" ] || [ "$lastDir" = "bini" ]; then
# If path contains binary folder, go one level up
export CASROOT=$(cd "$aScriptPath/.." && pwd)
else
# Keep current location
export CASROOT="${aScriptPath}"
fi
cd ${aCurrentPath}
fi fi
# ----- Define path to 3rdparty products ----- # ----- Define path to 3rdparty products -----

View File

@@ -1,10 +1,21 @@
#!/bin/bash #!/bin/bash
aCurrentPath="$PWD"
aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD"; aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
cd ${aCurrentPath}
# ----- For compatibility with external application using CASROOT ----- # ----- For compatibility with external application using CASROOT -----
if [ "${CASROOT}" == "" ]; then if [ "${CASROOT}" == "" ]; then
export CASROOT="@INSTALL_DIR@" # Get the last directory name from the path
lastDir=$(basename "$aScriptPath")
# Check if last directory is exactly bin, bind, or bini
if [ "$lastDir" = "bin" ] || [ "$lastDir" = "bind" ] || [ "$lastDir" = "bini" ]; then
# If path contains binary folder, go one level up
export CASROOT=$(cd "$aScriptPath/.." && pwd)
else
# Keep current location
export CASROOT="${aScriptPath}"
fi
cd ${aCurrentPath}
fi fi
# ----- Define path to 3rdparty products ----- # ----- Define path to 3rdparty products -----

View File

@@ -20,7 +20,7 @@ BEGIN
VALUE "LegalCopyright", "\251 OPEN CASCADE SAS\000" VALUE "LegalCopyright", "\251 OPEN CASCADE SAS\000"
VALUE "ProductName", "Open CASCADE Technology\000" VALUE "ProductName", "Open CASCADE Technology\000"
VALUE "ProductVersion", OCC_VERSION_STRING_EXT "\000" VALUE "ProductVersion", OCC_VERSION_STRING_EXT "\000"
VALUE "OfficialSite", "www.opencascade.com\000" VALUE "OfficialSite", "www.occt3d.com\000"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@@ -12,54 +12,70 @@ The easiest way to install third-party libraries is to download archive with pre
from [Development Portal](https://dev.opencascade.org/resources/download/3rd-party-components). from [Development Portal](https://dev.opencascade.org/resources/download/3rd-party-components).
You can also build third-party libraries from their sources, see @ref build_upgrade_building_3rdparty for instructions. You can also build third-party libraries from their sources, see @ref build_upgrade_building_3rdparty for instructions.
On Linux and macOS we recommend to use libraries maintained by distributive developers, when possible. On Linux and macOS we recommend using libraries maintained by distributive developers when possible.
@section build_occt_win_cmake Building with CMake tool @section build_requirements System Requirements
This chapter describes the [CMake](https://cmake.org/download/)-based build process, which is now suggested as a standard way to produce the binaries of Open CASCADE Technology from sources. * **CMake** version 3.10 or later (3.16+ recommended for precompiled headers support)
OCCT requires CMake version 3.1 or later. * C++11 compliant compiler (required)
* Supported platforms and compilers:
* Windows:
- Visual Studio 2015 or later
- MinGW-w64 7.3 or later
* Linux:
- GCC 5.0 or later
- Clang 3.8 or later
* macOS:
- Apple Clang 9.0 or later
- Xcode 9.0 or later
CMake is a tool that generates the actual project files for the selected target build system (e.g. Unix makefiles) or IDE (e.g. Visual Studio 2010). @section build_occt_cmake Building with CMake
Here we describe the build procedure on the example of Windows platform with Visual Studio 2010.
This chapter describes the [CMake](https://cmake.org/download/)-based build process, which is the standard way to produce OCCT binaries from sources.
CMake is a tool that generates project files for the selected target build system (e.g. Unix makefiles) or IDE (e.g. Visual Studio).
Here we describe the build procedure using Windows platform with Visual Studio as an example.
However, CMake is cross-platform and can be used to build OCCT on Linux and macOS in essentially the same way. However, CMake is cross-platform and can be used to build OCCT on Linux and macOS in essentially the same way.
CMake deals with three directories: source, build or binary and installation. CMake deals with three directories: source, build or binary and installation.
* The source directory is where the sources of OCCT are located in your file system; * The source directory is where the sources of OCCT are located in your file system;
* The build or binary directory is where all files created during CMake configuration and generation process will be located. The mentioned process will be described below. * The build or binary directory is where all files created during CMake configuration and generation process will be located;
* The installation directory is where binaries will be installed after building the *INSTALL* project that is created by CMake generation process, along with header files and resources required for OCCT use in applications. * The installation directory is where binaries will be installed after building the *INSTALL* project, along with header files and resources required for OCCT use in applications.
The good practice is not to use the source directory as a build one. The good practice is not to use the source directory as a build one.
Different configurations should be built in different build directories to avoid conflicts. Different configurations should be built in different build directories to avoid conflicts.
It is however possible to choose one installation directory for several configurations of OCCT (differentiated by platform, bitness, compiler and build type), for example: For example:
d:/occt/ - the source directory d:/occt/ - the source directory
d:/tmp/occt-build-vc10-x64 - the build directory with the generated d:/tmp/occt-build-vc14-x64 - the build directory with the generated
solution and other intermediate files created during a CMake tool working solution and other intermediate files created during a CMake tool working
d:/occt-install - the installation directory that is d:/occt-install - the installation directory that can
able to contain several OCCT configurations contain several OCCT configurations
@subsection build_cmake_conf Configuration process @subsection build_cmake_conf Configuration process
For unexperienced users we recommend to start with *cmake-gui* -- a cross-platform GUI tool provided by CMake on Windows, Mac and Linux. For inexperienced users we recommend starting with *cmake-gui* -- a cross-platform GUI tool provided by CMake on Windows, Mac and Linux.
A command-line alternative, *ccmake* can also be used. A command-line alternative, *ccmake* can also be used.
If the command-line tool is used, run the tool from the build directory with a single argument indicating the source (relative or absolute path) directory, and press *c* to configure: If the command-line tool is used, run it from the build directory with a single argument indicating the source directory:
cd d:/tmp/occt-build-vc10-x64 cd d:/tmp/occt-build-vc14-x64
ccmake d:/occt ccmake d:/occt
Then press *c* to configure.
@figure{/build/build_occt/images/cmake_image000.png} @figure{/build/build_occt/images/cmake_image000.png}
If the GUI tool is used, run this tool without additional arguments and after that specify the source directory by clicking **Browse Source** and the build (binary) one by clicking **Browse Build**: If the GUI tool is used, run this tool without additional arguments and specify the source directory by clicking **Browse Source** and the build directory by clicking **Browse Build**:
@figure{/build/build_occt/images/cmake_image001.png} @figure{/build/build_occt/images/cmake_image001.png}
@note Each configuration of the project should be built in its own directory. @note Each configuration of the project should be built in its own directory.
When building multiple configurations it is suggested to indicate in the name of build directories the system, bitness and compiler (e.g., <i>d:/occt/build/win32-vc10</i>). When building multiple configurations it is suggested to indicate in the name of build directories the system, bitness and compiler (e.g., <i>d:/occt/build/win32-vc14</i>).
Once the source and build directories are selected, "Configure" button should be pressed in order to start manual configuration process. Once the source and build directories are selected, "Configure" button should be pressed in order to start manual configuration process.
It begins with selection of a target configurator. It is "Visual Studio 10 2010 Win64" in our example. It begins with selection of a target configurator. It is "Visual Studio 14 2015 Win64" in our example.
@figure{/build/build_occt/images/cmake_image002.png} @figure{/build/build_occt/images/cmake_image002.png}
@@ -86,24 +102,29 @@ The following table gives the full list of environment variables used at the con
| Variable | Type | Purpose | | Variable | Type | Purpose |
|----------|------|---------| |----------|------|---------|
| CMAKE_BUILD_TYPE | String | Specifies the build type on single-configuration generators (such as make). Possible values are Debug, Release and RelWithDebInfo | | CMAKE_BUILD_TYPE | String | Specifies the build type on single-configuration generators (such as make). Possible values are Debug, Release and RelWithDebInfo |
| USE_FREETYPE | Boolean | Indicates whether FreeType product should be used in OCCT for text rendering | | USE_FREETYPE | Boolean | Indicates whether FreeType product should be used in OCCT for text rendering |
| USE_FREEIMAGE | Boolean | Indicates whether FreeImage product should be used in OCCT visualization module for support of popular graphics image formats (PNG, BMP, etc.) | | USE_FREEIMAGE | Boolean | Indicates whether FreeImage product should be used in OCCT visualization module for support of popular graphics image formats |
| USE_OPENVR | Boolean | Indicates whether OpenVR product should be used in OCCT visualization module for support of Virtual Reality | | USE_FFMPEG | Boolean | Indicates whether FFmpeg framework should be used for video encoding/decoding support |
| USE_OPENGL | Boolean | Indicates whether TKOpenGl graphic driver using OpenGL library (desktop) should be built within OCCT visualization module | | USE_OPENVR | Boolean | Indicates whether OpenVR product should be used in OCCT visualization module for VR support |
| USE_GLES2 | Boolean | Indicates whether TKOpenGles graphic driver using OpenGL ES library (embedded OpenGL) should be built within OCCT visualization module | | USE_OPENGL | Boolean | Indicates whether TKOpenGl graphic driver using OpenGL library (desktop) should be built |
| USE_RAPIDJSON | Boolean | Indicates whether RapidJSON product should be used in OCCT Data Exchange module for support of glTF mesh file format | | USE_GLES2 | Boolean | Indicates whether TKOpenGles graphic driver using OpenGL ES library should be built |
| USE_DRACO | Boolean | Indicates whether Draco product should be used in OCCT Data Exchange module for support of Draco compression in glTF mesh file format | | USE_RAPIDJSON | Boolean | Indicates whether RapidJSON product should be used for JSON format support |
| USE_TK | Boolean | Indicates whether Tcl/Tk product should be used in OCCT Draw Harness module for user interface (in addition to Tcl, which is mandatory for Draw Harness) | | USE_DRACO | Boolean | Indicates whether Draco mesh compression library should be used |
| USE_TBB | Boolean | Indicates whether TBB (Threading Building Blocks) 3rd party is used or not. Note that OCCT remains parallel even without TBB product | | USE_TK | Boolean | Indicates whether Tcl/Tk product should be used in Draw Harness for user interface |
| USE_VTK | Boolean | Indicates whether VTK 3rd party is used or not. OCCT comes with a bridge between CAD data representation and VTK by means of its dedicated VIS component (VTK Integration Services). You may skip this 3rd party unless you are planning to use VTK visualization for OCCT geometry. See the official documentation @ref occt_user_guides__vis for the details on VIS | | USE_TBB | Boolean | Indicates whether TBB (Threading Building Blocks) should be used for parallel computations |
| USE_VTK | Boolean | Indicates whether VTK bridge should be built |
| BUILD_USE_PCH | Boolean | Enable/disable use of precompiled headers. Requires CMake 3.16 or later |
| BUILD_USE_VCPKG | Boolean | Use vcpkg for managing third-party dependencies |
| BUILD_INCLUDE_SYMLINK | Boolean | Use symbolic links instead of copies for header files in build directory |
| BUILD_MODULE_<MODULE>| Boolean | Indicates whether the corresponding OCCT module should be built |
| BUILD_LIBRARY_TYPE | String | Specifies library type ("Shared" or "Static") |
| BUILD_CPP_STANDARD | String | Select C++ standard (C++11, C++14, C++17, C++20, C++23) |
| 3RDPARTY_DIR | Path | Defines the root directory where all required 3rd party products will be searched. Once you define this path it is very convenient to click "Configure" button in order to let CMake automatically detect all necessary products| | 3RDPARTY_DIR | Path | Defines the root directory where all required 3rd party products will be searched. Once you define this path it is very convenient to click "Configure" button in order to let CMake automatically detect all necessary products|
| 3RDPARTY_FREETYPE_* | Path | Path to FreeType binaries | | 3RDPARTY_FREETYPE_* | Path | Path to FreeType binaries |
| 3RDPARTY_TCL_* 3RDPARTY_TK_* | Path | Path to Tcl/Tk binaries | | 3RDPARTY_TCL_* 3RDPARTY_TK_* | Path | Path to Tcl/Tk binaries |
| 3RDPARTY_FREEIMAGE* | Path | Path to FreeImage binaries | | 3RDPARTY_FREEIMAGE* | Path | Path to FreeImage binaries |
| 3RDPARTY_TBB* | Path | Path to TBB binaries | | 3RDPARTY_TBB* | Path | Path to TBB binaries |
| 3RDPARTY_VTK_* | Path | Path to VTK binaries | | 3RDPARTY_VTK_* | Path | Path to VTK binaries |
| BUILD_MODULE_<MODULE>| Boolean | Indicates whether the corresponding OCCT module should be built or not. It should be noted that some toolkits of a module can be built even if this module is not checked (this happens if some other modules depend on these toolkits). The main modules and their descriptions can be found in @ref user_guides |
| BUILD_LIBRARY_TYPE | String | Specifies the type of library to be created. "Shared" libraries are linked dynamically and loaded at runtime. "Static" libraries are archives of object files used when linking other targets. Note that Draw Harness plugin system is incompatible with "Static" builds, and therefore it is disabled for these builds.|
| BUILD_ADDITIONAL_TOOLKITS | String | Semicolon-separated individual toolkits to include into build process. If you want to build some particular libraries (toolkits) only, then you may uncheck all modules in the corresponding *BUILD_MODUE_\<MODULE\>* options and provide the list of necessary libraries here. Of course, all dependencies will be resolved automatically | | BUILD_ADDITIONAL_TOOLKITS | String | Semicolon-separated individual toolkits to include into build process. If you want to build some particular libraries (toolkits) only, then you may uncheck all modules in the corresponding *BUILD_MODUE_\<MODULE\>* options and provide the list of necessary libraries here. Of course, all dependencies will be resolved automatically |
| BUILD_YACCLEX | Boolean | Enables Flex/Bison lexical analyzers. OCCT source files relating to STEP reader and ExprIntrp functionality are generated automatically with Flex/Bison. Checking this option leads to automatic search of Flex/Bison binaries and regeneration of the mentioned files | | BUILD_YACCLEX | Boolean | Enables Flex/Bison lexical analyzers. OCCT source files relating to STEP reader and ExprIntrp functionality are generated automatically with Flex/Bison. Checking this option leads to automatic search of Flex/Bison binaries and regeneration of the mentioned files |
| BUILD_SAMPLES_MFC | Boolean | Indicates whether MFC samples should be built together with OCCT. This option is only relevant to Windows platforms | | BUILD_SAMPLES_MFC | Boolean | Indicates whether MFC samples should be built together with OCCT. This option is only relevant to Windows platforms |
@@ -113,7 +134,6 @@ The following table gives the full list of environment variables used at the con
| BUILD_PATCH | Path | Points to the directory recognized as a "patch" for OCCT. If specified, the files from this directory take precedence over the corresponding native OCCT sources. This way you are able to introduce patches to Open CASCADE Technology not affecting the original source distribution | | BUILD_PATCH | Path | Points to the directory recognized as a "patch" for OCCT. If specified, the files from this directory take precedence over the corresponding native OCCT sources. This way you are able to introduce patches to Open CASCADE Technology not affecting the original source distribution |
| BUILD_WITH_DEBUG | Boolean | Enables extended messages of many OCCT algorithms, usually printed to cout. These include messages on internal errors and special cases encountered, timing, etc. | | BUILD_WITH_DEBUG | Boolean | Enables extended messages of many OCCT algorithms, usually printed to cout. These include messages on internal errors and special cases encountered, timing, etc. |
| BUILD_ENABLE_FPE_SIGNAL_HANDLER | Boolean | Enable/Disable the floating point exceptions (FPE) during DRAW execution only. Corresponding environment variable (CSF_FPE) can be changed manually in custom.bat/sh scripts without regeneration by CMake. | | BUILD_ENABLE_FPE_SIGNAL_HANDLER | Boolean | Enable/Disable the floating point exceptions (FPE) during DRAW execution only. Corresponding environment variable (CSF_FPE) can be changed manually in custom.bat/sh scripts without regeneration by CMake. |
| BUILD_CPP_STANDARD | String | Employ corresponding c++ standard (C++11, C++14, ..C++23) for building OCCT |
| CMAKE_CONFIGURATION_TYPES | String | Semicolon-separated CMake configurations | | CMAKE_CONFIGURATION_TYPES | String | Semicolon-separated CMake configurations |
| INSTALL_DIR | Path | Points to the installation directory. *INSTALL_DIR* is a synonym of *CMAKE_INSTALL_PREFIX*. The user can specify both *INSTALL_DIR* or *CMAKE_INSTALL_PREFIX* | | INSTALL_DIR | Path | Points to the installation directory. *INSTALL_DIR* is a synonym of *CMAKE_INSTALL_PREFIX*. The user can specify both *INSTALL_DIR* or *CMAKE_INSTALL_PREFIX* |
| INSTALL_DIR_BIN | Path | Relative path to the binaries installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_BIN}) | | INSTALL_DIR_BIN | Path | Relative path to the binaries installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_BIN}) |
@@ -211,7 +231,7 @@ The directory structure is as follows:
samples - samples samples - samples
src - all required source files for OCCT src - all required source files for OCCT
tests - OCCT test suite tests - OCCT test suite
win32\vc10\bind - binary files (installed 3rdparties and occt) win32\vc14\bind - binary files (installed 3rdparties and occt)
\libd - libraries (installed 3rdparties and occt) \libd - libraries (installed 3rdparties and occt)
@note The above example is given for debug configuration. @note The above example is given for debug configuration.
@@ -219,7 +239,7 @@ However, it is generally safe to use the same installation directory for the rel
In the latter case the contents of install directory will be enriched with subdirectories and files related to the release configuration. In the latter case the contents of install directory will be enriched with subdirectories and files related to the release configuration.
In particular, the binaries directory win64 will be expanded as follows: In particular, the binaries directory win64 will be expanded as follows:
\win32\vc10\bind \win32\vc14\bind
\libd \libd
\bin \bin
\lib \lib
@@ -235,10 +255,11 @@ This section describes the steps to build OCCT libraries for Android from a comp
The steps on Windows 7 and Ubuntu 15.10 are similar. There is the only one difference: makefiles are built with mingw32-make on Windows and native GNU make on Ubuntu. The steps on Windows 7 and Ubuntu 15.10 are similar. There is the only one difference: makefiles are built with mingw32-make on Windows and native GNU make on Ubuntu.
Required tools (download and install if it is required): Required tools (download and install if it is required):
- CMake 3.0+ - CMake 3.10+ (3.16+ recommended)
- [Cross-compilation toolchain for CMake](https://github.com/taka-no-me/android-cmake) - Android NDK r19+
- [Android NDK r12+](https://developer.android.com/ndk/downloads) - Android SDK API level 21+
- GNU Make: MinGW v4.82+ for [Windows](https://www.mingw-w64.org/), GNU Make 4.0 for Ubuntu. - For Windows: MinGW-w64 7.3+ or Visual Studio 2015+
- For Linux/macOS: GNU Make 4.0+
Run GUI tool provided by CMake and: Run GUI tool provided by CMake and:
- Specify the root folder of OCCT (`$CASROOT`, which contains *CMakelists.txt* file) by clicking **Browse Source**. - Specify the root folder of OCCT (`$CASROOT`, which contains *CMakelists.txt* file) by clicking **Browse Source**.
@@ -263,9 +284,9 @@ specify `CMAKE_MAKE_PROGRAM` to mingw32-make executable.
@figure{/build/build_occt/images/android_image005.png} @figure{/build/build_occt/images/android_image005.png}
How to configure OCCT, see @ref build_cmake_conf "Configure" section taking into account the specific configuration variables for Android: How to configure OCCT, see @ref build_cmake_conf "Configure" section taking into account the specific configuration variables for Android:
- `ANDROID_ABI` = `armeabi-v7a` - `ANDROID_ABI` = `armeabi-v7a`, `arm64-v8a`, `x86`, or `x86_64`
- `ANDROID_NATIVE_API_LEVEL` = `15` - `ANDROID_PLATFORM` = `android-21` (minimum supported API level)
- `ANDROID_NDK_LAYOUT` is equal to `CMAKE_BUILD_TYPE` variable - `ANDROID_STL` = `c++_shared` (recommended)
- `BUILD_MODULE_Draw` = `OFF` - `BUILD_MODULE_Draw` = `OFF`
@figure{/build/build_occt/images/android_image006.png} @figure{/build/build_occt/images/android_image006.png}

View File

@@ -233,13 +233,18 @@ void Average (const Standard_Real** theArray,
To improve the open source readability and, consequently, maintainability, the following set of rules is applied. To improve the open source readability and, consequently, maintainability, the following set of rules is applied.
### Clang-format [MANDATORY]
The source code should be formatted using the clang-format tool with the configuration file provided in the OCCT repository.
The version of clang-format should be 18.1.8 or higher.
### International language [MANDATORY] ### International language [MANDATORY]
All comments in all sources must be in English. All comments in all sources must be in English.
### Line length ### Line length
Try to stay within the limit of 120 characters per line in all sources. Try to stay within the limit of 100 characters per line in all sources.
### C++ style comments ### C++ style comments
@@ -254,49 +259,6 @@ Delete unused code instead of commenting it or using \#define.
Indentation in all sources should be set to two space characters. Indentation in all sources should be set to two space characters.
Use of tabulation characters for indentation is disallowed. Use of tabulation characters for indentation is disallowed.
### Separating spaces
Punctuation rules follow the rules of the English language.
* C/C++ reserved words, commas, colons and semicolons should be followed by a space character if they are not at the end of a line.
* There should be no space characters after '(' and before ')'. Closing and opening brackets should be separated by a space character.
* For better readability it is also recommended to surround conventional operators by a space character.
Examples:
~~~~{.cpp}
while (true) // NOT: while( true ) ...
{
DoSomething (theA, theB, theC, theD); // NOT: DoSomething(theA,theB,theC,theD);
}
for (anIter = 0; anIter < 10; ++anIter) // NOT: for (anIter=0;anIter<10;++anIter){
{
theA = (theB + theC) * theD; // NOT: theA=(theB+theC)*theD
}
~~~~
### Declaration of pointers and references
In declarations of simple pointers and references put asterisk (*) or ampersand (&) right after the type without extra space.
Since declaration of several variables with mixed pointer types contrudicts this rule, it should be avoided. Instead, declare each variable independently with fully qualified type.
Examples:
~~~~{.cpp}
Standard_Integer *theVariable; // not recommended
Standard_Integer * theVariable; // not recommended
Standard_Integer* theVariable; // this is OK
Standard_Integer *&theVariable; // not recommended
Standard_Integer *& theVariable; // not recommended
Standard_Integer*& theVariable; // this is OK
Standard_Integer **theVariable; // not recommended
Standard_Integer ** theVariable; // not recommended
Standard_Integer** theVariable; // this is OK
Standard_Integer *theA, theB, **theC; // not recommended (declare each variable independently)
~~~~
### Separate logical blocks ### Separate logical blocks
Separate logical blocks of code with one blank line and comments. Separate logical blocks of code with one blank line and comments.
@@ -330,19 +292,16 @@ Each descriptive block should contain at least a function name and purpose descr
See the following example: See the following example:
~~~~{.cpp} ~~~~{.cpp}
// =======================================================================
// function : TellMeSmthGood // ================================================================================================
// purpose : Gives me good news
// =======================================================================
void TellMeSmthGood() void TellMeSmthGood()
{ {
... ...
} }
// ======================================================================= // ================================================================================================
// function : TellMeSmthBad
// purpose : Gives me bad news
// =======================================================================
void TellMeSmthBad() void TellMeSmthBad()
{ {
... ...
@@ -400,23 +359,6 @@ if (THE_LIMIT == theValue) // bad style (global constant vs. variable)
if (theValue == THE_LIMIT) // OK if (theValue == THE_LIMIT) // OK
~~~~ ~~~~
### Alignment
Use alignment wherever it enhances the readability. See the following example:
~~~~{.cpp}
MyPackage_MyClass anObject;
Standard_Real aMinimum = 0.0;
Standard_Integer aVal = theVal;
switch (aVal)
{
case 0: computeSomething(); break;
case 12: computeSomethingElse (aMinimum); break;
case 3:
default: computeSomethingElseYet(); break;
}
~~~~
### Indentation of comments ### Indentation of comments
Comments should be indented in the same way as the code to which they refer or they can be in the same line if they are short. Comments should be indented in the same way as the code to which they refer or they can be in the same line if they are short.

View File

@@ -7,7 +7,7 @@ Upgrade from older OCCT versions {#occt__upgrade}
This document provides technical details on changes made in particular versions of OCCT. It can help to upgrade user applications based on previous versions of OCCT to newer ones. This document provides technical details on changes made in particular versions of OCCT. It can help to upgrade user applications based on previous versions of OCCT to newer ones.
@ref upgrade_occt780 "SEEK TO THE LAST CHAPTER (UPGRADE TO 7.8.0)" @ref upgrade_occt790 "SEEK TO THE LAST CHAPTER (UPGRADE TO 7.9.0)"
@subsection upgrade_intro_precautions Precautions @subsection upgrade_intro_precautions Precautions
@@ -2409,3 +2409,77 @@ The most recommended manager is `JeMalloc`. To use it with a plugin system, like
`BUILD_OPT_PROFILE` is a new variable to define optimization level. Available profiles: `BUILD_OPT_PROFILE` is a new variable to define optimization level. Available profiles:
* `Default` - specializes only in quality-dependent parameters for the compiler. * `Default` - specializes only in quality-dependent parameters for the compiler.
* `Production` - specializes in performance and quality-dependent parameters for the compiler and linker. * `Production` - specializes in performance and quality-dependent parameters for the compiler and linker.
@section upgrade_occt790 Upgrade to OCCT 7.9.0
@subsection upgrade_790_code_formatting Code Formatting update
The entire code base has been formatted with `clang-format` 18.1.8 (Windows) using settings available in the root of the repository.
Most custom patches on top of previous releases will likely have merge conflicts.
When encountering merge conflicts, it is recommended to use `clang-format` to format the code.
To maintain patches, it is recommended to merge them into the main repository as part of a contribution. See [Get Involved](https://dev.opencascade.org/get_involved) and [Contribution Guide](https://github.com/Open-Cascade-SAS/OCCT/discussions/36).
@subsection upgrade_790_migration Migration to GitHub
The OCCT repository has been migrated to GitHub. The new repository is available at [GitHub](https://github.com/Open-Cascade-SAS/OCCT).
The old repository will be available for some time, but it is recommended to use the new repository for all new changes.
Contribution to the new repository is available through the GitHub interface - see [Get Involved](https://dev.opencascade.org/get_involved) and [Contribution Guide](https://github.com/Open-Cascade-SAS/OCCT/discussions/36).
@subsection upgrade_790_configuration GenProj no longer supported
The `GenProj` tool is no longer supported. It is recommended to use CMake for building OCCT.
In case of problems, please refer to the [CMake Guide](https://dev.opencascade.org/doc/overview/html/build_upgrade__building_occt.html).
@subsection upgrade_790_modeling_scale_exception Disabling exception for transformation with scale
The exception for transformation with scale has been disabled by default.
These exceptions were enabled in OCCT 7.6.0 for all cases of applying a transformation on a `TopoDS_Shape` with scale or negative determinant.
Now the exceptions are disabled by default but can be enabled by changing the parameter in the method which applies the transformation on `TopoDS_Shape`.
@subsection upgrade_790_de_wrapper Migration of DE_Wrapper classes
The DE Wrapper classes have been reorganized to follow a single style throughout the OCCT open source and commercial code.
All DE formats starting from 7.8.0 were grouped into their own TKs with the `TKDE` prefix.
Now all DE Wrapper interfaces have moved to their own package with the `DE` prefix.
DE Wrapper classes follow the pattern: `DE<Format>_Parameters`, `DE<Format>_Provider`, and `DE<Format>_ConfigurationNode`.
Example: `DESTEP_Parameters`, `DESTEP_Provider`, `DESTEP_ConfigurationNode`.
@subsection upgrade_790_de_shape_healing Migration of shape healing parameters
The shape healing parameters have migrated from the resource file to the DE interface.
The previous implementation was based on the resource file or `Interface_Static`.
Now the parameters are stored in the `DE_ShapeFixParameters` structure with the option to use a string-string map to store extra parameters.
To use the previous interface, use code similar to:
~~~~{.cpp}
STEPControl_Reader aReader;
XSAlgo_ShapeProcessor::ProcessingData aProcessingData =
XSAlgo_ShapeProcessor::ReadProcessingData("read.step.resource.name", "read.step.sequence");
aReader.SetShapeFixParameters(std::move(aProcessingData.first));
aReader.SetShapeProcessFlags(aProcessingData.second);
~~~~
It is recommended to use the new interface to store parameters in the `DE_ShapeFixParameters` structure directly.
@subsection upgrade_790_de_interface_static Migration of DE parameters from Interface_Static
During transfer operations, all parameters that were stored in `Interface_Static` have moved to their own DE structure.
The parameters are read only once during initialization and stored in the model.
Parameters are now available as part of the DE Wrapper interface, for example: `DESTEP_Parameters`, `DEIGES_Parameters`.
Code samples showing how to set the parameters can be found in `DESTEP_Provider` and `DEIGES_Provider`.
@subsection upgrade_790_general_handle_types Deprecated Handle types
The `Handle_*` type names have been deprecated in favor of directly using the macro.
The `Handle_*` type names are still available, but it is recommended to use the macro directly.
Example:
~~~~{.cpp}
Handle(TDataStd_Application) anApp = new TDataStd_Application(); // recommended
Handle_TDataStd_Application anApp = new TDataStd_Application(); // deprecated
~~~~
@subsection upgrade_790_general_map NCollection_Map algorithm method migration
The `NCollection_Map` class has been reorganized to migrate extra methods to the `NCollection_MapAlgo` class.
Boolean operations on maps are now available in the `NCollection_MapAlgo` class.

View File

@@ -197,7 +197,7 @@ All registered providers are set to the map with information about its vendor an
@subsubsection occt_de_wrapper_3_3_1 Registering providers. Code sample @subsubsection occt_de_wrapper_3_3_1 Registering providers. Code sample
It is nesessary to register only one ConfigurationNode for all needed formats. It is necessary to register only one ConfigurationNode for all needed formats.
~~~~{.cpp} ~~~~{.cpp}
Handle(DE_Wrapper) aSession = DE_Wrapper::GlobalWrapper(); Handle(DE_Wrapper) aSession = DE_Wrapper::GlobalWrapper();
Handle(DE_ConfigurationNode) aNode = new DESTEP_ConfigurationNode(); Handle(DE_ConfigurationNode) aNode = new DESTEP_ConfigurationNode();

View File

@@ -6480,7 +6480,7 @@ blend b b 2 .
==fleche : 0.001 ==fleche : 0.001
==tolblend 0.01 0.0001 1e-05 0.001 ==tolblend 0.01 0.0001 1e-05 0.001
==Pick an object ==Pick an object
# click on the edge you want ot fillet # click on the edge you want to fillet
==COMPUTE: temps total 0.1s dont : ==COMPUTE: temps total 0.1s dont :
==- Init + ExtentAnalyse 0s ==- Init + ExtentAnalyse 0s

View File

@@ -87,7 +87,7 @@ Note that if a given value of linear deflection is less than shape tolerance the
The application should provide deflection parameters to compute a satisfactory mesh. Angular deflection is relatively simple and allows using a default value (12-20 degrees). Linear deflection has an absolute meaning and the application should provide the correct value for its models. Giving small values may result in a too huge mesh (consuming a lot of memory, which results in a long computation time and slow rendering) while big values result in an ugly mesh. The application should provide deflection parameters to compute a satisfactory mesh. Angular deflection is relatively simple and allows using a default value (12-20 degrees). Linear deflection has an absolute meaning and the application should provide the correct value for its models. Giving small values may result in a too huge mesh (consuming a lot of memory, which results in a long computation time and slow rendering) while big values result in an ugly mesh.
For an application working in dimensions known in advance it can be reasonable to use the absolute linear deflection for all models. This provides meshes according to metrics and precision used in the application (for example, it it is known that the model will be stored in meters, 0.004 m is enough for most tasks). For an application working in dimensions known in advance it can be reasonable to use the absolute linear deflection for all models. This provides meshes according to metrics and precision used in the application (for example, it is known that the model will be stored in meters, 0.004 m is enough for most tasks).
However, an application that imports models created in other applications may not use the same deflection for all models. Note that actually this is an abnormal situation and this application is probably just a viewer for CAD models with dimensions varying by an order of magnitude. This problem can be solved by introducing the concept of a relative linear deflection with some LOD (level of detail). The level of detail is a scale factor for absolute deflection, which is applied to model dimensions. However, an application that imports models created in other applications may not use the same deflection for all models. Note that actually this is an abnormal situation and this application is probably just a viewer for CAD models with dimensions varying by an order of magnitude. This problem can be solved by introducing the concept of a relative linear deflection with some LOD (level of detail). The level of detail is a scale factor for absolute deflection, which is applied to model dimensions.

View File

@@ -2782,7 +2782,7 @@ The *TObj* sources are distributed in the following packages:
* **External links** -- references from one data structure to another data structure in another document. * **External links** -- references from one data structure to another data structure in another document.
To store these references properly, a label must also contain an external link attribute. To store these references properly, a label must also contain an external link attribute.
* **Father** -- a label, from which other labels have been created. The other labels are, by definition, the children of this label. * **Father** -- a label, from which other labels have been created. The other labels are, by definition, the children of this label.
* **Framework** -- a group of co-operating classes which enable a design to be re-used for a given category of problem. The framework guides the architecture of the application by breaking it up into abstract classes, each of which has different responsibilities and collaborates in a predefined way. Application developer creates a specialized framework by: * **Framework** -- a group of co-operating classes which enable a design to be reused for a given category of problem. The framework guides the architecture of the application by breaking it up into abstract classes, each of which has different responsibilities and collaborates in a predefined way. Application developer creates a specialized framework by:
* defining new classes which inherit from these abstract classes * defining new classes which inherit from these abstract classes
* composing framework class instances * composing framework class instances
* implementing the services required by the framework. * implementing the services required by the framework.

View File

@@ -459,7 +459,7 @@ Boolean flag regulating translation of entities that define tessellated geometry
* TRIANGULATED_FACE * TRIANGULATED_FACE
* COMPLEX_TRIANGULATED_FACE * COMPLEX_TRIANGULATED_FACE
Tesselated geometry is attached to shapes as objects of <i>Poly_Triangulation</i> type using STEP links. Tessellated geometry is attached to shapes as objects of <i>Poly_Triangulation</i> type using STEP links.
* 0 (Off) -- do not translate * 0 (Off) -- do not translate
* 1 (On) -- translate * 1 (On) -- translate
@@ -1020,7 +1020,7 @@ Boolean flag regulating writing of entities that define tessellated geometry:
* TESSELLATED_SOLID * TESSELLATED_SOLID
* TRIANGULATED_FACE * TRIANGULATED_FACE
Tesselated geometry is taken as objects of <i>Poly_Triangulation type</i> from the active <i>TopoDS_Face</i> triangulation. Tessellated geometry is taken as objects of <i>Poly_Triangulation type</i> from the active <i>TopoDS_Face</i> triangulation.
* 0 (Off) -- do not write * 0 (Off) -- do not write
* 1 (On) -- write * 1 (On) -- write

View File

@@ -3,7 +3,11 @@ CONFIG += debug_and_release qt
TARGET = FuncDemo TARGET = FuncDemo
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt) isEmpty(CSF_OCCTSamplesPath) {
SAMPLESROOT = $$PWD/..
} else {
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
}
HEADERS = src/*.h HEADERS = src/*.h
SOURCES = src/*.cpp SOURCES = src/*.cpp

View File

@@ -3,7 +3,11 @@ CONFIG += debug_and_release qt
TARGET = IESample TARGET = IESample
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt) isEmpty(CSF_OCCTSamplesPath) {
SAMPLESROOT = $$PWD/..
} else {
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
}
HEADERS = $${SAMPLESROOT}/Common/src/*.h \ HEADERS = $${SAMPLESROOT}/Common/src/*.h \
$${SAMPLESROOT}/Interface/src/*.h $${SAMPLESROOT}/Interface/src/*.h

View File

@@ -9,7 +9,11 @@ greaterThan(QT_MAJOR_VERSION, 4) {
TARGET = OCCTOverview TARGET = OCCTOverview
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt) isEmpty(CSF_OCCTSamplesPath) {
SAMPLESROOT = $$PWD/..
} else {
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
}
HEADERS = ./src/*.h \ HEADERS = ./src/*.h \

View File

@@ -3,7 +3,11 @@ CONFIG += debug_and_release qt
TARGET = Tutorial TARGET = Tutorial
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt) isEmpty(CSF_OCCTSamplesPath) {
SAMPLESROOT = $$PWD/..
} else {
SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
}
HEADERS = src/*.h \ HEADERS = src/*.h \
$${SAMPLESROOT}/Common/src/*.h \ $${SAMPLESROOT}/Common/src/*.h \

View File

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

View File

@@ -18,51 +18,44 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
//============================================================================= //=================================================================================================
//function : Constructor
//purpose : AIS_Animation::AIS_Animation(const TCollection_AsciiString& theAnimationName)
//============================================================================= : myName(theAnimationName),
AIS_Animation::AIS_Animation (const TCollection_AsciiString& theAnimationName) myState(AnimationState_Stopped),
: myName (theAnimationName), myPtsStart(0.0),
myState (AnimationState_Stopped), myOwnDuration(0.0),
myPtsStart (0.0), myChildrenDuration(0.0)
myOwnDuration (0.0),
myChildrenDuration (0.0)
{ {
// //
} }
//============================================================================= //=================================================================================================
//function : ~AIS_Animation
//purpose :
//=============================================================================
AIS_Animation::~AIS_Animation() AIS_Animation::~AIS_Animation()
{ {
Clear(); Clear();
} }
//============================================================================= //=================================================================================================
//function : Clear
//purpose :
//=============================================================================
void AIS_Animation::Clear() void AIS_Animation::Clear()
{ {
myAnimations.Clear(); myAnimations.Clear();
myOwnDuration = 0.0; myOwnDuration = 0.0;
} }
//============================================================================= //=================================================================================================
//function : Add
//purpose : void AIS_Animation::Add(const Handle(AIS_Animation)& theAnimation)
//=============================================================================
void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
{ {
if (theAnimation.IsNull()) if (theAnimation.IsNull())
{ {
throw Standard_ProgramError("AIS_Animation::Add() - attempt to add a NULL animation!"); throw Standard_ProgramError("AIS_Animation::Add() - attempt to add a NULL animation!");
} }
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
if (anIter.Value() == theAnimation) if (anIter.Value() == theAnimation)
{ {
@@ -71,17 +64,16 @@ void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
} }
} }
myAnimations.Append (theAnimation); myAnimations.Append(theAnimation);
UpdateTotalDuration(); UpdateTotalDuration();
} }
//============================================================================= //=================================================================================================
//function : Find
//purpose : Handle(AIS_Animation) AIS_Animation::Find(const TCollection_AsciiString& theAnimationName) const
//=============================================================================
Handle(AIS_Animation) AIS_Animation::Find (const TCollection_AsciiString& theAnimationName) const
{ {
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
if (anIter.Value()->Name() == theAnimationName) if (anIter.Value()->Name() == theAnimationName)
{ {
@@ -91,17 +83,16 @@ Handle(AIS_Animation) AIS_Animation::Find (const TCollection_AsciiString& theAni
return Handle(AIS_Animation)(); return Handle(AIS_Animation)();
} }
//============================================================================= //=================================================================================================
//function : Remove
//purpose : Standard_Boolean AIS_Animation::Remove(const Handle(AIS_Animation)& theAnimation)
//=============================================================================
Standard_Boolean AIS_Animation::Remove (const Handle(AIS_Animation)& theAnimation)
{ {
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
if (anIter.Value() == theAnimation) if (anIter.Value() == theAnimation)
{ {
myAnimations.Remove (anIter); myAnimations.Remove(anIter);
UpdateTotalDuration(); UpdateTotalDuration();
return Standard_True; return Standard_True;
} }
@@ -109,14 +100,13 @@ Standard_Boolean AIS_Animation::Remove (const Handle(AIS_Animation)& theAnimatio
return Standard_False; return Standard_False;
} }
//============================================================================= //=================================================================================================
//function : Replace
//purpose : Standard_Boolean AIS_Animation::Replace(const Handle(AIS_Animation)& theAnimationOld,
//============================================================================= const Handle(AIS_Animation)& theAnimationNew)
Standard_Boolean AIS_Animation::Replace (const Handle(AIS_Animation)& theAnimationOld,
const Handle(AIS_Animation)& theAnimationNew)
{ {
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
if (anIter.Value() == theAnimationOld) if (anIter.Value() == theAnimationOld)
{ {
@@ -128,63 +118,59 @@ Standard_Boolean AIS_Animation::Replace (const Handle(AIS_Animation)& theAnimati
return Standard_False; return Standard_False;
} }
//============================================================================= //=================================================================================================
//function : CopyFrom
//purpose : void AIS_Animation::CopyFrom(const Handle(AIS_Animation)& theOther)
//=============================================================================
void AIS_Animation::CopyFrom (const Handle(AIS_Animation)& theOther)
{ {
myAnimations.Clear(); myAnimations.Clear();
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (theOther->myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(theOther->myAnimations);
anIter.More();
anIter.Next())
{ {
myAnimations.Append (anIter.Value()); myAnimations.Append(anIter.Value());
} }
UpdateTotalDuration(); UpdateTotalDuration();
myPtsStart = theOther->myPtsStart; myPtsStart = theOther->myPtsStart;
myOwnDuration = theOther->myOwnDuration; myOwnDuration = theOther->myOwnDuration;
} }
//============================================================================= //=================================================================================================
//function : UpdateTotalDuration
//purpose :
//=============================================================================
void AIS_Animation::UpdateTotalDuration() void AIS_Animation::UpdateTotalDuration()
{ {
myChildrenDuration = 0.0; myChildrenDuration = 0.0;
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
myChildrenDuration = Max (myChildrenDuration, anIter.Value()->StartPts() + anIter.Value()->Duration()); myChildrenDuration =
Max(myChildrenDuration, anIter.Value()->StartPts() + anIter.Value()->Duration());
} }
} }
//============================================================================= //=================================================================================================
//function : StartTimer
//purpose : void AIS_Animation::StartTimer(const Standard_Real theStartPts,
//============================================================================= const Standard_Real thePlaySpeed,
void AIS_Animation::StartTimer (const Standard_Real theStartPts, const Standard_Boolean theToUpdate,
const Standard_Real thePlaySpeed, const Standard_Boolean theToStopTimer)
const Standard_Boolean theToUpdate,
const Standard_Boolean theToStopTimer)
{ {
if (myTimer.IsNull()) if (myTimer.IsNull())
{ {
myTimer = new Media_Timer(); myTimer = new Media_Timer();
} }
myTimer->Stop(); myTimer->Stop();
myTimer->Seek (theStartPts); myTimer->Seek(theStartPts);
myTimer->SetPlaybackSpeed (thePlaySpeed); myTimer->SetPlaybackSpeed(thePlaySpeed);
Start (theToUpdate); Start(theToUpdate);
if (theToStopTimer) if (theToStopTimer)
{ {
myTimer->Stop(); myTimer->Stop();
myTimer->Seek (theStartPts); myTimer->Seek(theStartPts);
} }
} }
//============================================================================= //=================================================================================================
//function : UpdateTimer
//purpose :
//=============================================================================
Standard_Real AIS_Animation::UpdateTimer() Standard_Real AIS_Animation::UpdateTimer()
{ {
if (myTimer.IsNull()) if (myTimer.IsNull())
@@ -193,29 +179,26 @@ Standard_Real AIS_Animation::UpdateTimer()
} }
const Standard_Real anElapsedTime = myTimer->ElapsedTime(); const Standard_Real anElapsedTime = myTimer->ElapsedTime();
Update (anElapsedTime); Update(anElapsedTime);
return anElapsedTime; return anElapsedTime;
} }
//============================================================================= //=================================================================================================
//function : Start
//purpose : void AIS_Animation::Start(const Standard_Boolean theToUpdate)
//=============================================================================
void AIS_Animation::Start (const Standard_Boolean theToUpdate)
{ {
UpdateTotalDuration(); UpdateTotalDuration();
myState = AnimationState_Started; myState = AnimationState_Started;
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
anIter.ChangeValue()->Start (Standard_False); anIter.ChangeValue()->Start(Standard_False);
} }
if (theToUpdate) if (theToUpdate)
{ {
const Standard_Real anElapsedTime = !myTimer.IsNull() const Standard_Real anElapsedTime = !myTimer.IsNull() ? myTimer->ElapsedTime() : 0.0;
? myTimer->ElapsedTime() Update(anElapsedTime);
: 0.0;
Update (anElapsedTime);
} }
if (!myTimer.IsNull()) if (!myTimer.IsNull())
@@ -224,10 +207,8 @@ void AIS_Animation::Start (const Standard_Boolean theToUpdate)
} }
} }
//============================================================================= //=================================================================================================
//function : Pause
//purpose :
//=============================================================================
void AIS_Animation::Pause() void AIS_Animation::Pause()
{ {
myState = AnimationState_Paused; myState = AnimationState_Paused;
@@ -236,16 +217,15 @@ void AIS_Animation::Pause()
myTimer->Pause(); myTimer->Pause();
} }
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
anIter.ChangeValue()->Stop(); anIter.ChangeValue()->Stop();
} }
} }
//============================================================================= //=================================================================================================
//function : Stop
//purpose :
//=============================================================================
void AIS_Animation::Stop() void AIS_Animation::Stop()
{ {
myState = AnimationState_Stopped; myState = AnimationState_Stopped;
@@ -253,56 +233,50 @@ void AIS_Animation::Stop()
{ {
const Standard_Real anElapsedTime = ElapsedTime(); const Standard_Real anElapsedTime = ElapsedTime();
myTimer->Stop(); myTimer->Stop();
myTimer->Seek (Min (Duration(), anElapsedTime)); myTimer->Seek(Min(Duration(), anElapsedTime));
} }
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
anIter.ChangeValue()->Stop(); anIter.ChangeValue()->Stop();
} }
} }
//============================================================================= //=================================================================================================
//function : Update
//purpose : Standard_Boolean AIS_Animation::Update(const Standard_Real thePts)
//=============================================================================
Standard_Boolean AIS_Animation::Update (const Standard_Real thePts)
{ {
AIS_AnimationProgress aPosition; AIS_AnimationProgress aPosition;
aPosition.Pts = thePts; aPosition.Pts = thePts;
aPosition.LocalPts = thePts - myPtsStart; aPosition.LocalPts = thePts - myPtsStart;
aPosition.LocalNormalized = HasOwnDuration() aPosition.LocalNormalized = HasOwnDuration() ? (aPosition.LocalPts / myOwnDuration) : 0.0;
? (aPosition.LocalPts / myOwnDuration) aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
: 0.0; aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
aPosition.LocalNormalized = Max (0.0, aPosition.LocalNormalized); updateWithChildren(aPosition);
aPosition.LocalNormalized = Min (1.0, aPosition.LocalNormalized);
updateWithChildren (aPosition);
return thePts < myPtsStart + Duration(); return thePts < myPtsStart + Duration();
} }
//============================================================================= //=================================================================================================
//function : updateWithChildren
//purpose : void AIS_Animation::updateWithChildren(const AIS_AnimationProgress& thePosition)
//=============================================================================
void AIS_Animation::updateWithChildren (const AIS_AnimationProgress& thePosition)
{ {
if (thePosition.LocalPts < 0.0 if (thePosition.LocalPts < 0.0 || IsStopped())
|| IsStopped())
{ {
return; return;
} }
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{ {
const Handle(AIS_Animation)& anAnim = anIter.Value(); const Handle(AIS_Animation)& anAnim = anIter.Value();
AIS_AnimationProgress aPosition = thePosition; AIS_AnimationProgress aPosition = thePosition;
aPosition.LocalPts = aPosition.LocalPts - anAnim->StartPts(); aPosition.LocalPts = aPosition.LocalPts - anAnim->StartPts();
aPosition.LocalNormalized = anAnim->HasOwnDuration() aPosition.LocalNormalized =
? (aPosition.LocalPts / anAnim->OwnDuration()) anAnim->HasOwnDuration() ? (aPosition.LocalPts / anAnim->OwnDuration()) : 0.0;
: 0.0; aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
aPosition.LocalNormalized = Max (0.0, aPosition.LocalNormalized); aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
aPosition.LocalNormalized = Min (1.0, aPosition.LocalNormalized); anAnim->updateWithChildren(aPosition);
anAnim->updateWithChildren (aPosition);
} }
if (thePosition.LocalPts >= Duration()) if (thePosition.LocalPts >= Duration())
@@ -310,5 +284,5 @@ void AIS_Animation::updateWithChildren (const AIS_AnimationProgress& thePosition
Stop(); Stop();
} }
update (thePosition); update(thePosition);
} }

View File

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

View File

@@ -15,37 +15,35 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
//============================================================================= //=================================================================================================
//function : Constructor
//purpose : AIS_AnimationAxisRotation::AIS_AnimationAxisRotation(
//============================================================================= const TCollection_AsciiString& theAnimationName,
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName, const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveContext)& theContext, const Handle(AIS_InteractiveObject)& theObject,
const Handle(AIS_InteractiveObject)& theObject, const gp_Ax1& theAxis,
const gp_Ax1& theAxis, const Standard_Real theAngleStart,
const Standard_Real theAngleStart, const Standard_Real theAngleEnd)
const Standard_Real theAngleEnd) : AIS_BaseAnimationObject(theAnimationName, theContext, theObject),
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject), myRotAxis(theAxis),
myRotAxis (theAxis), myAngleStart(theAngleStart),
myAngleStart (theAngleStart), myAngleEnd(theAngleEnd)
myAngleEnd (theAngleEnd)
{ {
// //
} }
//============================================================================= //=================================================================================================
//function : update
//purpose : void AIS_AnimationAxisRotation::update(const AIS_AnimationProgress& theProgress)
//=============================================================================
void AIS_AnimationAxisRotation::update (const AIS_AnimationProgress& theProgress)
{ {
if (myObject.IsNull()) if (myObject.IsNull())
{ {
return; return;
} }
gp_Trsf aTrsf; gp_Trsf aTrsf;
Standard_Real aCurrentAngle = (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd; Standard_Real aCurrentAngle =
aTrsf.SetRotation (myRotAxis, aCurrentAngle); (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
updateTrsf (aTrsf); aTrsf.SetRotation(myRotAxis, aCurrentAngle);
updateTrsf(aTrsf);
} }

View File

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

View File

@@ -18,38 +18,32 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation) IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
//============================================================================= //=================================================================================================
//function : AIS_AnimationCamera
//purpose : AIS_AnimationCamera::AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
//============================================================================= const Handle(V3d_View)& theView)
AIS_AnimationCamera::AIS_AnimationCamera (const TCollection_AsciiString& theAnimationName, : AIS_Animation(theAnimationName),
const Handle(V3d_View)& theView) myView(theView)
: AIS_Animation (theAnimationName),
myView (theView)
{ {
// //
} }
//============================================================================= //=================================================================================================
//function : update
//purpose : void AIS_AnimationCamera::update(const AIS_AnimationProgress& theProgress)
//=============================================================================
void AIS_AnimationCamera::update (const AIS_AnimationProgress& theProgress)
{ {
if (myView.IsNull() if (myView.IsNull() || myCamStart.IsNull() || myCamEnd.IsNull())
|| myCamStart.IsNull()
|| myCamEnd.IsNull())
{ {
return; return;
} }
Handle(Graphic3d_Camera) aCamera = myView->Camera(); Handle(Graphic3d_Camera) aCamera = myView->Camera();
Graphic3d_CameraLerp aCamLerp (myCamStart, myCamEnd); Graphic3d_CameraLerp aCamLerp(myCamStart, myCamEnd);
aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera); aCamLerp.Interpolate(HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False); const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate(Standard_False);
myView->SetCamera (aCamera); myView->SetCamera(aCamera);
myView->SetImmediateUpdate (aPrevImmUpdate); myView->SetImmediateUpdate(aPrevImmUpdate);
myView->Invalidate(); myView->Invalidate();
} }

View File

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

View File

@@ -16,26 +16,22 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
//============================================================================= //=================================================================================================
//function : Constructor
//purpose : AIS_AnimationObject::AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
//============================================================================= const Handle(AIS_InteractiveContext)& theContext,
AIS_AnimationObject::AIS_AnimationObject (const TCollection_AsciiString& theAnimationName, const Handle(AIS_InteractiveObject)& theObject,
const Handle(AIS_InteractiveContext)& theContext, const gp_Trsf& theTrsfStart,
const Handle(AIS_InteractiveObject)& theObject, const gp_Trsf& theTrsfEnd)
const gp_Trsf& theTrsfStart, : AIS_BaseAnimationObject(theAnimationName, theContext, theObject),
const gp_Trsf& theTrsfEnd) myTrsfLerp(theTrsfStart, theTrsfEnd)
: AIS_BaseAnimationObject (theAnimationName, theContext, theObject),
myTrsfLerp (theTrsfStart, theTrsfEnd)
{ {
// //
} }
//============================================================================= //=================================================================================================
//function : update
//purpose : void AIS_AnimationObject::update(const AIS_AnimationProgress& theProgress)
//=============================================================================
void AIS_AnimationObject::update (const AIS_AnimationProgress& theProgress)
{ {
if (myObject.IsNull()) if (myObject.IsNull())
{ {
@@ -43,6 +39,6 @@ void AIS_AnimationObject::update (const AIS_AnimationProgress& theProgress)
} }
gp_Trsf aTrsf; gp_Trsf aTrsf;
myTrsfLerp.Interpolate (theProgress.LocalNormalized, aTrsf); myTrsfLerp.Interpolate(theProgress.LocalNormalized, aTrsf);
updateTrsf (aTrsf); updateTrsf(aTrsf);
} }

View File

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

View File

@@ -14,46 +14,49 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <AIS_AttributeFilter.hxx> #include <AIS_AttributeFilter.hxx>
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_AttributeFilter,SelectMgr_Filter) IMPLEMENT_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
AIS_AttributeFilter::AIS_AttributeFilter(): AIS_AttributeFilter::AIS_AttributeFilter()
hasC(Standard_False), : hasC(Standard_False),
hasW(Standard_False){} hasW(Standard_False)
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol):
myCol(aCol),
hasC(Standard_True),
hasW(Standard_False){}
AIS_AttributeFilter::AIS_AttributeFilter(const 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())); }
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol)
: myCol(aCol),
hasC(Standard_True),
hasW(Standard_False)
{
}
AIS_AttributeFilter::AIS_AttributeFilter(const Standard_Real aWid)
: myWid(aWid),
hasC(Standard_False),
hasW(Standard_True)
{
}
Standard_Boolean AIS_AttributeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{
Handle(AIS_InteractiveObject) aSelectable(
Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable()));
if (aSelectable.IsNull()) if (aSelectable.IsNull())
return Standard_False; return Standard_False;
Standard_Boolean okstat = Standard_True; Standard_Boolean okstat = Standard_True;
if( hasC && aSelectable->HasColor() ) if (hasC && aSelectable->HasColor())
{ {
Quantity_Color aColor; Quantity_Color aColor;
aSelectable->Color (aColor); aSelectable->Color(aColor);
okstat = (myCol == aColor.Name()); okstat = (myCol == aColor.Name());
} }
if( hasW && aSelectable->HasWidth() ) if (hasW && aSelectable->HasWidth())
okstat = (myWid == aSelectable->Width()) && okstat; okstat = (myWid == aSelectable->Width()) && okstat;
return okstat; return okstat;

View File

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

View File

@@ -38,192 +38,172 @@
#include <StdPrs_Curve.hxx> #include <StdPrs_Curve.hxx>
#include <UnitsAPI.hxx> #include <UnitsAPI.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_Axis,AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
//======================================================================= //=================================================================================================
//function : AIS_Axis
//purpose : AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent)
//======================================================================= : myComponent(aComponent),
AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent): myTypeOfAxis(AIS_TOAX_Unknown),
myComponent(aComponent), myIsXYZAxis(Standard_False)
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{ {
myDrawer->SetLineAspect(new Prs3d_LineAspect myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
SetInfiniteState(); SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction(); gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location(); gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ(); myPfirst = loc.XYZ() + aLength * thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ(); myPlast = loc.XYZ() - aLength * thedir.XYZ();
} }
//======================================================================= //=======================================================================
//function : AIS_Axis // function : AIS_Axis
//purpose : Xaxis, YAxis, ZAxis // purpose : Xaxis, YAxis, ZAxis
//======================================================================= //=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType)
const AIS_TypeOfAxis anAxisType): : myAx2(aComponent),
myAx2(aComponent), myTypeOfAxis(anAxisType),
myTypeOfAxis(anAxisType), myIsXYZAxis(Standard_True)
myIsXYZAxis(Standard_True)
{ {
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect(); Handle(Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
Standard_Real aLength; Standard_Real aLength;
try { try
aLength = UnitsAPI::AnyToLS(100. ,"mm"); {
} catch (Standard_Failure const&) { aLength = UnitsAPI::AnyToLS(100., "mm");
}
catch (Standard_Failure const&)
{
aLength = 0.1; aLength = 0.1;
} }
DA->SetAxisLength(aLength,aLength,aLength); DA->SetAxisLength(aLength, aLength, aLength);
Quantity_Color col (Quantity_NOC_TURQUOISE); Quantity_Color col(Quantity_NOC_TURQUOISE);
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col); DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col);
myDrawer->SetDatumAspect(DA); myDrawer->SetDatumAspect(DA);
ComputeFields(); ComputeFields();
} }
//======================================================================= //=================================================================================================
//function : AIS_Axis
//purpose :
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis) AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
:myComponent(new Geom_Line(anAxis->Ax1())), : myComponent(new Geom_Line(anAxis->Ax1())),
myTypeOfAxis(AIS_TOAX_Unknown), myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False) myIsXYZAxis(Standard_False)
{ {
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.)); myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
SetInfiniteState(); SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction(); gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location(); gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ(); myPfirst = loc.XYZ() + aLength * thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ(); myPlast = loc.XYZ() - aLength * thedir.XYZ();
} }
//======================================================================= //=================================================================================================
//function : AIS_Axis
//purpose : AIS_Axis::AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength)
//======================================================================= : myComponent(new Geom_Line(theAxis)),
AIS_Axis::AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength) myTypeOfAxis(AIS_TOAX_ZAxis),
: myComponent (new Geom_Line (theAxis)), myIsXYZAxis(Standard_True)
myTypeOfAxis (AIS_TOAX_ZAxis),
myIsXYZAxis (Standard_True)
{ {
myDir = theAxis.Direction(); myDir = theAxis.Direction();
myPfirst = theAxis.Location(); myPfirst = theAxis.Location();
if (theLength <= 0 && theLength != -1) if (theLength <= 0 && theLength != -1)
{ {
throw Standard_NumericError ("AIS_Axis::AIS_Axis : invalid value for theLength parameter"); throw Standard_NumericError("AIS_Axis::AIS_Axis : invalid value for theLength parameter");
} }
myVal = (theLength == -1) ? UnitsAPI::AnyToLS (250000., "mm") : theLength; myVal = (theLength == -1) ? UnitsAPI::AnyToLS(250000., "mm") : theLength;
myPlast = myPfirst.XYZ() + myVal * myDir.XYZ(); myPlast = myPfirst.XYZ() + myVal * myDir.XYZ();
SetInfiniteState(); SetInfiniteState();
Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect(); Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
aDatumAspect->SetDrawLabels (Standard_False); aDatumAspect->SetDrawLabels(Standard_False);
myDrawer->SetDatumAspect (aDatumAspect); myDrawer->SetDatumAspect(aDatumAspect);
Handle(Prs3d_LineAspect) aDefaultLineAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0); Handle(Prs3d_LineAspect) aDefaultLineAspect =
myDrawer->SetLineAspect (aDefaultLineAspect); new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
myDrawer->SetLineAspect(aDefaultLineAspect);
myLineAspect = myDrawer->LineAspect(); myLineAspect = myDrawer->LineAspect();
} }
//======================================================================= //=================================================================================================
//function : SetComponent
//purpose :
//=======================================================================
void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent) void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent)
{ {
myComponent = aComponent; myComponent = aComponent;
myTypeOfAxis = AIS_TOAX_Unknown; myTypeOfAxis = AIS_TOAX_Unknown;
myIsXYZAxis = Standard_False; myIsXYZAxis = Standard_False;
SetInfiniteState(); SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction(); gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location(); gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm"); Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ(); myPfirst = loc.XYZ() + aLength * thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ(); myPlast = loc.XYZ() - aLength * thedir.XYZ();
} }
//=================================================================================================
//=======================================================================
//function : SetAxis2Placement
//purpose :
//=======================================================================
void AIS_Axis::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent, void AIS_Axis::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType) const AIS_TypeOfAxis anAxisType)
{ {
myAx2 = aComponent; myAx2 = aComponent;
myTypeOfAxis = anAxisType; myTypeOfAxis = anAxisType;
myIsXYZAxis = Standard_True; myIsXYZAxis = Standard_True;
ComputeFields(); ComputeFields();
} }
//======================================================================= //=================================================================================================
//function : SetAxis1Placement
//purpose :
//=======================================================================
void AIS_Axis::SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis) void AIS_Axis::SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis)
{ {
SetComponent(new Geom_Line(anAxis->Ax1())); SetComponent(new Geom_Line(anAxis->Ax1()));
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_Axis::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer )
{ {
thePrs->SetInfiniteState (myInfiniteState); thePrs->SetInfiniteState(myInfiniteState);
if (!myIsXYZAxis) if (!myIsXYZAxis)
{ {
GeomAdaptor_Curve curv (myComponent); GeomAdaptor_Curve curv(myComponent);
StdPrs_Curve::Add (thePrs, curv, myDrawer); StdPrs_Curve::Add(thePrs, curv, myDrawer);
} }
else else
{ {
DsgPrs_XYZAxisPresentation::Add (thePrs, myLineAspect, myDir, myVal, DsgPrs_XYZAxisPresentation::Add(thePrs,
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "", myLineAspect,
myPfirst, myPlast); myDir,
myVal,
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "",
myPfirst,
myPlast);
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Axis::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, void AIS_Axis::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer) const Standard_Integer)
{ {
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner (this, 3); Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 3);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, myPfirst, myPlast);
myPfirst,
myPlast);
aSelection->Add(seg); aSelection->Add(seg);
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose : void AIS_Axis::SetColor(const Quantity_Color& aCol)
//=======================================================================
void AIS_Axis::SetColor(const Quantity_Color &aCol)
{ {
hasOwnColor=Standard_True; hasOwnColor = Standard_True;
myDrawer->SetColor (aCol); myDrawer->SetColor(aCol);
myDrawer->LineAspect()->SetColor(aCol); myDrawer->LineAspect()->SetColor(aCol);
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect(); const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol); DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol); DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
@@ -231,17 +211,17 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol)
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Axis::SetWidth(const Standard_Real aValue) void AIS_Axis::SetWidth(const Standard_Real aValue)
{ {
if(aValue<0.0) return; if (aValue < 0.0)
if(aValue==0) UnsetWidth(); return;
if (aValue == 0)
UnsetWidth();
myDrawer->LineAspect()->SetWidth(aValue); myDrawer->LineAspect()->SetWidth(aValue);
const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect(); const Handle(Prs3d_DatumAspect)& DA = myDrawer->DatumAspect();
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetWidth(aValue); DA->LineAspect(Prs3d_DatumParts_XAxis)->SetWidth(aValue);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetWidth(aValue); DA->LineAspect(Prs3d_DatumParts_YAxis)->SetWidth(aValue);
@@ -249,87 +229,80 @@ void AIS_Axis::SetWidth(const Standard_Real aValue)
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : SetDisplayAspect
//purpose : void AIS_Axis::SetDisplayAspect(const Handle(Prs3d_LineAspect)& theNewLineAspect)
//=======================================================================
void AIS_Axis::SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewLineAspect)
{ {
myDrawer->SetLineAspect (theNewLineAspect); myDrawer->SetLineAspect(theNewLineAspect);
myLineAspect = myDrawer->LineAspect(); myLineAspect = myDrawer->LineAspect();
SetColor (theNewLineAspect->Aspect()->Color()); SetColor(theNewLineAspect->Aspect()->Color());
} }
//======================================================================= //=================================================================================================
//function : ComputeFields
//purpose :
//=======================================================================
void AIS_Axis::ComputeFields() void AIS_Axis::ComputeFields()
{ {
if (myIsXYZAxis){ if (myIsXYZAxis)
{
// calcul de myPFirst,myPlast // calcul de myPFirst,myPlast
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect(); Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
gp_Ax2 anAxis = myAx2->Ax2(); gp_Ax2 anAxis = myAx2->Ax2();
const gp_Pnt& Orig = anAxis.Location(); const gp_Pnt& Orig = anAxis.Location();
const gp_Dir& oX = anAxis.XDirection(); const gp_Dir& oX = anAxis.XDirection();
const gp_Dir& oY = anAxis.YDirection(); const gp_Dir& oY = anAxis.YDirection();
const gp_Dir& oZ = anAxis.Direction(); const gp_Dir& oZ = anAxis.Direction();
Standard_Real xo,yo,zo,x = 0.,y = 0.,z = 0.; Standard_Real xo, yo, zo, x = 0., y = 0., z = 0.;
Orig.Coord(xo,yo,zo); Orig.Coord(xo, yo, zo);
myPfirst.SetCoord(xo,yo,zo); myPfirst.SetCoord(xo, yo, zo);
switch (myTypeOfAxis) { switch (myTypeOfAxis)
case AIS_TOAX_XAxis: {
{ case AIS_TOAX_XAxis: {
oX.Coord(x,y,z); oX.Coord(x, y, z);
myVal = DA->AxisLength(Prs3d_DatumParts_XAxis); myVal = DA->AxisLength(Prs3d_DatumParts_XAxis);
myDir = oX; myDir = oX;
myLineAspect = DA->LineAspect(Prs3d_DatumParts_XAxis); myLineAspect = DA->LineAspect(Prs3d_DatumParts_XAxis);
myText = Standard_CString ("X"); myText = Standard_CString("X");
break; break;
} }
case AIS_TOAX_YAxis: case AIS_TOAX_YAxis: {
{ oY.Coord(x, y, z);
oY.Coord(x,y,z); myVal = DA->AxisLength(Prs3d_DatumParts_YAxis);
myVal = DA->AxisLength(Prs3d_DatumParts_YAxis); myDir = oY;
myDir = oY; myLineAspect = DA->LineAspect(Prs3d_DatumParts_YAxis);
myLineAspect = DA->LineAspect(Prs3d_DatumParts_YAxis); myText = Standard_CString("Y");
myText = Standard_CString ("Y"); break;
break;
} }
case AIS_TOAX_ZAxis: case AIS_TOAX_ZAxis: {
{ oZ.Coord(x, y, z);
oZ.Coord(x,y,z); myVal = DA->AxisLength(Prs3d_DatumParts_ZAxis);
myVal = DA->AxisLength(Prs3d_DatumParts_ZAxis); myDir = oZ;
myDir = oZ; myLineAspect = DA->LineAspect(Prs3d_DatumParts_ZAxis);
myLineAspect = DA->LineAspect(Prs3d_DatumParts_ZAxis); myText = Standard_CString("Z");
myText = Standard_CString ("Z"); break;
break;
} }
default: default:
break; break;
} }
myComponent = new Geom_Line(Orig,myDir); myComponent = new Geom_Line(Orig, myDir);
x = xo + x*myVal; y = yo + y*myVal; z = zo + z*myVal; x = xo + x * myVal;
myPlast.SetCoord(x,y,z); y = yo + y * myVal;
z = zo + z * myVal;
myPlast.SetCoord(x, y, z);
SetInfiniteState(); SetInfiniteState();
} }
} }
//======================================================================= //=================================================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_Axis:: Standard_Boolean AIS_Axis::AcceptDisplayMode(const Standard_Integer aMode) const
AcceptDisplayMode(const Standard_Integer aMode) const {
{return aMode == 0;} return aMode == 0;
}
//=================================================================================================
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Axis::UnsetColor() void AIS_Axis::UnsetColor()
{ {
myDrawer->LineAspect()->SetColor(Quantity_NOC_RED); myDrawer->LineAspect()->SetColor(Quantity_NOC_RED);
@@ -340,10 +313,8 @@ void AIS_Axis::UnsetColor()
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Quantity_NOC_TURQUOISE); myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Quantity_NOC_TURQUOISE);
SynchronizeAspects(); SynchronizeAspects();
} }
//=======================================================================
//function : UnsetWidth //=================================================================================================
//purpose :
//=======================================================================
void AIS_Axis::UnsetWidth() void AIS_Axis::UnsetWidth()
{ {

View File

@@ -38,13 +38,13 @@ class AIS_Axis : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
public: public:
//! Initializes the line aComponent //! Initializes the line aComponent
Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent); Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent);
//! initializes the axis2 position //! initializes the axis2 position
//! aComponent. The coordinate system used is right-handed. //! aComponent. The coordinate system used is right-handed.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType); Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
//! Initializes the axis1 position anAxis. //! Initializes the axis1 position anAxis.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis); Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis);
@@ -52,14 +52,14 @@ public:
//! Initializes the ray as axis with start point and direction //! Initializes the ray as axis with start point and direction
//! @param[in] theAxis Start point and direction of the ray //! @param[in] theAxis Start point and direction of the ray
//! @param[in] theLength Optional length of the ray (ray is infinite by default). //! @param[in] theLength Optional length of the ray (ray is infinite by default).
Standard_EXPORT AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength = -1); Standard_EXPORT AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength = -1);
//! Returns the axis entity aComponent and identifies it //! Returns the axis entity aComponent and identifies it
//! as a component of a shape. //! as a component of a shape.
const Handle(Geom_Line)& Component() const { return myComponent; } const Handle(Geom_Line)& Component() const { return myComponent; }
//! Sets the coordinates of the lin aComponent. //! Sets the coordinates of the lin aComponent.
Standard_EXPORT void SetComponent (const Handle(Geom_Line)& aComponent); Standard_EXPORT void SetComponent(const Handle(Geom_Line)& aComponent);
//! Returns the position of axis2 and positions it by //! Returns the position of axis2 and positions it by
//! identifying it as the x, y, or z axis and giving its //! identifying it as the x, y, or z axis and giving its
@@ -69,17 +69,18 @@ public:
//! Allows you to provide settings for aComponent:the //! Allows you to provide settings for aComponent:the
//! position and direction of an axis in 3D space. The //! position and direction of an axis in 3D space. The
//! coordinate system used is right-handed. //! coordinate system used is right-handed.
Standard_EXPORT void SetAxis2Placement (const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType); Standard_EXPORT void SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
//! Constructs a new line to serve as the axis anAxis in 3D space. //! Constructs a new line to serve as the axis anAxis in 3D space.
Standard_EXPORT void SetAxis1Placement (const Handle(Geom_Axis1Placement)& anAxis); Standard_EXPORT void SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis);
//! Returns the type of axis. //! Returns the type of axis.
AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; } AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; }
//! Constructs the entity theTypeAxis to stock information //! Constructs the entity theTypeAxis to stock information
//! concerning type of axis. //! concerning type of axis.
void SetTypeOfAxis (const AIS_TypeOfAxis theTypeAxis) { myTypeOfAxis = theTypeAxis; } void SetTypeOfAxis(const AIS_TypeOfAxis theTypeAxis) { myTypeOfAxis = theTypeAxis; }
//! Returns a signature of 2 for axis datums. When you //! Returns a signature of 2 for axis datums. When you
//! activate mode 2 by a signature, you pick AIS objects //! activate mode 2 by a signature, you pick AIS objects
@@ -87,47 +88,48 @@ public:
Standard_Boolean IsXYZAxis() const { return myIsXYZAxis; } Standard_Boolean IsXYZAxis() const { return myIsXYZAxis; }
//! Returns true if the interactive object accepts the display mode aMode. //! Returns true if the interactive object accepts the display mode aMode.
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE; Standard_EXPORT Standard_Boolean
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 2; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 2; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; } virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Set required visualization parameters. //! Set required visualization parameters.
Standard_EXPORT void SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewDatumAspect); Standard_EXPORT void SetDisplayAspect(const Handle(Prs3d_LineAspect)& theNewDatumAspect);
Standard_EXPORT void UnsetColor() Standard_OVERRIDE; Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeFields(); Standard_EXPORT void ComputeFields();
private: private:
Handle(Geom_Line) myComponent;
Handle(Geom_Line) myComponent;
Handle(Geom_Axis2Placement) myAx2; Handle(Geom_Axis2Placement) myAx2;
gp_Pnt myPfirst; gp_Pnt myPfirst;
gp_Pnt myPlast; gp_Pnt myPlast;
AIS_TypeOfAxis myTypeOfAxis; AIS_TypeOfAxis myTypeOfAxis;
Standard_Boolean myIsXYZAxis; Standard_Boolean myIsXYZAxis;
gp_Dir myDir; gp_Dir myDir;
Standard_Real myVal; Standard_Real myVal;
Standard_CString myText; Standard_CString myText;
Handle(Prs3d_LineAspect) myLineAspect; Handle(Prs3d_LineAspect) myLineAspect;
}; };
DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject)

View File

@@ -22,85 +22,71 @@
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_BadEdgeFilter,SelectMgr_Filter) IMPLEMENT_STANDARD_RTTIEXT(AIS_BadEdgeFilter, SelectMgr_Filter)
//=================================================================================================
//=======================================================================
//function : AIS_BadEdgeFilter
//purpose :
//=======================================================================
AIS_BadEdgeFilter::AIS_BadEdgeFilter() AIS_BadEdgeFilter::AIS_BadEdgeFilter()
{ {
myContour=0; myContour = 0;
} }
//======================================================================= //=================================================================================================
//function : ActsOn
//purpose :
//=======================================================================
Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{ {
return (aType == TopAbs_EDGE); return (aType == TopAbs_EDGE);
} }
//======================================================================= //=================================================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{ {
if (myContour==0) if (myContour == 0)
return Standard_True; return Standard_True;
Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO)); Handle(StdSelect_BRepOwner) aBO(Handle(StdSelect_BRepOwner)::DownCast(EO));
if (aBO.IsNull()) if (aBO.IsNull())
return Standard_True; return Standard_True;
const TopoDS_Shape& aShape = aBO->Shape(); const TopoDS_Shape& aShape = aBO->Shape();
if (myBadEdges.IsBound(myContour)) { if (myBadEdges.IsBound(myContour))
{
TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour)); TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
for (; it.More(); it.Next()) { for (; it.More(); it.Next())
{
if (it.Value().IsSame(aShape)) if (it.Value().IsSame(aShape))
return Standard_False; return Standard_False;
} }
} }
return Standard_True; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : AddEdge
//purpose :
//=======================================================================
void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge, void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge, const Standard_Integer Index)
const Standard_Integer Index)
{ {
if (myBadEdges.IsBound(Index)) { if (myBadEdges.IsBound(Index))
myBadEdges.ChangeFind(Index).Append(anEdge); {
myBadEdges.ChangeFind(Index).Append(anEdge);
} }
else { else
{
TopTools_ListOfShape LS; TopTools_ListOfShape LS;
LS.Append(anEdge); LS.Append(anEdge);
myBadEdges.Bind(Index,LS); myBadEdges.Bind(Index, LS);
} }
} }
//======================================================================= //=================================================================================================
//function : RemoveEdges
//purpose :
//=======================================================================
void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index) void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
{ {
myBadEdges.UnBind(Index); myBadEdges.UnBind(Index);
} }
//======================================================================= //=================================================================================================
//function : RemoveEdges
//purpose :
//=======================================================================
void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index) void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
{ {

View File

@@ -26,7 +26,6 @@
class SelectMgr_EntityOwner; class SelectMgr_EntityOwner;
class TopoDS_Edge; class TopoDS_Edge;
class AIS_BadEdgeFilter; class AIS_BadEdgeFilter;
DEFINE_STANDARD_HANDLE(AIS_BadEdgeFilter, SelectMgr_Filter) DEFINE_STANDARD_HANDLE(AIS_BadEdgeFilter, SelectMgr_Filter)
@@ -35,50 +34,33 @@ class AIS_BadEdgeFilter : public SelectMgr_Filter
{ {
public: public:
//! Constructs an empty filter object for bad edges. //! Constructs an empty filter object for bad edges.
Standard_EXPORT AIS_BadEdgeFilter(); Standard_EXPORT AIS_BadEdgeFilter();
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
Standard_OVERRIDE;
//! sets <myContour> with current contour. used by //! sets <myContour> with current contour. used by
//! IsOk. //! IsOk.
Standard_EXPORT void SetContour (const Standard_Integer Index); Standard_EXPORT void SetContour(const Standard_Integer Index);
//! Adds an edge to the list of non-selectionnable //! Adds an edge to the list of non-selectionnable
//! edges. //! edges.
Standard_EXPORT void AddEdge (const TopoDS_Edge& anEdge, const Standard_Integer Index); Standard_EXPORT void AddEdge(const TopoDS_Edge& anEdge, const Standard_Integer Index);
//! removes from the list of non-selectionnable edges //! removes from the list of non-selectionnable edges
//! all edges in the contour <Index>. //! all edges in the contour <Index>.
Standard_EXPORT void RemoveEdges (const Standard_Integer Index); Standard_EXPORT void RemoveEdges(const Standard_Integer Index);
DEFINE_STANDARD_RTTIEXT(AIS_BadEdgeFilter, SelectMgr_Filter)
DEFINE_STANDARD_RTTIEXT(AIS_BadEdgeFilter,SelectMgr_Filter)
protected: protected:
private: private:
TopTools_DataMapOfIntegerListOfShape myBadEdges; TopTools_DataMapOfIntegerListOfShape myBadEdges;
Standard_Integer myContour; Standard_Integer myContour;
}; };
#endif // _AIS_BadEdgeFilter_HeaderFile #endif // _AIS_BadEdgeFilter_HeaderFile

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,51 +29,45 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
namespace namespace
{ {
static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f; static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f;
static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE; static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE;
} } // namespace
//=================================================================================================
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_CameraFrustum::AIS_CameraFrustum() AIS_CameraFrustum::AIS_CameraFrustum()
: myPoints (0, Graphic3d_Camera::FrustumVerticesNB) : myPoints(0, Graphic3d_Camera::FrustumVerticesNB)
{ {
myDrawer->SetLineAspect (new Prs3d_LineAspect (THE_DEFAULT_COLOR, Aspect_TOL_SOLID, 1.0)); myDrawer->SetLineAspect(new Prs3d_LineAspect(THE_DEFAULT_COLOR, Aspect_TOL_SOLID, 1.0));
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect(); Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
aShadingAspect->SetMaterial (Graphic3d_NameOfMaterial_Plastified); aShadingAspect->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
aShadingAspect->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend); aShadingAspect->Aspect()->SetAlphaMode(Graphic3d_AlphaMode_Blend);
aShadingAspect->SetTransparency (THE_DEFAULT_TRANSPARENCY); aShadingAspect->SetTransparency(THE_DEFAULT_TRANSPARENCY);
aShadingAspect->SetColor (THE_DEFAULT_COLOR); aShadingAspect->SetColor(THE_DEFAULT_COLOR);
myDrawer->SetShadingAspect (aShadingAspect); myDrawer->SetShadingAspect(aShadingAspect);
myDrawer->SetTransparency (THE_DEFAULT_TRANSPARENCY); myDrawer->SetTransparency(THE_DEFAULT_TRANSPARENCY);
SetDisplayMode (AIS_Shaded); SetDisplayMode(AIS_Shaded);
} }
//======================================================================= //=================================================================================================
//function : AcceptDisplayMode
//purpose : Standard_Boolean AIS_CameraFrustum::AcceptDisplayMode(const Standard_Integer theMode) const
//=======================================================================
Standard_Boolean AIS_CameraFrustum::AcceptDisplayMode (const Standard_Integer theMode) const
{ {
return theMode == AIS_Shaded || theMode == AIS_WireFrame; return theMode == AIS_Shaded || theMode == AIS_WireFrame;
} }
//======================================================================= //=================================================================================================
//function : SetCameraFrustum
//purpose : void AIS_CameraFrustum::SetCameraFrustum(const Handle(Graphic3d_Camera)& theCamera)
//=======================================================================
void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCamera)
{ {
if (theCamera.IsNull()) if (theCamera.IsNull())
{ {
return; return;
} }
theCamera->FrustumPoints (myPoints); theCamera->FrustumPoints(myPoints);
fillTriangles(); fillTriangles();
fillBorders(); fillBorders();
@@ -81,22 +75,18 @@ void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCam
SetToUpdate(); SetToUpdate();
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose : void AIS_CameraFrustum::SetColor(const Quantity_Color& theColor)
//=======================================================================
void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor)
{ {
AIS_InteractiveObject::SetColor (theColor); AIS_InteractiveObject::SetColor(theColor);
myDrawer->ShadingAspect()->SetColor (theColor); myDrawer->ShadingAspect()->SetColor(theColor);
myDrawer->LineAspect()->SetColor (theColor); myDrawer->LineAspect()->SetColor(theColor);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::UnsetColor() void AIS_CameraFrustum::UnsetColor()
{ {
if (!HasColor()) if (!HasColor())
@@ -106,26 +96,22 @@ void AIS_CameraFrustum::UnsetColor()
AIS_InteractiveObject::UnsetColor(); AIS_InteractiveObject::UnsetColor();
myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR); myDrawer->ShadingAspect()->SetColor(THE_DEFAULT_COLOR);
myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR); myDrawer->LineAspect()->SetColor(THE_DEFAULT_COLOR);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_CameraFrustum::UnsetTransparency() void AIS_CameraFrustum::UnsetTransparency()
{ {
myDrawer->ShadingAspect()->SetTransparency (0.0f); myDrawer->ShadingAspect()->SetTransparency(0.0f);
myDrawer->SetTransparency (0.0f); myDrawer->SetTransparency(0.0f);
SynchronizeAspects(); SynchronizeAspects();
} }
//======================================================================= //=================================================================================================
//function : fillTriangles
//purpose :
//=======================================================================
void AIS_CameraFrustum::fillTriangles() void AIS_CameraFrustum::fillTriangles()
{ {
if (myTriangles.IsNull()) if (myTriangles.IsNull())
@@ -133,18 +119,19 @@ void AIS_CameraFrustum::fillTriangles()
const Standard_Integer aPlaneTriangleVertsNb = 2 * 3; const Standard_Integer aPlaneTriangleVertsNb = 2 * 3;
const Standard_Integer aPlanesNb = 3 * 2; const Standard_Integer aPlanesNb = 3 * 2;
myTriangles = new Graphic3d_ArrayOfTriangles (Graphic3d_Camera::FrustumVerticesNB, aPlaneTriangleVertsNb * aPlanesNb); myTriangles = new Graphic3d_ArrayOfTriangles(Graphic3d_Camera::FrustumVerticesNB,
myTriangles->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0)); aPlaneTriangleVertsNb * aPlanesNb);
myTriangles->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
// Triangles go in order (clockwise vertices traversing for correct normal): // Triangles go in order (clockwise vertices traversing for correct normal):
// (0, 2, 1), (3, 1, 2) // (0, 2, 1), (3, 1, 2)
const Standard_Integer aLookup1_clockwise[] = { 0, 1, 0, 1, 0, 1 }; const Standard_Integer aLookup1_clockwise[] = {0, 1, 0, 1, 0, 1};
const Standard_Integer aLookup2_clockwise[] = { 0, 0, 1, 1, 1, 0 }; const Standard_Integer aLookup2_clockwise[] = {0, 0, 1, 1, 1, 0};
// Triangles go in order (counterclockwise vertices traversing for correct normal): // Triangles go in order (counterclockwise vertices traversing for correct normal):
// (1, 2, 0), (2, 1, 3) // (1, 2, 0), (2, 1, 3)
const Standard_Integer aLookup1_anticlockwise[] = { 0, 1, 0, 1, 0, 1 }; const Standard_Integer aLookup1_anticlockwise[] = {0, 1, 0, 1, 0, 1};
const Standard_Integer aLookup2_anticlockwise[] = { 1, 0, 0, 0, 1, 1 }; const Standard_Integer aLookup2_anticlockwise[] = {1, 0, 0, 0, 1, 1};
Standard_Integer aShifts[] = { 0, 0, 0 }; Standard_Integer aShifts[] = {0, 0, 0};
// Planes go in order: // Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR // LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
@@ -167,37 +154,37 @@ void AIS_CameraFrustum::fillTriangles()
} }
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2]; Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
myTriangles->AddEdge (anIndex + 1); myTriangles->AddEdge(anIndex + 1);
} }
} }
} }
} }
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter) for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB;
++aPointIter)
{ {
const Graphic3d_Vec3d aPnt = myPoints[aPointIter]; const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
myTriangles->SetVertice (aPointIter + 1, gp_Pnt (aPnt.x(), aPnt.y(), aPnt.z())); myTriangles->SetVertice(aPointIter + 1, gp_Pnt(aPnt.x(), aPnt.y(), aPnt.z()));
} }
} }
//======================================================================= //=================================================================================================
//function : fillBorders
//purpose :
//=======================================================================
void AIS_CameraFrustum::fillBorders() void AIS_CameraFrustum::fillBorders()
{ {
if (myBorders.IsNull()) if (myBorders.IsNull())
{ {
const Standard_Integer aPlaneSegmVertsNb = 2 * 4; const Standard_Integer aPlaneSegmVertsNb = 2 * 4;
const Standard_Integer aPlanesNb = 3 * 2; const Standard_Integer aPlanesNb = 3 * 2;
myBorders = new Graphic3d_ArrayOfSegments (Graphic3d_Camera::FrustumVerticesNB, aPlaneSegmVertsNb * aPlanesNb); myBorders = new Graphic3d_ArrayOfSegments(Graphic3d_Camera::FrustumVerticesNB,
myBorders->SetVertice (Graphic3d_Camera::FrustumVerticesNB, gp_Pnt (0.0, 0.0, 0.0)); aPlaneSegmVertsNb * aPlanesNb);
myBorders->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
// Segments go in order: // Segments go in order:
// (0, 2), (2, 3), (3, 1), (1, 0) // (0, 2), (2, 3), (3, 1), (1, 0)
const Standard_Integer aLookup1[] = { 0, 1, 1, 1, 1, 0, 0, 0 }; const Standard_Integer aLookup1[] = {0, 1, 1, 1, 1, 0, 0, 0};
const Standard_Integer aLookup2[] = { 0, 0, 0, 1, 1, 1, 1, 0 }; const Standard_Integer aLookup2[] = {0, 0, 0, 1, 1, 1, 1, 0};
Standard_Integer aShifts[] = { 0, 0, 0 }; Standard_Integer aShifts[] = {0, 0, 0};
// Planes go in order: // Planes go in order:
// LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR // LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR
@@ -207,33 +194,32 @@ void AIS_CameraFrustum::fillBorders()
{ {
for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter) for (Standard_Integer aSegmVertIter = 0; aSegmVertIter < aPlaneSegmVertsNb; ++aSegmVertIter)
{ {
aShifts[aFaceIdx] = i; aShifts[aFaceIdx] = i;
aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter]; aShifts[(aFaceIdx + 1) % 3] = aLookup1[aSegmVertIter];
aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter]; aShifts[(aFaceIdx + 2) % 3] = aLookup2[aSegmVertIter];
Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2]; Standard_Integer anIndex = aShifts[0] * 2 * 2 + aShifts[1] * 2 + aShifts[2];
myBorders->AddEdge (anIndex + 1); myBorders->AddEdge(anIndex + 1);
} }
} }
} }
} }
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter) for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB;
++aPointIter)
{ {
const Graphic3d_Vec3d aPnt = myPoints[aPointIter]; const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
myBorders->SetVertice (aPointIter + 1, gp_Pnt (aPnt.x(), aPnt.y(), aPnt.z())); myBorders->SetVertice(aPointIter + 1, gp_Pnt(aPnt.x(), aPnt.y(), aPnt.z()));
} }
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_CameraFrustum::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer theMode)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{ {
thePrs->SetInfiniteState (true); thePrs->SetInfiniteState(true);
if (myTriangles.IsNull()) if (myTriangles.IsNull())
{ {
return; return;
@@ -241,48 +227,48 @@ void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (theMode) switch (theMode)
{ {
case AIS_Shaded: case AIS_Shaded: {
{
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myTriangles); aGroup->AddPrimitiveArray(myTriangles);
} }
Standard_FALLTHROUGH Standard_FALLTHROUGH
case AIS_WireFrame: case AIS_WireFrame: {
{
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup(); Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); aGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders); aGroup->AddPrimitiveArray(myBorders);
break; break;
} }
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_CameraFrustum::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
//======================================================================= const Standard_Integer theMode)
void AIS_CameraFrustum::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{ {
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this); Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
switch (theMode) switch (theMode)
{ {
case SelectionMode_Edges: case SelectionMode_Edges: {
{ Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup(anOwner);
Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (anOwner);
for (Standard_Integer anIter = 1; anIter <= myBorders->EdgeNumber(); anIter += 2) for (Standard_Integer anIter = 1; anIter <= myBorders->EdgeNumber(); anIter += 2)
{ {
aSensitiveEntity->Add (new Select3D_SensitiveSegment (anOwner, myBorders->Vertice (myBorders->Edge (anIter)), myBorders->Vertice(myBorders->Edge (anIter + 1)))); aSensitiveEntity->Add(
new Select3D_SensitiveSegment(anOwner,
myBorders->Vertice(myBorders->Edge(anIter)),
myBorders->Vertice(myBorders->Edge(anIter + 1))));
} }
theSelection->Add (aSensitiveEntity); theSelection->Add(aSensitiveEntity);
break; break;
} }
case SelectionMode_Volume: case SelectionMode_Volume: {
{ Handle(Select3D_SensitivePrimitiveArray) aSelArray =
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (anOwner); new Select3D_SensitivePrimitiveArray(anOwner);
aSelArray->InitTriangulation (myTriangles->Attributes(), myTriangles->Indices(), TopLoc_Location()); aSelArray->InitTriangulation(myTriangles->Attributes(),
theSelection->Add (aSelArray); myTriangles->Indices(),
TopLoc_Location());
theSelection->Add(aSelArray);
break; break;
} }
} }

View File

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

View File

@@ -33,105 +33,99 @@
#include <Standard_Type.hxx> #include <Standard_Type.hxx>
#include <StdPrs_DeflectionCurve.hxx> #include <StdPrs_DeflectionCurve.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_Circle,AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
//======================================================================= //=================================================================================================
//function : AIS_Circle
//purpose : AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent)
//======================================================================= : AIS_InteractiveObject(PrsMgr_TOP_AllView),
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent): myComponent(aComponent),
AIS_InteractiveObject(PrsMgr_TOP_AllView), myUStart(0.0),
myComponent(aComponent), myUEnd(2.0 * M_PI),
myUStart (0.0), myCircleIsArc(Standard_False),
myUEnd (2.0 * M_PI), myIsFilledCircleSens(Standard_False)
myCircleIsArc (Standard_False),
myIsFilledCircleSens (Standard_False)
{ {
} }
//======================================================================= //=================================================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent, AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
const Standard_Real theUStart, const Standard_Real theUStart,
const Standard_Real theUEnd, const Standard_Real theUEnd,
const Standard_Boolean theIsFilledCircleSens) const Standard_Boolean theIsFilledCircleSens)
: AIS_InteractiveObject(PrsMgr_TOP_AllView), : AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent (theComponent), myComponent(theComponent),
myUStart (theUStart), myUStart(theUStart),
myUEnd (theUEnd), myUEnd(theUEnd),
myCircleIsArc (Abs (Abs (theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()), myCircleIsArc(Abs(Abs(theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()),
myIsFilledCircleSens (theIsFilledCircleSens) myIsFilledCircleSens(theIsFilledCircleSens)
{ {
} }
//======================================================================= //=================================================================================================
//function : Compute
//purpose : void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager)&,
//======================================================================= const Handle(Prs3d_Presentation)& thePrs,
void AIS_Circle::Compute (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer)
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer )
{ {
if (myCircleIsArc) { ComputeArc (thePrs); } if (myCircleIsArc)
else { ComputeCircle (thePrs); } {
ComputeArc(thePrs);
}
else
{
ComputeCircle(thePrs);
}
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/) const Standard_Integer /*aMode*/)
{ {
if (myCircleIsArc) ComputeArcSelection(aSelection); if (myCircleIsArc)
else ComputeCircleSelection(aSelection); ComputeArcSelection(aSelection);
else
ComputeCircleSelection(aSelection);
} }
//======================================================================= //=================================================================================================
//function : replaceWithNewLineAspect
//purpose : void AIS_Circle::replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
//=======================================================================
void AIS_Circle::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
{ {
if (!myDrawer->HasLink()) if (!myDrawer->HasLink())
{ {
myDrawer->SetLineAspect (theAspect); myDrawer->SetLineAspect(theAspect);
return; return;
} }
const Handle(Graphic3d_AspectLine3d) anAspectOld = myDrawer->LineAspect()->Aspect(); const Handle(Graphic3d_AspectLine3d) anAspectOld = myDrawer->LineAspect()->Aspect();
const Handle(Graphic3d_AspectLine3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect(); const Handle(Graphic3d_AspectLine3d) anAspectNew =
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
if (anAspectNew != anAspectOld) if (anAspectNew != anAspectOld)
{ {
myDrawer->SetLineAspect (theAspect); myDrawer->SetLineAspect(theAspect);
Graphic3d_MapOfAspectsToAspects aReplaceMap; Graphic3d_MapOfAspectsToAspects aReplaceMap;
aReplaceMap.Bind (anAspectOld, anAspectNew); aReplaceMap.Bind(anAspectOld, anAspectNew);
replaceAspects (aReplaceMap); replaceAspects(aReplaceMap);
} }
} }
//======================================================================= //=================================================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Circle::SetColor(const Quantity_Color &aCol) void AIS_Circle::SetColor(const Quantity_Color& aCol)
{ {
hasOwnColor=Standard_True; hasOwnColor = Standard_True;
myDrawer->SetColor (aCol); myDrawer->SetColor(aCol);
if (!myDrawer->HasOwnLineAspect()) if (!myDrawer->HasOwnLineAspect())
{ {
Standard_Real WW = HasWidth() ? myOwnWidth : Standard_Real WW = HasWidth() ? myOwnWidth
myDrawer->HasLink() ? : myDrawer->HasLink()
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
1.; : 1.;
replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW)); replaceWithNewLineAspect(new Prs3d_LineAspect(aCol, Aspect_TOL_SOLID, WW));
} }
else else
{ {
@@ -140,20 +134,20 @@ void AIS_Circle::SetColor(const Quantity_Color &aCol)
} }
} }
//======================================================================= //=================================================================================================
//function : SetWidth
//purpose :
//=======================================================================
void AIS_Circle::SetWidth(const Standard_Real aValue) void AIS_Circle::SetWidth(const Standard_Real aValue)
{ {
myOwnWidth = (Standard_ShortReal )aValue; myOwnWidth = (Standard_ShortReal)aValue;
if (!myDrawer->HasOwnLineAspect()) if (!myDrawer->HasOwnLineAspect())
{ {
Quantity_Color CC = Quantity_NOC_YELLOW; Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color(); if (HasColor())
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); CC = myDrawer->Color();
replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
} }
else else
{ {
@@ -162,101 +156,90 @@ void AIS_Circle::SetWidth(const Standard_Real aValue)
} }
} }
//=================================================================================================
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Circle::UnsetColor() void AIS_Circle::UnsetColor()
{ {
hasOwnColor = Standard_False; hasOwnColor = Standard_False;
if (!HasWidth()) if (!HasWidth())
{ {
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
} }
else else
{ {
Quantity_Color CC = Quantity_NOC_YELLOW; Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color(); if (HasColor())
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); CC = myDrawer->Color();
else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->LineAspect()->SetColor(CC); myDrawer->LineAspect()->SetColor(CC);
myDrawer->SetColor (CC); myDrawer->SetColor(CC);
SynchronizeAspects(); SynchronizeAspects();
} }
} }
//======================================================================= //=================================================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Circle::UnsetWidth() void AIS_Circle::UnsetWidth()
{ {
if (!HasColor()) if (!HasColor())
{ {
replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); replaceWithNewLineAspect(Handle(Prs3d_LineAspect)());
} }
else else
{ {
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.0f; Standard_ShortReal WW =
myDrawer->LineAspect()->SetWidth(WW); myDrawer->HasLink()
myOwnWidth = WW; ? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.0f;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeCircle
//purpose : void AIS_Circle::ComputeCircle(const Handle(Prs3d_Presentation)& thePresentation)
//=======================================================================
void AIS_Circle::ComputeCircle (const Handle(Prs3d_Presentation)& thePresentation)
{ {
GeomAdaptor_Curve curv(myComponent); GeomAdaptor_Curve curv(myComponent);
Standard_Real prevdev = myDrawer->DeviationCoefficient(); Standard_Real prevdev = myDrawer->DeviationCoefficient();
myDrawer->SetDeviationCoefficient (1.e-5); myDrawer->SetDeviationCoefficient(1.e-5);
StdPrs_DeflectionCurve::Add (thePresentation, curv, myDrawer); StdPrs_DeflectionCurve::Add(thePresentation, curv, myDrawer);
myDrawer->SetDeviationCoefficient (prevdev); myDrawer->SetDeviationCoefficient(prevdev);
} }
//======================================================================= //=================================================================================================
//function : ComputeArc
//purpose : void AIS_Circle::ComputeArc(const Handle(Prs3d_Presentation)& thePresentation)
//=======================================================================
void AIS_Circle::ComputeArc (const Handle(Prs3d_Presentation)& thePresentation)
{ {
GeomAdaptor_Curve curv(myComponent, myUStart, myUEnd); GeomAdaptor_Curve curv(myComponent, myUStart, myUEnd);
Standard_Real prevdev = myDrawer->DeviationCoefficient(); Standard_Real prevdev = myDrawer->DeviationCoefficient();
myDrawer->SetDeviationCoefficient (1.e-5); myDrawer->SetDeviationCoefficient(1.e-5);
StdPrs_DeflectionCurve::Add (thePresentation, curv, myDrawer); StdPrs_DeflectionCurve::Add(thePresentation, curv, myDrawer);
myDrawer->SetDeviationCoefficient (prevdev); myDrawer->SetDeviationCoefficient(prevdev);
} }
//======================================================================= //=================================================================================================
//function : ComputeCircleSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeCircleSelection (const Handle(SelectMgr_Selection)& theSelection) void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& theSelection)
{ {
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this); Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) aCirc = new Select3D_SensitiveCircle (anOwner, Handle(Select3D_SensitiveCircle) aCirc =
myComponent->Circ(), new Select3D_SensitiveCircle(anOwner, myComponent->Circ(), myIsFilledCircleSens);
myIsFilledCircleSens); theSelection->Add(aCirc);
theSelection->Add (aCirc);
} }
//=======================================================================
//function : ComputeArcSelection
//purpose :
//=======================================================================
void AIS_Circle::ComputeArcSelection (const Handle(SelectMgr_Selection)& theSelection) //=================================================================================================
void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& theSelection)
{ {
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this); Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitivePoly) aSeg = new Select3D_SensitivePoly (anOwner, Handle(Select3D_SensitivePoly) aSeg = new Select3D_SensitivePoly(anOwner,
myComponent->Circ(), myComponent->Circ(),
myUStart, myUEnd, myUStart,
myIsFilledCircleSens); myUEnd,
theSelection->Add (aSeg); myIsFilledCircleSens);
theSelection->Add(aSeg);
} }

View File

@@ -27,97 +27,102 @@ class AIS_Circle : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
public: public:
//! Initializes this algorithm for constructing AIS circle //! Initializes this algorithm for constructing AIS circle
//! datums initializes the circle aCircle //! datums initializes the circle aCircle
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle); Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle);
//! Initializes this algorithm for constructing AIS circle datums. //! Initializes this algorithm for constructing AIS circle datums.
//! Initializes the circle theCircle, the arc //! Initializes the circle theCircle, the arc
//! starting point theUStart, the arc ending point theUEnd, //! starting point theUStart, the arc ending point theUEnd,
//! and the type of sensitivity theIsFilledCircleSens. //! and the type of sensitivity theIsFilledCircleSens.
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle, const Standard_Real theUStart, const Standard_Real theUEnd, const Standard_Boolean theIsFilledCircleSens = Standard_False); Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle,
const Standard_Real theUStart,
const Standard_Real theUEnd,
const Standard_Boolean theIsFilledCircleSens = Standard_False);
//! Returns index 6 by default. //! Returns index 6 by default.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; }
//! Indicates that the type of Interactive Object is a datum. //! Indicates that the type of Interactive Object is a datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; } virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Returns the circle component defined in SetCircle. //! Returns the circle component defined in SetCircle.
const Handle(Geom_Circle)& Circle() const { return myComponent; } const Handle(Geom_Circle)& Circle() const { return myComponent; }
//! Constructs instances of the starting point and the end //! Constructs instances of the starting point and the end
//! point parameters, theU1 and theU2. //! point parameters, theU1 and theU2.
void Parameters (Standard_Real& theU1, Standard_Real& theU2) const void Parameters(Standard_Real& theU1, Standard_Real& theU2) const
{ {
theU1 = myUStart; theU1 = myUStart;
theU2 = myUEnd; theU2 = myUEnd;
} }
//! Allows you to provide settings for the circle datum aCircle. //! Allows you to provide settings for the circle datum aCircle.
void SetCircle (const Handle(Geom_Circle)& theCircle) { myComponent = theCircle; } void SetCircle(const Handle(Geom_Circle)& theCircle) { myComponent = theCircle; }
//! Allows you to set the parameter theU for the starting point of an arc. //! Allows you to set the parameter theU for the starting point of an arc.
void SetFirstParam (const Standard_Real theU) void SetFirstParam(const Standard_Real theU)
{ {
myUStart = theU; myUStart = theU;
myCircleIsArc = Standard_True; myCircleIsArc = Standard_True;
} }
//! Allows you to provide the parameter theU for the end point of an arc. //! Allows you to provide the parameter theU for the end point of an arc.
void SetLastParam (const Standard_Real theU) void SetLastParam(const Standard_Real theU)
{ {
myUEnd = theU; myUEnd = theU;
myCircleIsArc = Standard_True; myCircleIsArc = Standard_True;
} }
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
//! Assigns the width aValue to the solid line boundary of the circle datum. //! Assigns the width aValue to the solid line boundary of the circle datum.
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Removes color from the solid line boundary of the circle datum. //! Removes color from the solid line boundary of the circle datum.
Standard_EXPORT void UnsetColor() Standard_OVERRIDE; Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
//! Removes width settings from the solid line boundary of the circle datum. //! Removes width settings from the solid line boundary of the circle datum.
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
//! Returns the type of sensitivity for the circle; //! Returns the type of sensitivity for the circle;
Standard_Boolean IsFilledCircleSens() const { return myIsFilledCircleSens; } Standard_Boolean IsFilledCircleSens() const { return myIsFilledCircleSens; }
//! Sets the type of sensitivity for the circle. If theIsFilledCircleSens set to Standard_True //! Sets the type of sensitivity for the circle. If theIsFilledCircleSens set to Standard_True
//! then the whole circle will be detectable, otherwise only the boundary of the circle. //! then the whole circle will be detectable, otherwise only the boundary of the circle.
void SetFilledCircleSens (const Standard_Boolean theIsFilledCircleSens) { myIsFilledCircleSens = theIsFilledCircleSens; } void SetFilledCircleSens(const Standard_Boolean theIsFilledCircleSens)
{
myIsFilledCircleSens = theIsFilledCircleSens;
}
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& theprs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& theprs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, Standard_EXPORT void ComputeCircle(const Handle(Prs3d_Presentation)& aPresentation);
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeCircle (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeArc(const Handle(Prs3d_Presentation)& aPresentation);
Standard_EXPORT void ComputeArc (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeCircleSelection (const Handle(SelectMgr_Selection)& aSelection); Standard_EXPORT void ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeArcSelection (const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value. //! Replace aspects of already computed groups with the new value.
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect); void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private: private:
Handle(Geom_Circle) myComponent; Handle(Geom_Circle) myComponent;
Standard_Real myUStart; Standard_Real myUStart;
Standard_Real myUEnd; Standard_Real myUEnd;
Standard_Boolean myCircleIsArc; Standard_Boolean myCircleIsArc;
Standard_Boolean myIsFilledCircleSens; Standard_Boolean myIsFilledCircleSens;
}; };
DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject)

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,7 @@
class AIS_ColorScale; class AIS_ColorScale;
DEFINE_STANDARD_HANDLE(AIS_ColorScale, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_ColorScale, AIS_InteractiveObject)
//! Class for drawing a custom color scale. //! Class for drawing a custom color scale.
//! //!
//! The color scale consists of rectangular color bar (composed of fixed //! The color scale consists of rectangular color bar (composed of fixed
@@ -39,71 +40,81 @@ class AIS_ColorScale : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject)
public: public:
//! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
const Standard_Integer theColorsCount,
const Graphic3d_Vec3d& theColorHlsMin,
const Graphic3d_Vec3d& theColorHlsMax,
Quantity_Color& theColor);
//! Calculate color according passed value; returns true if value is in range or false, if isn't //! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT static Standard_Boolean FindColor (const Standard_Real theValue, static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin, const Standard_Real theMin,
const Standard_Real theMax, const Standard_Real theMax,
const Standard_Integer theColorsCount, const Standard_Integer theColorsCount,
const Graphic3d_Vec3d& theColorHlsMin, Quantity_Color& theColor)
const Graphic3d_Vec3d& theColorHlsMax,
Quantity_Color& theColor);
//! Calculate color according passed value; returns true if value is in range or false, if isn't
static Standard_Boolean FindColor (const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
const Standard_Integer theColorsCount,
Quantity_Color& theColor)
{ {
return FindColor (theValue, theMin, theMax, theColorsCount, return FindColor(theValue,
Graphic3d_Vec3d (230.0, 1.0, 1.0), theMin,
Graphic3d_Vec3d (0.0, 1.0, 1.0), theMax,
theColor); theColorsCount,
Graphic3d_Vec3d(230.0, 1.0, 1.0),
Graphic3d_Vec3d(0.0, 1.0, 1.0),
theColor);
} }
//! Shift hue into valid range. //! Shift hue into valid range.
//! Lightness and Saturation should be specified in valid range [0.0, 1.0], //! Lightness and Saturation should be specified in valid range [0.0, 1.0],
//! however Hue might be given out of Quantity_Color range to specify desired range for interpolation. //! however Hue might be given out of Quantity_Color range to specify desired range for
static Standard_Real hueToValidRange (const Standard_Real theHue) //! interpolation.
static Standard_Real hueToValidRange(const Standard_Real theHue)
{ {
Standard_Real aHue = theHue; Standard_Real aHue = theHue;
while (aHue < 0.0) { aHue += 360.0; } while (aHue < 0.0)
while (aHue > 360.0) { aHue -= 360.0; } {
aHue += 360.0;
}
while (aHue > 360.0)
{
aHue -= 360.0;
}
return aHue; return aHue;
} }
public: public:
//! Default constructor. //! Default constructor.
Standard_EXPORT AIS_ColorScale(); Standard_EXPORT AIS_ColorScale();
//! Calculate color according passed value; returns true if value is in range or false, if isn't //! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const; Standard_EXPORT Standard_Boolean FindColor(const Standard_Real theValue,
Quantity_Color& theColor) const;
//! Returns minimal value of color scale, 0.0 by default. //! Returns minimal value of color scale, 0.0 by default.
Standard_Real GetMin() const { return myMin; } Standard_Real GetMin() const { return myMin; }
//! Sets the minimal value of color scale. //! Sets the minimal value of color scale.
void SetMin (const Standard_Real theMin) { SetRange (theMin, GetMax()); } void SetMin(const Standard_Real theMin) { SetRange(theMin, GetMax()); }
//! Returns maximal value of color scale, 1.0 by default. //! Returns maximal value of color scale, 1.0 by default.
Standard_Real GetMax() const { return myMax; } Standard_Real GetMax() const { return myMax; }
//! Sets the maximal value of color scale. //! Sets the maximal value of color scale.
void SetMax (const Standard_Real theMax) { SetRange (GetMin(), theMax); } void SetMax(const Standard_Real theMax) { SetRange(GetMin(), theMax); }
//! Returns minimal and maximal values of color scale, 0.0 to 1.0 by default. //! Returns minimal and maximal values of color scale, 0.0 to 1.0 by default.
void GetRange (Standard_Real& theMin, Standard_Real& theMax) const void GetRange(Standard_Real& theMin, Standard_Real& theMax) const
{ {
theMin = myMin; theMin = myMin;
theMax = myMax; theMax = myMax;
} }
//! Sets the minimal and maximal value of color scale. //! Sets the minimal and maximal value of color scale.
//! Note that values order will be ignored - the minimum and maximum values will be swapped if needed. //! Note that values order will be ignored - the minimum and maximum values will be swapped if
//! needed.
//! ::SetReversed() should be called to swap displaying order. //! ::SetReversed() should be called to swap displaying order.
Standard_EXPORT void SetRange (const Standard_Real theMin, const Standard_Real theMax); Standard_EXPORT void SetRange(const Standard_Real theMin, const Standard_Real theMax);
//! Returns the hue angle corresponding to minimum value, 230 by default (blue). //! Returns the hue angle corresponding to minimum value, 230 by default (blue).
Standard_Real HueMin() const { return myColorHlsMin[0]; } Standard_Real HueMin() const { return myColorHlsMin[0]; }
@@ -111,9 +122,9 @@ public:
//! Returns the hue angle corresponding to maximum value, 0 by default (red). //! Returns the hue angle corresponding to maximum value, 0 by default (red).
Standard_Real HueMax() const { return myColorHlsMax[0]; } Standard_Real HueMax() const { return myColorHlsMax[0]; }
//! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default (blue to red). //! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default
void HueRange (Standard_Real& theMinAngle, //! (blue to red).
Standard_Real& theMaxAngle) const void HueRange(Standard_Real& theMinAngle, Standard_Real& theMaxAngle) const
{ {
theMinAngle = myColorHlsMin[0]; theMinAngle = myColorHlsMin[0];
theMaxAngle = myColorHlsMax[0]; theMaxAngle = myColorHlsMax[0];
@@ -121,27 +132,30 @@ public:
//! Sets hue angle range corresponding to minimum and maximum values. //! Sets hue angle range corresponding to minimum and maximum values.
//! The valid angle range is [0, 360], see Quantity_Color and Quantity_TOC_HLS for more details. //! The valid angle range is [0, 360], see Quantity_Color and Quantity_TOC_HLS for more details.
void SetHueRange (const Standard_Real theMinAngle, void SetHueRange(const Standard_Real theMinAngle, const Standard_Real theMaxAngle)
const Standard_Real theMaxAngle)
{ {
myColorHlsMin[0] = theMinAngle; myColorHlsMin[0] = theMinAngle;
myColorHlsMax[0] = theMaxAngle; myColorHlsMax[0] = theMaxAngle;
} }
//! Returns color range corresponding to minimum and maximum values, blue to red by default. //! Returns color range corresponding to minimum and maximum values, blue to red by default.
void ColorRange (Quantity_Color& theMinColor, void ColorRange(Quantity_Color& theMinColor, Quantity_Color& theMaxColor) const
Quantity_Color& theMaxColor) const
{ {
theMinColor.SetValues (hueToValidRange (myColorHlsMin[0]), myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS); theMinColor.SetValues(hueToValidRange(myColorHlsMin[0]),
theMaxColor.SetValues (hueToValidRange (myColorHlsMax[0]), myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS); myColorHlsMin[1],
myColorHlsMin[2],
Quantity_TOC_HLS);
theMaxColor.SetValues(hueToValidRange(myColorHlsMax[0]),
myColorHlsMax[1],
myColorHlsMax[2],
Quantity_TOC_HLS);
} }
//! Sets color range corresponding to minimum and maximum values. //! Sets color range corresponding to minimum and maximum values.
void SetColorRange (const Quantity_Color& theMinColor, void SetColorRange(const Quantity_Color& theMinColor, const Quantity_Color& theMaxColor)
const Quantity_Color& theMaxColor)
{ {
theMinColor.Values (myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS); theMinColor.Values(myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
theMaxColor.Values (myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS); theMaxColor.Values(myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
} }
//! Returns the type of labels, Aspect_TOCSD_AUTO by default. //! Returns the type of labels, Aspect_TOCSD_AUTO by default.
@@ -152,7 +166,7 @@ public:
//! Sets the type of labels. //! Sets the type of labels.
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals //! Aspect_TOCSD_AUTO - labels as boundary values for intervals
//! Aspect_TOCSD_USER - user specified label is used //! Aspect_TOCSD_USER - user specified label is used
void SetLabelType (const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; } void SetLabelType(const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; }
//! Returns the type of colors, Aspect_TOCSD_AUTO by default. //! Returns the type of colors, Aspect_TOCSD_AUTO by default.
//! Aspect_TOCSD_AUTO - value between Red and Blue //! Aspect_TOCSD_AUTO - value between Red and Blue
@@ -162,19 +176,19 @@ public:
//! Sets the type of colors. //! Sets the type of colors.
//! Aspect_TOCSD_AUTO - value between Red and Blue //! Aspect_TOCSD_AUTO - value between Red and Blue
//! Aspect_TOCSD_USER - user specified color from color map //! Aspect_TOCSD_USER - user specified color from color map
void SetColorType (const Aspect_TypeOfColorScaleData theType) { myColorType = theType; } void SetColorType(const Aspect_TypeOfColorScaleData theType) { myColorType = theType; }
//! Returns the number of color scale intervals, 10 by default. //! Returns the number of color scale intervals, 10 by default.
Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; } Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; }
//! Sets the number of color scale intervals. //! Sets the number of color scale intervals.
Standard_EXPORT void SetNumberOfIntervals (const Standard_Integer theNum); Standard_EXPORT void SetNumberOfIntervals(const Standard_Integer theNum);
//! Returns the color scale title string, empty string by default. //! Returns the color scale title string, empty string by default.
const TCollection_ExtendedString& GetTitle() const { return myTitle; } const TCollection_ExtendedString& GetTitle() const { return myTitle; }
//! Sets the color scale title string. //! Sets the color scale title string.
void SetTitle (const TCollection_ExtendedString& theTitle) { myTitle = theTitle; } void SetTitle(const TCollection_ExtendedString& theTitle) { myTitle = theTitle; }
//! Returns the format for numbers, "%.4g" by default. //! Returns the format for numbers, "%.4g" by default.
//! The same like format for function printf(). //! The same like format for function printf().
@@ -185,58 +199,60 @@ public:
const TCollection_AsciiString& Format() const { return myFormat; } const TCollection_AsciiString& Format() const { return myFormat; }
//! Sets the color scale auto label format specification. //! Sets the color scale auto label format specification.
void SetFormat (const TCollection_AsciiString& theFormat) { myFormat = theFormat; } void SetFormat(const TCollection_AsciiString& theFormat) { myFormat = theFormat; }
//! Returns the user specified label with index theIndex. //! Returns the user specified label with index theIndex.
//! Index is in range from 1 to GetNumberOfIntervals() or to //! Index is in range from 1 to GetNumberOfIntervals() or to
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. //! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true.
//! Returns empty string if label not defined. //! Returns empty string if label not defined.
Standard_EXPORT TCollection_ExtendedString GetLabel (const Standard_Integer theIndex) const; Standard_EXPORT TCollection_ExtendedString GetLabel(const Standard_Integer theIndex) const;
//! Returns the user specified color from color map with index (starts at 1). //! Returns the user specified color from color map with index (starts at 1).
//! Returns default color if index is out of range in color map. //! Returns default color if index is out of range in color map.
Standard_EXPORT Quantity_Color GetIntervalColor (const Standard_Integer theIndex) const; Standard_EXPORT Quantity_Color GetIntervalColor(const Standard_Integer theIndex) const;
//! Sets the color of the specified interval. //! Sets the color of the specified interval.
//! Note that list is automatically resized to include specified index. //! Note that list is automatically resized to include specified index.
//! @param theColor color value to set //! @param theColor color value to set
//! @param theIndex index in range [1, GetNumberOfIntervals()]; //! @param theIndex index in range [1, GetNumberOfIntervals()];
//! appended to the end of list if -1 is specified //! appended to the end of list if -1 is specified
Standard_EXPORT void SetIntervalColor (const Quantity_Color& theColor, const Standard_Integer theIndex); Standard_EXPORT void SetIntervalColor(const Quantity_Color& theColor,
const Standard_Integer theIndex);
//! Returns the user specified labels. //! Returns the user specified labels.
Standard_EXPORT void GetLabels (TColStd_SequenceOfExtendedString& theLabels) const; Standard_EXPORT void GetLabels(TColStd_SequenceOfExtendedString& theLabels) const;
//! Returns the user specified labels. //! Returns the user specified labels.
const TColStd_SequenceOfExtendedString& Labels() const { return myLabels; } const TColStd_SequenceOfExtendedString& Labels() const { return myLabels; }
//! Sets the color scale labels. //! Sets the color scale labels.
//! The length of the sequence should be equal to GetNumberOfIntervals() or to GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. //! The length of the sequence should be equal to GetNumberOfIntervals() or to
//! If length of the sequence does not much the number of intervals, //! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. If length of the sequence does not
//! then these labels will be considered as "free" and will be located //! much the number of intervals, then these labels will be considered as "free" and will be
//! at the virtual intervals corresponding to the number of labels //! located at the virtual intervals corresponding to the number of labels (with flag
//! (with flag IsLabelAtBorder() having the same effect as in normal case). //! IsLabelAtBorder() having the same effect as in normal case).
Standard_EXPORT void SetLabels (const TColStd_SequenceOfExtendedString& theSeq); Standard_EXPORT void SetLabels(const TColStd_SequenceOfExtendedString& theSeq);
//! Returns the user specified colors. //! Returns the user specified colors.
Standard_EXPORT void GetColors (Aspect_SequenceOfColor& theColors) const; Standard_EXPORT void GetColors(Aspect_SequenceOfColor& theColors) const;
//! Returns the user specified colors. //! Returns the user specified colors.
const Aspect_SequenceOfColor& GetColors() const { return myColors; } const Aspect_SequenceOfColor& GetColors() const { return myColors; }
//! Sets the color scale colors. //! Sets the color scale colors.
//! The length of the sequence should be equal to GetNumberOfIntervals(). //! The length of the sequence should be equal to GetNumberOfIntervals().
Standard_EXPORT void SetColors (const Aspect_SequenceOfColor& theSeq); Standard_EXPORT void SetColors(const Aspect_SequenceOfColor& theSeq);
//! Populates colors scale by colors of the same lightness value in CIE Lch //! Populates colors scale by colors of the same lightness value in CIE Lch
//! color space, distributed by hue, with perceptually uniform differences //! color space, distributed by hue, with perceptually uniform differences
//! between consequent colors. //! between consequent colors.
//! See MakeUniformColors() for description of parameters. //! See MakeUniformColors() for description of parameters.
void SetUniformColors (Standard_Real theLightness, void SetUniformColors(Standard_Real theLightness,
Standard_Real theHueFrom, Standard_Real theHueTo) Standard_Real theHueFrom,
Standard_Real theHueTo)
{ {
SetColors (MakeUniformColors (myNbIntervals, theLightness, theHueFrom, theHueTo)); SetColors(MakeUniformColors(myNbIntervals, theLightness, theHueFrom, theHueTo));
SetColorType (Aspect_TOCSD_USER); SetColorType(Aspect_TOCSD_USER);
} }
//! Generates sequence of colors of the same lightness value in CIE Lch //! Generates sequence of colors of the same lightness value in CIE Lch
@@ -250,26 +266,29 @@ public:
//! lightness of pure blue) //! lightness of pure blue)
//! @param theHueFrom - hue value at the start of the scale //! @param theHueFrom - hue value at the start of the scale
//! @param theHueTo - hue value defining the end of the scale //! @param theHueTo - hue value defining the end of the scale
//! //!
//! Hue value can be out of the range [0, 360], interpreted as modulo 360. //! Hue value can be out of the range [0, 360], interpreted as modulo 360.
//! The colors of the scale will be in the order of increasing hue if //! The colors of the scale will be in the order of increasing hue if
//! theHueTo > theHueFrom, and decreasing otherwise. //! theHueTo > theHueFrom, and decreasing otherwise.
Standard_EXPORT static Aspect_SequenceOfColor Standard_EXPORT static Aspect_SequenceOfColor MakeUniformColors(Standard_Integer theNbColors,
MakeUniformColors (Standard_Integer theNbColors, Standard_Real theLightness, Standard_Real theLightness,
Standard_Real theHueFrom, Standard_Real theHueTo); Standard_Real theHueFrom,
Standard_Real theHueTo);
//! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by default. //! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by
//! default.
Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; } Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; }
//! Sets the color scale labels position relative to color bar. //! Sets the color scale labels position relative to color bar.
void SetLabelPosition (const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; } void SetLabelPosition(const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; }
//! Returns the position of color scale title, Aspect_TOCSP_LEFT by default. //! Returns the position of color scale title, Aspect_TOCSP_LEFT by default.
Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; } Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; }
//! Sets the color scale title position. //! Sets the color scale title position.
Standard_DEPRECATED("AIS_ColorScale::SetTitlePosition() has no effect!") Standard_DEPRECATED("AIS_ColorScale::SetTitlePosition() has no effect!")
void SetTitlePosition (const Aspect_TypeOfColorScalePosition thePos) { myTitlePos = thePos; }
void SetTitlePosition(const Aspect_TypeOfColorScalePosition thePos) { myTitlePos = thePos; }
//! Returns TRUE if the labels and colors used in reversed order, FALSE by default. //! Returns TRUE if the labels and colors used in reversed order, FALSE by default.
//! - Normal, bottom-up order with Minimal value on the Bottom and Maximum value on Top. //! - Normal, bottom-up order with Minimal value on the Bottom and Maximum value on Top.
@@ -277,14 +296,14 @@ public:
Standard_Boolean IsReversed() const { return myIsReversed; } Standard_Boolean IsReversed() const { return myIsReversed; }
//! Sets true if the labels and colors used in reversed order. //! Sets true if the labels and colors used in reversed order.
void SetReversed (const Standard_Boolean theReverse) { myIsReversed = theReverse; } void SetReversed(const Standard_Boolean theReverse) { myIsReversed = theReverse; }
//! Return TRUE if color transition between neighbor intervals //! Return TRUE if color transition between neighbor intervals
//! should be linearly interpolated, FALSE by default. //! should be linearly interpolated, FALSE by default.
Standard_Boolean IsSmoothTransition() const { return myIsSmooth; } Standard_Boolean IsSmoothTransition() const { return myIsSmooth; }
//! Setup smooth color transition. //! Setup smooth color transition.
void SetSmoothTransition (const Standard_Boolean theIsSmooth) { myIsSmooth = theIsSmooth; } void SetSmoothTransition(const Standard_Boolean theIsSmooth) { myIsSmooth = theIsSmooth; }
//! Returns TRUE if the labels are placed at border of color intervals, TRUE by default. //! Returns TRUE if the labels are placed at border of color intervals, TRUE by default.
//! The automatically generated label will show value exactly on the current position: //! The automatically generated label will show value exactly on the current position:
@@ -294,31 +313,33 @@ public:
//! Sets true if the labels are placed at border of color intervals (TRUE by default). //! Sets true if the labels are placed at border of color intervals (TRUE by default).
//! If set to False, labels will be drawn at color intervals rather than at borders. //! If set to False, labels will be drawn at color intervals rather than at borders.
void SetLabelAtBorder (const Standard_Boolean theOn) { myIsLabelAtBorder = theOn; } void SetLabelAtBorder(const Standard_Boolean theOn) { myIsLabelAtBorder = theOn; }
//! Returns TRUE if the color scale has logarithmic intervals, FALSE by default. //! Returns TRUE if the color scale has logarithmic intervals, FALSE by default.
Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; } Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; }
//! Sets true if the color scale has logarithmic intervals. //! Sets true if the color scale has logarithmic intervals.
void SetLogarithmic (const Standard_Boolean isLogarithmic) { myIsLogarithmic = isLogarithmic; } void SetLogarithmic(const Standard_Boolean isLogarithmic) { myIsLogarithmic = isLogarithmic; }
//! Sets the color scale label at index. //! Sets the color scale label at index.
//! Note that list is automatically resized to include specified index. //! Note that list is automatically resized to include specified index.
//! @param theLabel new label text //! @param theLabel new label text
//! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1] if IsLabelAtBorder() is true; //! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1]
//! if IsLabelAtBorder() is true;
//! label is appended to the end of list if negative index is specified //! label is appended to the end of list if negative index is specified
Standard_EXPORT void SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex); Standard_EXPORT void SetLabel(const TCollection_ExtendedString& theLabel,
const Standard_Integer theIndex);
//! Returns the size of color bar, 0 and 0 by default //! Returns the size of color bar, 0 and 0 by default
//! (e.g. should be set by user explicitly before displaying). //! (e.g. should be set by user explicitly before displaying).
void GetSize (Standard_Integer& theBreadth, Standard_Integer& theHeight) const void GetSize(Standard_Integer& theBreadth, Standard_Integer& theHeight) const
{ {
theBreadth = myBreadth; theBreadth = myBreadth;
theHeight = myHeight; theHeight = myHeight;
} }
//! Sets the size of color bar. //! Sets the size of color bar.
void SetSize (const Standard_Integer theBreadth, const Standard_Integer theHeight) void SetSize(const Standard_Integer theBreadth, const Standard_Integer theHeight)
{ {
myBreadth = theBreadth; myBreadth = theBreadth;
myHeight = theHeight; myHeight = theHeight;
@@ -329,24 +350,24 @@ public:
Standard_Integer GetBreadth() const { return myBreadth; } Standard_Integer GetBreadth() const { return myBreadth; }
//! Sets the width of color bar. //! Sets the width of color bar.
void SetBreadth (const Standard_Integer theBreadth) { myBreadth = theBreadth; } void SetBreadth(const Standard_Integer theBreadth) { myBreadth = theBreadth; }
//! Returns the height of color bar, 0 by default //! Returns the height of color bar, 0 by default
//! (e.g. should be set by user explicitly before displaying). //! (e.g. should be set by user explicitly before displaying).
Standard_Integer GetHeight() const { return myHeight; } Standard_Integer GetHeight() const { return myHeight; }
//! Sets the height of color bar. //! Sets the height of color bar.
void SetHeight (const Standard_Integer theHeight) { myHeight = theHeight; } void SetHeight(const Standard_Integer theHeight) { myHeight = theHeight; }
//! Returns the bottom-left position of color scale, 0x0 by default. //! Returns the bottom-left position of color scale, 0x0 by default.
void GetPosition (Standard_Real& theX, Standard_Real& theY) const void GetPosition(Standard_Real& theX, Standard_Real& theY) const
{ {
theX = myXPos; theX = myXPos;
theY = myYPos; theY = myYPos;
} }
//! Sets the position of color scale. //! Sets the position of color scale.
void SetPosition (const Standard_Integer theX, const Standard_Integer theY) void SetPosition(const Standard_Integer theX, const Standard_Integer theY)
{ {
myXPos = theX; myXPos = theX;
myYPos = theY; myYPos = theY;
@@ -356,67 +377,69 @@ public:
Standard_Integer GetXPosition() const { return myXPos; } Standard_Integer GetXPosition() const { return myXPos; }
//! Sets the left position of color scale. //! Sets the left position of color scale.
void SetXPosition (const Standard_Integer theX) { myXPos = theX; } void SetXPosition(const Standard_Integer theX) { myXPos = theX; }
//! Returns the bottom position of color scale, 0 by default. //! Returns the bottom position of color scale, 0 by default.
Standard_Integer GetYPosition() const { return myYPos; } Standard_Integer GetYPosition() const { return myYPos; }
//! Sets the bottom position of color scale. //! Sets the bottom position of color scale.
void SetYPosition (const Standard_Integer theY) { myYPos = theY; } void SetYPosition(const Standard_Integer theY) { myYPos = theY; }
//! Returns the font height of text labels, 20 by default. //! Returns the font height of text labels, 20 by default.
Standard_Integer GetTextHeight() const { return myTextHeight; } Standard_Integer GetTextHeight() const { return myTextHeight; }
//! Sets the height of text of color scale. //! Sets the height of text of color scale.
void SetTextHeight (const Standard_Integer theHeight) { myTextHeight = theHeight; } void SetTextHeight(const Standard_Integer theHeight) { myTextHeight = theHeight; }
public: public:
//! Returns the width of text. //! Returns the width of text.
//! @param[in] theText the text of which to calculate width. //! @param[in] theText the text of which to calculate width.
Standard_EXPORT Standard_Integer TextWidth (const TCollection_ExtendedString& theText) const; Standard_EXPORT Standard_Integer TextWidth(const TCollection_ExtendedString& theText) const;
//! Returns the height of text. //! Returns the height of text.
//! @param[in] theText the text of which to calculate height. //! @param[in] theText the text of which to calculate height.
Standard_EXPORT Standard_Integer TextHeight (const TCollection_ExtendedString& theText) const; Standard_EXPORT Standard_Integer TextHeight(const TCollection_ExtendedString& theText) const;
Standard_EXPORT void TextSize (const TCollection_ExtendedString& theText, Standard_EXPORT void TextSize(const TCollection_ExtendedString& theText,
const Standard_Integer theHeight, const Standard_Integer theHeight,
Standard_Integer& theWidth, Standard_Integer& theWidth,
Standard_Integer& theAscent, Standard_Integer& theAscent,
Standard_Integer& theDescent) const; Standard_Integer& theDescent) const;
public: public:
//! Return true if specified display mode is supported. //! Return true if specified display mode is supported.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; } virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0;
}
//! Compute presentation. //! Compute presentation.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection - not implemented for color scale. //! Compute selection - not implemented for color scale.
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/, virtual void ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/) Standard_OVERRIDE {} const Standard_Integer /*aMode*/) Standard_OVERRIDE
{
}
private: private:
//! Returns the size of color scale. //! Returns the size of color scale.
//! @param[out] theWidth the width of color scale. //! @param[out] theWidth the width of color scale.
//! @param[out] theHeight the height of color scale. //! @param[out] theHeight the height of color scale.
void SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const; void SizeHint(Standard_Integer& theWidth, Standard_Integer& theHeight) const;
//! Returns the upper value of given interval, or minimum for theIndex = 0. //! Returns the upper value of given interval, or minimum for theIndex = 0.
Standard_Real GetIntervalValue (const Standard_Integer theIndex) const; Standard_Real GetIntervalValue(const Standard_Integer theIndex) const;
//! Returns the color for the given value in the given interval. //! Returns the color for the given value in the given interval.
//! @param[in] theValue the current value of interval //! @param[in] theValue the current value of interval
//! @param[in] theMin the min value of interval //! @param[in] theMin the min value of interval
//! @param[in] theMax the max value of interval //! @param[in] theMax the max value of interval
Quantity_Color colorFromValue (const Standard_Real theValue, Quantity_Color colorFromValue(const Standard_Real theValue,
const Standard_Real theMin, const Standard_Real theMin,
const Standard_Real theMax) const; const Standard_Real theMax) const;
//! Initialize text aspect for drawing the labels. //! Initialize text aspect for drawing the labels.
void updateTextAspect(); void updateTextAspect();
@@ -427,28 +450,29 @@ private:
//! @param[in] theX X coordinate of text position //! @param[in] theX X coordinate of text position
//! @param[in] theY Y coordinate of text position //! @param[in] theY Y coordinate of text position
//! @param[in] theVertAlignment text vertical alignment //! @param[in] theVertAlignment text vertical alignment
void drawText (const Handle(Graphic3d_Group)& theGroup, void drawText(const Handle(Graphic3d_Group)& theGroup,
const TCollection_ExtendedString& theText, const TCollection_ExtendedString& theText,
const Standard_Integer theX, const Standard_Integer theY, const Standard_Integer theX,
const Graphic3d_VerticalTextAlignment theVertAlignment); const Standard_Integer theY,
const Graphic3d_VerticalTextAlignment theVertAlignment);
//! Determine the maximum text label width in pixels. //! Determine the maximum text label width in pixels.
Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const; Standard_Integer computeMaxLabelWidth(const TColStd_SequenceOfExtendedString& theLabels) const;
//! Draw labels. //! Draw labels.
void drawLabels (const Handle(Graphic3d_Group)& theGroup, void drawLabels(const Handle(Graphic3d_Group)& theGroup,
const TColStd_SequenceOfExtendedString& theLabels, const TColStd_SequenceOfExtendedString& theLabels,
const Standard_Integer theBarBottom, const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight, const Standard_Integer theBarHeight,
const Standard_Integer theMaxLabelWidth, const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth); const Standard_Integer theColorBreadth);
//! Draw a color bar. //! Draw a color bar.
void drawColorBar (const Handle(Prs3d_Presentation)& thePrs, void drawColorBar(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theBarBottom, const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight, const Standard_Integer theBarHeight,
const Standard_Integer theMaxLabelWidth, const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth); const Standard_Integer theColorBreadth);
//! Draw a frame. //! Draw a frame.
//! @param[in] theX the X coordinate of frame position. //! @param[in] theX the X coordinate of frame position.
@@ -456,16 +480,17 @@ private:
//! @param[in] theWidth the width of frame. //! @param[in] theWidth the width of frame.
//! @param[in] theHeight the height of frame. //! @param[in] theHeight the height of frame.
//! @param[in] theColor the color of frame. //! @param[in] theColor the color of frame.
void drawFrame (const Handle(Prs3d_Presentation)& thePrs, void drawFrame(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theX, const Standard_Integer theY, const Standard_Integer theX,
const Standard_Integer theWidth, const Standard_Integer theHeight, const Standard_Integer theY,
const Quantity_Color& theColor); const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Quantity_Color& theColor);
private: private:
Standard_Real myMin; //!< values range - minimal value
Standard_Real myMin; //!< values range - minimal value Standard_Real myMax; //!< values range - maximal value
Standard_Real myMax; //!< values range - maximal value // clang-format off
// clang-format off
Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value
Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value
TCollection_ExtendedString myTitle; //!< optional title string TCollection_ExtendedString myTitle; //!< optional title string
@@ -480,15 +505,14 @@ private:
Aspect_SequenceOfColor myColors; //!< sequence of custom colors Aspect_SequenceOfColor myColors; //!< sequence of custom colors
TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels
Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale
// clang-format on // clang-format on
Aspect_TypeOfColorScalePosition myTitlePos; //!< title position Aspect_TypeOfColorScalePosition myTitlePos; //!< title position
Standard_Integer myXPos; //!< left position Standard_Integer myXPos; //!< left position
Standard_Integer myYPos; //!< bottom position Standard_Integer myYPos; //!< bottom position
Standard_Integer myBreadth; //!< color scale breadth Standard_Integer myBreadth; //!< color scale breadth
Standard_Integer myHeight; //!< height of the color scale Standard_Integer myHeight; //!< height of the color scale
Standard_Integer mySpacing; //!< extra spacing between element Standard_Integer mySpacing; //!< extra spacing between element
Standard_Integer myTextHeight; //!< label font height Standard_Integer myTextHeight; //!< label font height
}; };
#endif #endif

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -28,39 +28,36 @@ class StdSelect_BRepOwner;
class AIS_ColoredShape : public AIS_Shape class AIS_ColoredShape : public AIS_Shape
{ {
public: public:
//! Default constructor //! Default constructor
Standard_EXPORT AIS_ColoredShape (const TopoDS_Shape& theShape); Standard_EXPORT AIS_ColoredShape(const TopoDS_Shape& theShape);
//! Copy constructor //! Copy constructor
Standard_EXPORT AIS_ColoredShape (const Handle(AIS_Shape)& theShape); Standard_EXPORT AIS_ColoredShape(const Handle(AIS_Shape)& theShape);
public: //! @name sub-shape aspects public: //! @name sub-shape aspects
//! Customize properties of specified sub-shape. //! Customize properties of specified sub-shape.
//! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape! //! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape!
//! This method can be used to mark sub-shapes with customizable properties. //! This method can be used to mark sub-shapes with customizable properties.
Standard_EXPORT virtual Handle(AIS_ColoredDrawer) CustomAspects (const TopoDS_Shape& theShape); Standard_EXPORT virtual Handle(AIS_ColoredDrawer) CustomAspects(const TopoDS_Shape& theShape);
//! Reset the map of custom sub-shape aspects. //! Reset the map of custom sub-shape aspects.
Standard_EXPORT virtual void ClearCustomAspects(); Standard_EXPORT virtual void ClearCustomAspects();
//! Reset custom properties of specified sub-shape. //! Reset custom properties of specified sub-shape.
//! @param theToUnregister unregister or not sub-shape from the map //! @param theToUnregister unregister or not sub-shape from the map
Standard_EXPORT void UnsetCustomAspects (const TopoDS_Shape& theShape, Standard_EXPORT void UnsetCustomAspects(const TopoDS_Shape& theShape,
const Standard_Boolean theToUnregister = Standard_False); const Standard_Boolean theToUnregister = Standard_False);
//! Customize color of specified sub-shape //! Customize color of specified sub-shape
Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape, Standard_EXPORT void SetCustomColor(const TopoDS_Shape& theShape, const Quantity_Color& theColor);
const Quantity_Color& theColor);
//! Customize transparency of specified sub-shape //! Customize transparency of specified sub-shape
Standard_EXPORT void SetCustomTransparency (const TopoDS_Shape& theShape, Standard_EXPORT void SetCustomTransparency(const TopoDS_Shape& theShape,
Standard_Real theTransparency); Standard_Real theTransparency);
//! Customize line width of specified sub-shape //! Customize line width of specified sub-shape
Standard_EXPORT void SetCustomWidth (const TopoDS_Shape& theShape, Standard_EXPORT void SetCustomWidth(const TopoDS_Shape& theShape,
const Standard_Real theLineWidth); const Standard_Real theLineWidth);
//! Return the map of custom aspects. //! Return the map of custom aspects.
const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; } const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; }
@@ -69,21 +66,20 @@ public: //! @name sub-shape aspects
AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; } AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; }
public: //! @name global aspects public: //! @name global aspects
//! Setup color of entire shape. //! Setup color of entire shape.
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
//! Setup line width of entire shape. //! Setup line width of entire shape.
Standard_EXPORT virtual void SetWidth (const Standard_Real theLineWidth) Standard_OVERRIDE; Standard_EXPORT virtual void SetWidth(const Standard_Real theLineWidth) Standard_OVERRIDE;
//! Sets transparency value. //! Sets transparency value.
Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE; Standard_EXPORT virtual void SetTransparency(const Standard_Real theValue) Standard_OVERRIDE;
//! Sets the material aspect. //! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE; Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theAspect)
Standard_OVERRIDE;
public: public:
//! Removes the setting for transparency in the reconstructed compound shape. //! Removes the setting for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
@@ -91,22 +87,20 @@ public:
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
protected: //! @name override presentation computation protected: //! @name override presentation computation
//! Compute presentation considering sub-shape color map. //! Compute presentation considering sub-shape color map.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection considering sub-shape hidden state. //! Compute selection considering sub-shape hidden state.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
protected: protected:
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound>
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound> DataMapOfDrawerCompd; DataMapOfDrawerCompd;
protected: protected:
//! Recursive function to map shapes. //! Recursive function to map shapes.
//! @param theParentDrawer the drawer to be used for undetailed shapes (default colors) //! @param theParentDrawer the drawer to be used for undetailed shapes (default colors)
//! @param theShapeToParse the subshape to be recursively parsed //! @param theShapeToParse the subshape to be recursively parsed
@@ -115,41 +109,45 @@ protected:
//! @param theIsParentClosed flag indicating that specified shape is part of closed Solid //! @param theIsParentClosed flag indicating that specified shape is part of closed Solid
//! @param theDrawerOpenedShapePerType the array of shape types to fill //! @param theDrawerOpenedShapePerType the array of shape types to fill
//! @param theDrawerClosedFaces the map for closed faces //! @param theDrawerClosedFaces the map for closed faces
Standard_EXPORT static Standard_Boolean dispatchColors (const Handle(AIS_ColoredDrawer)& theParentDrawer, Standard_EXPORT static Standard_Boolean dispatchColors(
const TopoDS_Shape& theShapeToParse, const Handle(AIS_ColoredDrawer)& theParentDrawer,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap, const TopoDS_Shape& theShapeToParse,
const TopAbs_ShapeEnum theParentType, const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const Standard_Boolean theIsParentClosed, const TopAbs_ShapeEnum theParentType,
DataMapOfDrawerCompd* theDrawerOpenedShapePerType, const Standard_Boolean theIsParentClosed,
DataMapOfDrawerCompd& theDrawerClosedFaces); DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
protected: DataMapOfDrawerCompd& theDrawerClosedFaces);
protected:
//! Extract myShapeColors map (KeyshapeColored -> Color) to subshapes map (Subshape -> Color). //! Extract myShapeColors map (KeyshapeColored -> Color) to subshapes map (Subshape -> Color).
//! This needed when colored shape is not part of BaseShape (but subshapes are) and actually container for subshapes. //! This needed when colored shape is not part of BaseShape (but subshapes are) and actually
Standard_EXPORT void fillSubshapeDrawerMap (AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const; //! container for subshapes.
Standard_EXPORT void fillSubshapeDrawerMap(AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const;
//! Add shape to presentation //! Add shape to presentation
//! @param thePrs the presentation //! @param thePrs the presentation
//! @param theDrawerOpenedShapePerType the shapes map with unique attributes //! @param theDrawerOpenedShapePerType the shapes map with unique attributes
//! @param theDrawerClosedFaces the map of attributes for closed faces //! @param theDrawerClosedFaces the map of attributes for closed faces
//! @param theMode display mode //! @param theMode display mode
Standard_EXPORT void addShapesWithCustomProps (const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT void addShapesWithCustomProps(
const DataMapOfDrawerCompd* theDrawerOpenedShapePerType, const Handle(Prs3d_Presentation)& thePrs,
const DataMapOfDrawerCompd& theDrawerClosedFaces, const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
const Standard_Integer theMode); const DataMapOfDrawerCompd& theDrawerClosedFaces,
const Standard_Integer theMode);
//! Check all shapes from myShapeColorsfor visibility //! Check all shapes from myShapeColorsfor visibility
Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const; Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const;
//! Resolve (parse) theKeyShape into subshapes, search in they for theBaseShape, //! Resolve (parse) theKeyShape into subshapes, search in they for theBaseShape,
//! bind all resolved subshapes with theOriginKeyShape and store all binds in theShapeDrawerMap //! bind all resolved subshapes with theOriginKeyShape and store all binds in theShapeDrawerMap
//! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape -> theOriginKeyShape //! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape ->
//! theOriginKeyShape
//! @param theKeyShape a shape to be resolved (parse) into smaller (in topological sense) //! @param theKeyShape a shape to be resolved (parse) into smaller (in topological sense)
//! subshapes for new bind cycle //! subshapes for new bind cycle
//! @param theDrawer assigned drawer //! @param theDrawer assigned drawer
Standard_EXPORT void bindSubShapes (AIS_DataMapOfShapeDrawer& theShapeDrawerMap, Standard_EXPORT void bindSubShapes(AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theKeyShape, const TopoDS_Shape& theKeyShape,
const Handle(AIS_ColoredDrawer)& theDrawer) const; const Handle(AIS_ColoredDrawer)& theDrawer) const;
//! Add sub-shape to selection considering hidden state (recursively). //! Add sub-shape to selection considering hidden state (recursively).
//! @param theParentDrawer drawer of parent shape //! @param theParentDrawer drawer of parent shape
@@ -160,24 +158,21 @@ protected:
//! @param theTypOfSel type of selection //! @param theTypOfSel type of selection
//! @param theDeflection linear deflection //! @param theDeflection linear deflection
//! @param theDeflAngle angular deflection //! @param theDeflAngle angular deflection
Standard_EXPORT void computeSubshapeSelection (const Handle(AIS_ColoredDrawer)& theParentDrawer, Standard_EXPORT void computeSubshapeSelection(const Handle(AIS_ColoredDrawer)& theParentDrawer,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap, const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const Handle(StdSelect_BRepOwner)& theOwner, const Handle(StdSelect_BRepOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection, const Handle(SelectMgr_Selection)& theSelection,
const TopAbs_ShapeEnum theTypOfSel, const TopAbs_ShapeEnum theTypOfSel,
const Standard_Integer thePriority, const Standard_Integer thePriority,
const Standard_Real theDeflection, const Standard_Real theDeflection,
const Standard_Real theDeflAngle); const Standard_Real theDeflAngle);
protected: protected:
AIS_DataMapOfShapeDrawer myShapeColors; AIS_DataMapOfShapeDrawer myShapeColors;
public: public:
DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape, AIS_Shape)
DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape,AIS_Shape)
}; };
DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape) DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape)

View File

@@ -31,32 +31,30 @@
#include <StdSelect_BRepOwner.hxx> #include <StdSelect_BRepOwner.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
//======================================================================= //=================================================================================================
//function : AIS_ConnectedInteractive
//purpose : AIS_ConnectedInteractive::AIS_ConnectedInteractive(
//======================================================================= const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): : AIS_InteractiveObject(aTypeOfPresentation3d)
AIS_InteractiveObject(aTypeOfPresentation3d)
{ {
// //
} }
//======================================================================= //=================================================================================================
//function : connect
//purpose : void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
//======================================================================= const Handle(TopLoc_Datum3D)& theLocation)
void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theLocation)
{ {
if (myReference == theAnotherObj) if (myReference == theAnotherObj)
{ {
setLocalTransformation (theLocation); setLocalTransformation(theLocation);
return; return;
} }
Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj); Handle(AIS_ConnectedInteractive) aConnected =
Handle(AIS_ConnectedInteractive)::DownCast(theAnotherObj);
if (!aConnected.IsNull()) if (!aConnected.IsNull())
{ {
myReference = aConnected->myReference; myReference = aConnected->myReference;
@@ -67,59 +65,57 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
} }
else else
{ {
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - object without own presentation can not be connected"); throw Standard_ProgramError(
"AIS_ConnectedInteractive::Connect() - object without own presentation can not be connected");
} }
if (!myReference.IsNull()) if (!myReference.IsNull())
{ {
if (myReference->HasInteractiveContext() if (myReference->HasInteractiveContext()
&& myReference->GetContext()->DisplayStatus (myReference) != AIS_DS_None) && myReference->GetContext()->DisplayStatus(myReference) != AIS_DS_None)
{ {
myReference.Nullify(); myReference.Nullify();
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should NOT be displayed in context"); throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should "
"NOT be displayed in context");
} }
myTypeOfPresentation3d = myReference->TypeOfPresentation3d(); myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
} }
setLocalTransformation (theLocation); setLocalTransformation(theLocation);
} }
//======================================================================= //=================================================================================================
//function : Disconnect
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::Disconnect() void AIS_ConnectedInteractive::Disconnect()
{ {
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) for (PrsMgr_Presentations::Iterator aPrsIter(myPresentations); aPrsIter.More(); aPrsIter.Next())
{ {
const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value(); const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value();
if (!aPrs.IsNull()) if (!aPrs.IsNull())
{ {
aPrs->DisconnectAll (Graphic3d_TOC_DESCENDANT); aPrs->DisconnectAll(Graphic3d_TOC_DESCENDANT);
} }
} }
} }
//=======================================================================
//function : Compute //=================================================================================================
//purpose :
//======================================================================= void AIS_ConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Handle(Prs3d_Presentation)& thePrs,
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode)
const Standard_Integer theMode)
{ {
if (HasConnection()) if (HasConnection())
{ {
thePrs->Clear (Standard_False); thePrs->Clear(Standard_False);
thePrs->DisconnectAll (Graphic3d_TOC_DESCENDANT); thePrs->DisconnectAll(Graphic3d_TOC_DESCENDANT);
if (!myReference->HasInteractiveContext()) if (!myReference->HasInteractiveContext())
{ {
myReference->SetContext (GetContext()); myReference->SetContext(GetContext());
} }
thePrsMgr->Connect (this, myReference, theMode, theMode); thePrsMgr->Connect(this, myReference, theMode, theMode);
if (thePrsMgr->Presentation (myReference, theMode)->MustBeUpdated()) if (thePrsMgr->Presentation(myReference, theMode)->MustBeUpdated())
{ {
thePrsMgr->Update (myReference, theMode); thePrsMgr->Update(myReference, theMode);
} }
} }
@@ -129,17 +125,14 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)
} }
} }
//======================================================================= //=================================================================================================
//function : computeHLR
//purpose : void AIS_ConnectedInteractive::computeHLR(const Handle(Graphic3d_Camera)& theProjector,
//======================================================================= const Handle(TopLoc_Datum3D)& theTransformation,
void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& theProjector, const Handle(Prs3d_Presentation)& thePresentation)
const Handle(TopLoc_Datum3D)& theTransformation,
const Handle(Prs3d_Presentation)& thePresentation)
{ {
const bool hasTrsf = !theTransformation.IsNull() const bool hasTrsf = !theTransformation.IsNull() && theTransformation->Form() != gp_Identity;
&& theTransformation->Form() != gp_Identity; updateShape(!hasTrsf);
updateShape (!hasTrsf);
if (myShape.IsNull()) if (myShape.IsNull())
{ {
return; return;
@@ -147,49 +140,45 @@ void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& thePr
if (hasTrsf) if (hasTrsf)
{ {
const TopLoc_Location& aLocation = myShape.Location(); const TopLoc_Location& aLocation = myShape.Location();
TopoDS_Shape aShape = myShape.Located (TopLoc_Location (theTransformation->Trsf()) * aLocation); TopoDS_Shape aShape = myShape.Located(TopLoc_Location(theTransformation->Trsf()) * aLocation);
AIS_Shape::computeHlrPresentation (theProjector, thePresentation, aShape, myDrawer); AIS_Shape::computeHlrPresentation(theProjector, thePresentation, aShape, myDrawer);
} }
else else
{ {
AIS_Shape::computeHlrPresentation (theProjector, thePresentation, myShape, myDrawer); AIS_Shape::computeHlrPresentation(theProjector, thePresentation, myShape, myDrawer);
} }
} }
//======================================================================= //=================================================================================================
//function : updateShape
//purpose : void AIS_ConnectedInteractive::updateShape(const Standard_Boolean isWithLocation)
//=======================================================================
void AIS_ConnectedInteractive::updateShape (const Standard_Boolean isWithLocation)
{ {
Handle(AIS_Shape) anAisShape = Handle(AIS_Shape)::DownCast (myReference); Handle(AIS_Shape) anAisShape = Handle(AIS_Shape)::DownCast(myReference);
if (anAisShape.IsNull()) if (anAisShape.IsNull())
{ {
return; return;
} }
TopoDS_Shape aShape = anAisShape->Shape(); TopoDS_Shape aShape = anAisShape->Shape();
if (aShape.IsNull()) if (aShape.IsNull())
{ {
return; return;
} }
if(!isWithLocation) if (!isWithLocation)
{ {
myShape = aShape; myShape = aShape;
} }
else else
{ {
myShape = aShape.Moved (TopLoc_Location (Transformation())); myShape = aShape.Moved(TopLoc_Location(Transformation()));
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSelection
//purpose : void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
//======================================================================= const Standard_Integer theMode)
void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{ {
if (!HasConnection()) if (!HasConnection())
{ {
@@ -198,27 +187,30 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
if (theMode != 0 && myReference->AcceptShapeDecomposition()) if (theMode != 0 && myReference->AcceptShapeDecomposition())
{ {
computeSubShapeSelection (theSelection, theMode); computeSubShapeSelection(theSelection, theMode);
return; return;
} }
if (!myReference->HasSelection (theMode)) if (!myReference->HasSelection(theMode))
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection (theMode); const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(theMode);
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this); Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
TopLoc_Location aLocation (Transformation()); TopLoc_Location aLocation(Transformation());
anOwner->SetLocation (aLocation); anOwner->SetLocation(aLocation);
if (TheRefSel->IsEmpty()) if (TheRefSel->IsEmpty())
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (TheRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
TheRefSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{ {
if (const Handle(Select3D_SensitiveEntity)& aSensitive = aSelEntIter.Value()->BaseSensitive()) if (const Handle(Select3D_SensitiveEntity)& aSensitive = aSelEntIter.Value()->BaseSensitive())
{ {
@@ -226,67 +218,73 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
if (Handle(Select3D_SensitiveEntity) aNewSensitive = aSensitive->GetConnected()) if (Handle(Select3D_SensitiveEntity) aNewSensitive = aSensitive->GetConnected())
{ {
aNewSensitive->Set(anOwner); aNewSensitive->Set(anOwner);
theSelection->Add (aNewSensitive); theSelection->Add(aNewSensitive);
} }
} }
} }
} }
//======================================================================= //=================================================================================================
//function : ComputeSubShapeSelection
//purpose : void AIS_ConnectedInteractive::computeSubShapeSelection(
//======================================================================= const Handle(SelectMgr_Selection)& theSelection,
void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode)
const Standard_Integer theMode)
{ {
typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList; typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList> typedef NCollection_DataMap<TopoDS_Shape, SensitiveList> Shapes2EntitiesMap;
Shapes2EntitiesMap;
if (!myReference->HasSelection (theMode)) if (!myReference->HasSelection(theMode))
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode); const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection(theMode);
if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full) if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full)
{ {
myReference->RecomputePrimitives (theMode); myReference->RecomputePrimitives(theMode);
} }
// Fill in the map of subshapes and corresponding sensitive entities associated with aMode // Fill in the map of subshapes and corresponding sensitive entities associated with aMode
Shapes2EntitiesMap aShapes2EntitiesMap; Shapes2EntitiesMap aShapes2EntitiesMap;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aRefSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{ {
if (const Handle(Select3D_SensitiveEntity)& aSE = aSelEntIter.Value()->BaseSensitive()) if (const Handle(Select3D_SensitiveEntity)& aSE = aSelEntIter.Value()->BaseSensitive())
{ {
if (Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId())) if (Handle(StdSelect_BRepOwner) anOwner =
Handle(StdSelect_BRepOwner)::DownCast(aSE->OwnerId()))
{ {
const TopoDS_Shape& aSubShape = anOwner->Shape(); const TopoDS_Shape& aSubShape = anOwner->Shape();
if(!aShapes2EntitiesMap.IsBound (aSubShape)) if (!aShapes2EntitiesMap.IsBound(aSubShape))
{ {
aShapes2EntitiesMap.Bind (aSubShape, SensitiveList()); aShapes2EntitiesMap.Bind(aSubShape, SensitiveList());
} }
aShapes2EntitiesMap (aSubShape).Append (aSE); aShapes2EntitiesMap(aSubShape).Append(aSE);
} }
} }
} }
// Fill in selection from aShapes2EntitiesMap // Fill in selection from aShapes2EntitiesMap
for (Shapes2EntitiesMap::Iterator aMapIt (aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next()) for (Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
{ {
const SensitiveList& aSEList = aMapIt.Value(); const SensitiveList& aSEList = aMapIt.Value();
Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner (aMapIt.Key(), this, aSEList.First()->OwnerId()->Priority(), Standard_True); Handle(StdSelect_BRepOwner) anOwner =
anOwner->SetLocation (Transformation()); new StdSelect_BRepOwner(aMapIt.Key(),
for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next()) this,
aSEList.First()->OwnerId()->Priority(),
Standard_True);
anOwner->SetLocation(Transformation());
for (SensitiveList::Iterator aListIt(aSEList); aListIt.More(); aListIt.Next())
{ {
if (Handle(Select3D_SensitiveEntity) aNewSE = aListIt.Value()->GetConnected()) if (Handle(Select3D_SensitiveEntity) aNewSE = aListIt.Value()->GetConnected())
{ {
aNewSE->Set (anOwner); aNewSE->Set(anOwner);
theSelection->Add (aNewSE); theSelection->Add(aNewSE);
} }
} }
} }
StdSelect::SetDrawerForBRepOwner (theSelection, myDrawer); StdSelect::SetDrawerForBRepOwner(theSelection, myDrawer);
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,15 +17,14 @@
#ifndef _AIS_DisplayMode_HeaderFile #ifndef _AIS_DisplayMode_HeaderFile
#define _AIS_DisplayMode_HeaderFile #define _AIS_DisplayMode_HeaderFile
//! Sets display modes other than neutral point ones, //! Sets display modes other than neutral point ones,
//! for interactive objects. The possibilities include: //! for interactive objects. The possibilities include:
//! - wireframe, //! - wireframe,
//! - shaded, //! - shaded,
enum AIS_DisplayMode enum AIS_DisplayMode
{ {
AIS_WireFrame, AIS_WireFrame,
AIS_Shaded AIS_Shaded
}; };
#endif // _AIS_DisplayMode_HeaderFile #endif // _AIS_DisplayMode_HeaderFile

View File

@@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <AIS_ExclusionFilter.hxx> #include <AIS_ExclusionFilter.hxx>
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
@@ -22,55 +21,52 @@
#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx> #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx> #include <TColStd_ListOfInteger.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_ExclusionFilter,SelectMgr_Filter) IMPLEMENT_STANDARD_RTTIEXT(AIS_ExclusionFilter, SelectMgr_Filter)
//======================================================================= //=================================================================================================
//function : AIS_ExclusionFilter
//purpose : Constructors AIS_ExclusionFilter::AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn)
//======================================================================= : myIsExclusionFlagOn(ExclusionFlagOn)
AIS_ExclusionFilter::AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
{ {
} }
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Boolean ExclusionFlagOn): const Standard_Boolean ExclusionFlagOn)
myIsExclusionFlagOn(ExclusionFlagOn) : myIsExclusionFlagOn(ExclusionFlagOn)
{ {
TColStd_ListOfInteger L; TColStd_ListOfInteger L;
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L); myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
} }
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType, const Standard_Integer SignatureInType,
const Standard_Boolean ExclusionFlagOn): const Standard_Boolean ExclusionFlagOn)
myIsExclusionFlagOn(ExclusionFlagOn) : myIsExclusionFlagOn(ExclusionFlagOn)
{ {
TColStd_ListOfInteger L; TColStd_ListOfInteger L;
L.Append(SignatureInType); L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L); myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
} }
//======================================================================= //=================================================================================================
//function : Add
//purpose : Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude)
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude)
{ {
if(IsStored(TypeToExclude)) if (IsStored(TypeToExclude))
return Standard_False; return Standard_False;
TColStd_ListOfInteger L; TColStd_ListOfInteger L;
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L); myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
return Standard_True; return Standard_True;
} }
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude, Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType) const Standard_Integer SignatureInType)
{ {
if(!IsStored(TypeToExclude)){ if (!IsStored(TypeToExclude))
{
TColStd_ListOfInteger L; TColStd_ListOfInteger L;
L.Append(SignatureInType); L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude,L); myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
return Standard_True; return Standard_True;
} }
@@ -78,26 +74,27 @@ Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExcl
return Standard_True; return Standard_True;
} }
//======================================================================= //=================================================================================================
//function : Remove
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude) Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude)
{ {
if(!IsStored(TypeToExclude)) return Standard_False; if (!IsStored(TypeToExclude))
return Standard_False;
myStoredTypes((Standard_Integer)TypeToExclude).Clear(); myStoredTypes((Standard_Integer)TypeToExclude).Clear();
myStoredTypes.UnBind((Standard_Integer)TypeToExclude); myStoredTypes.UnBind((Standard_Integer)TypeToExclude);
return Standard_True; return Standard_True;
} }
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude, Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType) const Standard_Integer SignatureInType)
{ {
if(!IsStored(TypeToExclude)) return Standard_False; if (!IsStored(TypeToExclude))
return Standard_False;
TColStd_ListOfInteger& LL = myStoredTypes.ChangeFind((Standard_Integer)TypeToExclude); TColStd_ListOfInteger& LL = myStoredTypes.ChangeFind((Standard_Integer)TypeToExclude);
for(TColStd_ListIteratorOfListOfInteger it(LL);it.More();it.Next()){ for (TColStd_ListIteratorOfListOfInteger it(LL); it.More(); it.Next())
if(it.Value()==SignatureInType){ {
if (it.Value() == SignatureInType)
{
LL.Remove(it); LL.Remove(it);
return Standard_True; return Standard_True;
} }
@@ -105,105 +102,82 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
return Standard_False; return Standard_False;
} }
//=================================================================================================
//======================================================================= void AIS_ExclusionFilter::Clear()
//function : Clear
//purpose :
//=======================================================================
void AIS_ExclusionFilter::Clear()
{ {
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger Mit(myStoredTypes); TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger Mit(myStoredTypes);
for(;Mit.More();Mit.Next()) for (; Mit.More(); Mit.Next())
myStoredTypes.ChangeFind(Mit.Key()).Clear(); myStoredTypes.ChangeFind(Mit.Key()).Clear();
myStoredTypes.Clear(); myStoredTypes.Clear();
} }
//======================================================================= //=================================================================================================
//function : IsStored
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsStored(const AIS_KindOfInteractive aType) const Standard_Boolean AIS_ExclusionFilter::IsStored(const AIS_KindOfInteractive aType) const
{ {
return myStoredTypes.IsBound(Standard_Integer(aType)); return myStoredTypes.IsBound(Standard_Integer(aType));
} }
//======================================================================= //=================================================================================================
//function : IsSignatureIn
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsSignatureIn(const AIS_KindOfInteractive aType, Standard_Boolean AIS_ExclusionFilter::IsSignatureIn(const AIS_KindOfInteractive aType,
const Standard_Integer SignatureInType) const const Standard_Integer SignatureInType) const
{ {
if(!myStoredTypes.IsBound(aType)) return Standard_False; if (!myStoredTypes.IsBound(aType))
for(TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType)); return Standard_False;
Lit.More(); for (TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType)); Lit.More();
Lit.Next()){ Lit.Next())
if(Lit.Value()==SignatureInType) {
if (Lit.Value() == SignatureInType)
return Standard_True; return Standard_True;
} }
return Standard_False; return Standard_False;
} }
//======================================================================= //=================================================================================================
//function : ListOfStoredTypes
//purpose :
//=======================================================================
void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) const void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) const
{ {
TheList.Clear(); TheList.Clear();
TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger MIT(myStoredTypes); TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger MIT(myStoredTypes);
for(;MIT.More();MIT.Next()) for (; MIT.More(); MIT.Next())
TheList.Append(MIT.Key()); TheList.Append(MIT.Key());
} }
//======================================================================= //=================================================================================================
//function : ListOfSignature
//purpose :
//=======================================================================
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,TColStd_ListOfInteger& TheStoredList) const void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,
TColStd_ListOfInteger& TheStoredList) const
{ {
TheStoredList.Clear(); TheStoredList.Clear();
if(IsStored(aType)) if (IsStored(aType))
for(TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType));it.More();it.Next()) for (TColStd_ListIteratorOfListOfInteger it(myStoredTypes(aType)); it.More(); it.Next())
TheStoredList.Append(it.Value()); TheStoredList.Append(it.Value());
} }
//======================================================================= //=================================================================================================
//function : IsOk
//purpose :
//=======================================================================
Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{ {
if(myStoredTypes.IsEmpty()) if (myStoredTypes.IsEmpty())
return myIsExclusionFlagOn; return myIsExclusionFlagOn;
if(EO.IsNull()) if (EO.IsNull())
return Standard_False; return Standard_False;
Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable());
if(IO.IsNull()) if (IO.IsNull())
return Standard_False; return Standard_False;
// type of AIS is not in the map... // type of AIS is not in the map...
if(!myStoredTypes.IsBound(IO->Type())) if (!myStoredTypes.IsBound(IO->Type()))
return myIsExclusionFlagOn ; return myIsExclusionFlagOn;
// type of AIS is not in the map and there is no signature indicated // type of AIS is not in the map and there is no signature indicated
if(myStoredTypes(IO->Type()).IsEmpty()) if (myStoredTypes(IO->Type()).IsEmpty())
return !myIsExclusionFlagOn ;
// one or several signatures are indicated...
if(IsSignatureIn(IO->Type(),IO->Signature()))
return !myIsExclusionFlagOn; return !myIsExclusionFlagOn;
// one or several signatures are indicated...
if (IsSignatureIn(IO->Type(), IO->Signature()))
return !myIsExclusionFlagOn;
return myIsExclusionFlagOn; return myIsExclusionFlagOn;
} }

View File

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

View File

@@ -18,13 +18,11 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
// ======================================================================= //=================================================================================================
// function : AIS_GlobalStatus
// purpose :
// =======================================================================
AIS_GlobalStatus::AIS_GlobalStatus() AIS_GlobalStatus::AIS_GlobalStatus()
: myDispMode (0), : myDispMode(0),
myIsHilit(Standard_False), myIsHilit(Standard_False),
mySubInt (Standard_False) mySubInt(Standard_False)
{ {
} }

View File

@@ -31,7 +31,6 @@ class AIS_GlobalStatus : public Standard_Transient
{ {
DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient) DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
public: public:
//! Default constructor. //! Default constructor.
Standard_EXPORT AIS_GlobalStatus(); Standard_EXPORT AIS_GlobalStatus();
@@ -39,16 +38,16 @@ public:
Standard_Integer DisplayMode() const { return myDispMode; } Standard_Integer DisplayMode() const { return myDispMode; }
//! Sets display mode. //! Sets display mode.
void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; } void SetDisplayMode(const Standard_Integer theMode) { myDispMode = theMode; }
//! Returns TRUE if object is highlighted //! Returns TRUE if object is highlighted
Standard_Boolean IsHilighted() const { return myIsHilit; } Standard_Boolean IsHilighted() const { return myIsHilit; }
//! Sets highlighted state. //! Sets highlighted state.
void SetHilightStatus (const Standard_Boolean theStatus) { myIsHilit = theStatus; } void SetHilightStatus(const Standard_Boolean theStatus) { myIsHilit = theStatus; }
//! Changes applied highlight style for a particular object //! Changes applied highlight style for a particular object
void SetHilightStyle (const Handle(Prs3d_Drawer)& theStyle) { myHiStyle = theStyle; } void SetHilightStyle(const Handle(Prs3d_Drawer)& theStyle) { myHiStyle = theStyle; }
//! Returns applied highlight style for a particular object //! Returns applied highlight style for a particular object
const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; } const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; }
@@ -57,46 +56,41 @@ public:
const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; } const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; }
//! Return TRUE if selection mode was registered. //! Return TRUE if selection mode was registered.
Standard_Boolean IsSModeIn (Standard_Integer theMode) const Standard_Boolean IsSModeIn(Standard_Integer theMode) const
{ {
return mySelModes.Contains (theMode); return mySelModes.Contains(theMode);
} }
//! Add selection mode. //! Add selection mode.
Standard_Boolean AddSelectionMode (const Standard_Integer theMode) Standard_Boolean AddSelectionMode(const Standard_Integer theMode)
{ {
if (!mySelModes.Contains (theMode)) if (!mySelModes.Contains(theMode))
{ {
mySelModes.Append (theMode); mySelModes.Append(theMode);
return Standard_True; return Standard_True;
} }
return Standard_False; return Standard_False;
} }
//! Remove selection mode. //! Remove selection mode.
Standard_Boolean RemoveSelectionMode (const Standard_Integer theMode) Standard_Boolean RemoveSelectionMode(const Standard_Integer theMode)
{ {
return mySelModes.Remove (theMode); return mySelModes.Remove(theMode);
} }
//! Remove all selection modes. //! Remove all selection modes.
void ClearSelectionModes() void ClearSelectionModes() { mySelModes.Clear(); }
{
mySelModes.Clear();
}
Standard_Boolean IsSubIntensityOn() const { return mySubInt; } Standard_Boolean IsSubIntensityOn() const { return mySubInt; }
void SetSubIntensity (Standard_Boolean theIsOn) { mySubInt = theIsOn; } void SetSubIntensity(Standard_Boolean theIsOn) { mySubInt = theIsOn; }
private: private:
TColStd_ListOfInteger mySelModes; TColStd_ListOfInteger mySelModes;
Handle(Prs3d_Drawer) myHiStyle; Handle(Prs3d_Drawer) myHiStyle;
Standard_Integer myDispMode; Standard_Integer myDispMode;
Standard_Boolean myIsHilit; Standard_Boolean myIsHilit;
Standard_Boolean mySubInt; Standard_Boolean mySubInt;
}; };
#endif // _AIS_GlobalStatus_HeaderFile #endif // _AIS_GlobalStatus_HeaderFile

View File

@@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <AIS_GraphicTool.hxx> #include <AIS_GraphicTool.hxx>
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_MaterialAspect.hxx> #include <Graphic3d_MaterialAspect.hxx>
@@ -27,96 +26,99 @@
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr, static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att) const AIS_TypeOfAttribute Att)
{ {
switch(Att) switch (Att)
{ {
case AIS_TOA_Line: case AIS_TOA_Line:
return Dr->LineAspect(); return Dr->LineAspect();
case AIS_TOA_Dimension: case AIS_TOA_Dimension:
return Dr->DimensionAspect()->LineAspect(); return Dr->DimensionAspect()->LineAspect();
case AIS_TOA_Wire: case AIS_TOA_Wire:
return Dr->WireAspect(); return Dr->WireAspect();
case AIS_TOA_Plane: case AIS_TOA_Plane:
return Dr->PlaneAspect()->EdgesAspect(); return Dr->PlaneAspect()->EdgesAspect();
case AIS_TOA_Vector: case AIS_TOA_Vector:
return Dr->VectorAspect(); return Dr->VectorAspect();
case AIS_TOA_UIso: case AIS_TOA_UIso:
return Handle(Prs3d_LineAspect) (Dr->UIsoAspect()); return Handle(Prs3d_LineAspect)(Dr->UIsoAspect());
case AIS_TOA_VIso: case AIS_TOA_VIso:
return Handle(Prs3d_LineAspect) (Dr->VIsoAspect()); return Handle(Prs3d_LineAspect)(Dr->VIsoAspect());
case AIS_TOA_Free: case AIS_TOA_Free:
return Dr->FreeBoundaryAspect(); return Dr->FreeBoundaryAspect();
case AIS_TOA_UnFree: case AIS_TOA_UnFree:
return Dr->UnFreeBoundaryAspect(); return Dr->UnFreeBoundaryAspect();
case AIS_TOA_Section: case AIS_TOA_Section:
return Dr->SectionAspect(); return Dr->SectionAspect();
case AIS_TOA_Hidden: case AIS_TOA_Hidden:
return Dr->HiddenLineAspect(); return Dr->HiddenLineAspect();
case AIS_TOA_Seen: case AIS_TOA_Seen:
return Dr->SeenLineAspect(); return Dr->SeenLineAspect();
case AIS_TOA_FaceBoundary: case AIS_TOA_FaceBoundary:
return Dr->FaceBoundaryAspect(); return Dr->FaceBoundaryAspect();
case AIS_TOA_FirstAxis: case AIS_TOA_FirstAxis:
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis); return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis);
case AIS_TOA_SecondAxis: case AIS_TOA_SecondAxis:
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis); return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis);
case AIS_TOA_ThirdAxis: case AIS_TOA_ThirdAxis:
return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis); return Dr->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis);
} }
Handle(Prs3d_LineAspect) bid; Handle(Prs3d_LineAspect) bid;
return bid; return bid;
} }
Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att) Quantity_NameOfColor AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{ {
Quantity_Color color; Quantity_Color color;
GetLineColor(Dr,Att,color); GetLineColor(Dr, Att, color);
return color.Name(); return color.Name();
} }
void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor) void AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att,
Quantity_Color& aColor)
{ {
aColor = GetLineAspect(Dr,Att)->Aspect()->Color(); aColor = GetLineAspect(Dr, Att)->Aspect()->Color();
} }
Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr, Standard_Real AIS_GraphicTool::GetLineWidth(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att) const AIS_TypeOfAttribute Att)
{ {
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
return LA->Aspect()->Width(); return LA->Aspect()->Width();
} }
Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att) Aspect_TypeOfLine AIS_GraphicTool::GetLineType(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{ {
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
return LA->Aspect()->Type(); return LA->Aspect()->Type();
} }
void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr, void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att, const AIS_TypeOfAttribute Att,
Quantity_NameOfColor& Col, Quantity_NameOfColor& Col,
Standard_Real& W, Standard_Real& W,
Aspect_TypeOfLine& TYP) Aspect_TypeOfLine& TYP)
{ {
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
Col = LA->Aspect()->Color().Name(); Col = LA->Aspect()->Color().Name();
W = LA->Aspect()->Width(); W = LA->Aspect()->Width();
TYP = LA->Aspect()->Type(); TYP = LA->Aspect()->Type();
} }
Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr) Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr)
{ {
Quantity_Color color; Quantity_Color color;
GetInteriorColor(Dr,color); GetInteriorColor(Dr, color);
return color.Name(); return color.Name();
} }
void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor) void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color& aColor)
{ {
Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect(); Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect();
aColor = AFA->InteriorColor(); aColor = AFA->InteriorColor();
} }
Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr) Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr)

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -27,59 +27,50 @@
#include <Prs3d_TextAspect.hxx> #include <Prs3d_TextAspect.hxx>
#include <PrsMgr_PresentationManager.hxx> #include <PrsMgr_PresentationManager.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
//======================================================================= //=================================================================================================
//function : AIS_InteractiveObject
//purpose : AIS_InteractiveObject::AIS_InteractiveObject(
//======================================================================= const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) : SelectMgr_SelectableObject(aTypeOfPresentation3d),
: SelectMgr_SelectableObject (aTypeOfPresentation3d), myCTXPtr(NULL)
myCTXPtr (NULL)
{ {
// //
} }
//======================================================================= //=================================================================================================
//function : Redisplay
//purpose : void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes)
//=======================================================================
void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
{ {
if (myCTXPtr == NULL) if (myCTXPtr == NULL)
return; return;
myCTXPtr->Redisplay (this, Standard_False, AllModes); myCTXPtr->Redisplay(this, Standard_False, AllModes);
} }
//======================================================================= //=================================================================================================
//function : ProcessDragging
//purpose : Standard_Boolean AIS_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)&,
//======================================================================= const Handle(V3d_View)&,
Standard_Boolean AIS_InteractiveObject::ProcessDragging (const Handle(AIS_InteractiveContext)&, const Handle(SelectMgr_EntityOwner)&,
const Handle(V3d_View)&, const Graphic3d_Vec2i&,
const Handle(SelectMgr_EntityOwner)&, const Graphic3d_Vec2i&,
const Graphic3d_Vec2i&, const AIS_DragAction)
const Graphic3d_Vec2i&,
const AIS_DragAction)
{ {
return Standard_False; return Standard_False;
} }
//======================================================================= //=================================================================================================
//function :
//purpose : Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
//=======================================================================
Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
{ {
return myCTXPtr; return myCTXPtr;
} }
//======================================================================= //=================================================================================================
//function : SetContext
//purpose : void AIS_InteractiveObject::SetContext(const Handle(AIS_InteractiveContext)& theCtx)
//=======================================================================
void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
{ {
if (myCTXPtr == theCtx.get()) if (myCTXPtr == theCtx.get())
{ {
@@ -89,33 +80,27 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
myCTXPtr = theCtx.get(); myCTXPtr = theCtx.get();
if (!theCtx.IsNull()) if (!theCtx.IsNull())
{ {
myDrawer->Link (theCtx->DefaultDrawer()); myDrawer->Link(theCtx->DefaultDrawer());
} }
} }
//======================================================================= //=================================================================================================
//function : SetDisplayStatus
//purpose : void AIS_InteractiveObject::SetDisplayStatus(PrsMgr_DisplayStatus theStatus)
//=======================================================================
void AIS_InteractiveObject::SetDisplayStatus (PrsMgr_DisplayStatus theStatus)
{ {
myDisplayStatus = theStatus; myDisplayStatus = theStatus;
} }
//======================================================================= //=================================================================================================
//function : HasPresentation
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveObject::HasPresentation() const Standard_Boolean AIS_InteractiveObject::HasPresentation() const
{ {
return HasInteractiveContext() return HasInteractiveContext()
&& myCTXPtr->MainPrsMgr()->HasPresentation (this, myDrawer->DisplayMode()); && myCTXPtr->MainPrsMgr()->HasPresentation(this, myDrawer->DisplayMode());
} }
//======================================================================= //=================================================================================================
//function : Presentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
{ {
if (!HasInteractiveContext()) if (!HasInteractiveContext())
@@ -123,14 +108,13 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
return Handle(Prs3d_Presentation)(); return Handle(Prs3d_Presentation)();
} }
Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false); Handle(PrsMgr_Presentation) aPrs =
myCTXPtr->MainPrsMgr()->Presentation(this, myDrawer->DisplayMode(), false);
return aPrs; return aPrs;
} }
//======================================================================= //=================================================================================================
//function : SetAspect
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect) void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect)
{ {
@@ -147,31 +131,29 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect
const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last(); const Handle(Graphic3d_Group)& aGroup = aPrs->Groups().Last();
if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect)) if (Handle(Prs3d_ShadingAspect) aShadingAspect = Handle(Prs3d_ShadingAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aShadingAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aShadingAspect->Aspect());
} }
else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect)) else if (Handle(Prs3d_LineAspect) aLineAspect = Handle(Prs3d_LineAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aLineAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aLineAspect->Aspect());
} }
else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect)) else if (Handle(Prs3d_PointAspect) aPointAspect = Handle(Prs3d_PointAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aPointAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aPointAspect->Aspect());
} }
else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect)) else if (Handle(Prs3d_TextAspect) aTextAspect = Handle(Prs3d_TextAspect)::DownCast(theAspect))
{ {
aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect()); aGroup->SetGroupPrimitivesAspect(aTextAspect->Aspect());
} }
} }
//======================================================================= //=================================================================================================
//function : DumpJson
//purpose :
//=======================================================================
void AIS_InteractiveObject::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_SelectableObject) void AIS_InteractiveObject::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCTXPtr) {
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwner) OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
OCCT_DUMP_BASE_CLASS(theOStream, theDepth, SelectMgr_SelectableObject)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myCTXPtr)
OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, myOwner)
} }

View File

@@ -27,24 +27,26 @@ class V3d_View;
//! Defines a class of objects with display and selection services. //! Defines a class of objects with display and selection services.
//! Entities which are visualized and selected are Interactive Objects. //! Entities which are visualized and selected are Interactive Objects.
//! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer. //! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a
//! Prs3d_Drawer.
//! //!
//! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed, //! You can make use of classes of standard Interactive Objects for which all necessary methods have
//! or you can implement your own classes of Interactive Objects. //! already been programmed, or you can implement your own classes of Interactive Objects. Key
//! Key interface methods to be implemented by every Interactive Object: //! interface methods to be implemented by every Interactive Object:
//! * Presentable Object (PrsMgr_PresentableObject) //! * Presentable Object (PrsMgr_PresentableObject)
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects. //! Consider defining an enumeration of supported Display Mode indexes for particular Interactive
//! Object or class of Interactive Objects.
//! - AcceptDisplayMode() accepting display modes implemented by this object; //! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index; //! - Compute() computing presentation for the given display mode index;
//! * Selectable Object (SelectMgr_SelectableObject) //! * Selectable Object (SelectMgr_SelectableObject)
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects. //! Consider defining an enumeration of supported Selection Mode indexes for particular
//! Interactive Object or class of Interactive Objects.
//! - ComputeSelection() computing selectable entities for the given selection mode index. //! - ComputeSelection() computing selectable entities for the given selection mode index.
class AIS_InteractiveObject : public SelectMgr_SelectableObject class AIS_InteractiveObject : public SelectMgr_SelectableObject
{ {
friend class AIS_InteractiveContext; friend class AIS_InteractiveContext;
DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject) DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
public: public:
//! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default. //! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default.
virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; } virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; }
@@ -59,29 +61,30 @@ public:
//! - Circle signature 6 //! - Circle signature 6
//! - Plane signature 7. //! - Plane signature 7.
virtual Standard_Integer Signature() const { return -1; } virtual Standard_Integer Signature() const { return -1; }
//! Updates the active presentation; if <AllModes> = Standard_True //! Updates the active presentation; if <AllModes> = Standard_True
//! all the presentations inside are recomputed. //! all the presentations inside are recomputed.
//! IMPORTANT: It is preferable to call Redisplay method of //! IMPORTANT: It is preferable to call Redisplay method of
//! corresponding AIS_InteractiveContext instance for cases when it //! corresponding AIS_InteractiveContext instance for cases when it
//! is accessible. This method just redirects call to myCTXPtr, //! is accessible. This method just redirects call to myCTXPtr,
//! so this class field must be up to date for proper result. //! so this class field must be up to date for proper result.
Standard_EXPORT void Redisplay (const Standard_Boolean AllModes = Standard_False); Standard_EXPORT void Redisplay(const Standard_Boolean AllModes = Standard_False);
//! Indicates whether the Interactive Object has a pointer to an interactive context. //! Indicates whether the Interactive Object has a pointer to an interactive context.
Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; } Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; }
//! Returns the context pointer to the interactive context. //! Returns the context pointer to the interactive context.
AIS_InteractiveContext* InteractiveContext() const { return myCTXPtr; } AIS_InteractiveContext* InteractiveContext() const { return myCTXPtr; }
//! Sets the interactive context aCtx and provides a link //! Sets the interactive context aCtx and provides a link
//! to the default drawing tool or "Drawer" if there is none. //! to the default drawing tool or "Drawer" if there is none.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx); Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& aCtx);
//! Returns true if the object has an owner attributed to it. //! Returns true if the object has an owner attributed to it.
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is composed of, and takes the form of a transient. //! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is
//! composed of, and takes the form of a transient.
Standard_Boolean HasOwner() const { return !myOwner.IsNull(); } Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
//! Returns the owner of the Interactive Object. //! Returns the owner of the Interactive Object.
//! The owner can be a shape for a set of sub-shapes or //! The owner can be a shape for a set of sub-shapes or
//! a sub-shape for sub-shapes which it is composed of, //! a sub-shape for sub-shapes which it is composed of,
@@ -97,10 +100,13 @@ public:
//! an Interactive Object. This can be a shape for a set of //! an Interactive Object. This can be a shape for a set of
//! sub-shapes or a sub-shape for sub-shapes which it //! sub-shapes or a sub-shape for sub-shapes which it
//! is composed of. The owner takes the form of a transient. //! is composed of. The owner takes the form of a transient.
void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; } void SetOwner(const Handle(Standard_Transient)& theApplicativeEntity)
{
myOwner = theApplicativeEntity;
}
//! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient. //! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of
//! This method removes the owner from the graphic entity. //! a Transient. This method removes the owner from the graphic entity.
void ClearOwner() { myOwner.Nullify(); } void ClearOwner() { myOwner.Nullify(); }
//! Drag object in the viewer. //! Drag object in the viewer.
@@ -111,15 +117,15 @@ public:
//! @param[in] theDragTo drag end point //! @param[in] theDragTo drag end point
//! @param[in] theAction drag action //! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start) //! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx, Standard_EXPORT virtual Standard_Boolean ProcessDragging(
const Handle(V3d_View)& theView, const Handle(AIS_InteractiveContext)& theCtx,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theDragFrom, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragTo, const Graphic3d_Vec2i& theDragFrom,
const AIS_DragAction theAction); const Graphic3d_Vec2i& theDragTo,
const AIS_DragAction theAction);
public: public:
//! Returns the context pointer to the interactive context. //! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const; Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
@@ -131,26 +137,26 @@ public:
//! Sets the graphic basic aspect to the current presentation. //! Sets the graphic basic aspect to the current presentation.
Standard_DEPRECATED("Deprecated method, results might be undefined") Standard_DEPRECATED("Deprecated method, results might be undefined")
Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect); Standard_EXPORT void SetAspect(const Handle(Prs3d_BasicAspect)& anAspect);
//! Dumps the content of me into the stream //! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
protected: Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
//! The TypeOfPresention3d means that the interactive object //! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependent on the view of Display. //! may have a presentation dependent on the view of Display.
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); Standard_EXPORT AIS_InteractiveObject(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Set presentation display status. //! Set presentation display status.
Standard_EXPORT void SetDisplayStatus (PrsMgr_DisplayStatus theStatus); Standard_EXPORT void SetDisplayStatus(PrsMgr_DisplayStatus theStatus);
protected: protected:
// clang-format off
// clang-format off
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext() AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
// clang-format on // clang-format on
Handle(Standard_Transient) myOwner; //!< application-specific owner object Handle(Standard_Transient) myOwner; //!< application-specific owner object
}; };
DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)

View File

@@ -27,15 +27,16 @@ enum AIS_KindOfInteractive
AIS_KindOfInteractive_Shape, //!< presentation of topological shape AIS_KindOfInteractive_Shape, //!< presentation of topological shape
AIS_KindOfInteractive_Object, //!< presentation of group of topological shapes AIS_KindOfInteractive_Object, //!< presentation of group of topological shapes
AIS_KindOfInteractive_Relation, //!< presentation of relation (dimensions and constraints) AIS_KindOfInteractive_Relation, //!< presentation of relation (dimensions and constraints)
AIS_KindOfInteractive_Dimension, //!< presentation of dimension (length, radius, diameter and angle) AIS_KindOfInteractive_Dimension, //!< presentation of dimension (length, radius, diameter and
//!< angle)
AIS_KindOfInteractive_LightSource, //!< presentation of light source AIS_KindOfInteractive_LightSource, //!< presentation of light source
// old aliases // old aliases
AIS_KOI_None = AIS_KindOfInteractive_None, AIS_KOI_None = AIS_KindOfInteractive_None,
AIS_KOI_Datum = AIS_KindOfInteractive_Datum, AIS_KOI_Datum = AIS_KindOfInteractive_Datum,
AIS_KOI_Shape = AIS_KindOfInteractive_Shape, AIS_KOI_Shape = AIS_KindOfInteractive_Shape,
AIS_KOI_Object = AIS_KindOfInteractive_Object, AIS_KOI_Object = AIS_KindOfInteractive_Object,
AIS_KOI_Relation = AIS_KindOfInteractive_Relation, AIS_KOI_Relation = AIS_KindOfInteractive_Relation,
AIS_KOI_Dimension = AIS_KindOfInteractive_Dimension AIS_KOI_Dimension = AIS_KindOfInteractive_Dimension
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -29,28 +29,27 @@ class Select3D_SensitiveSphere;
//! - Positional light is represented by a sphere or marker; //! - Positional light is represented by a sphere or marker;
//! - Spot light is represented by a cone; //! - Spot light is represented by a cone;
//! - Directional light is represented by a set of arrows at the corner of view. //! - Directional light is represented by a set of arrows at the corner of view.
//! In addition, light source name could be displayed, and clicking on presentation will enable/disable light. //! In addition, light source name could be displayed, and clicking on presentation will
//! enable/disable light.
class AIS_LightSource : public AIS_InteractiveObject class AIS_LightSource : public AIS_InteractiveObject
{ {
friend class AIS_LightSourceOwner; friend class AIS_LightSourceOwner;
DEFINE_STANDARD_RTTIEXT(AIS_LightSource, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_LightSource, AIS_InteractiveObject)
public: public:
//! Initializes the light source by copying Graphic3d_CLight settings. //! Initializes the light source by copying Graphic3d_CLight settings.
Standard_EXPORT AIS_LightSource (const Handle(Graphic3d_CLight)& theLightSource); Standard_EXPORT AIS_LightSource(const Handle(Graphic3d_CLight)& theLightSource);
//! Returns the light. //! Returns the light.
const Handle(Graphic3d_CLight)& Light() const { return myLightSource; } const Handle(Graphic3d_CLight)& Light() const { return myLightSource; }
//! Set the light. //! Set the light.
void SetLight (const Handle(Graphic3d_CLight)& theLight) void SetLight(const Handle(Graphic3d_CLight)& theLight)
{ {
myLightSource = theLight; myLightSource = theLight;
SetToUpdate(); SetToUpdate();
} }
public: //! @name Light properties public: //! @name Light properties
//! Returns TRUE if the light source name should be displayed; TRUE by default. //! Returns TRUE if the light source name should be displayed; TRUE by default.
Standard_Boolean ToDisplayName() const { return myToDisplayName; } Standard_Boolean ToDisplayName() const { return myToDisplayName; }
@@ -64,12 +63,12 @@ public: //! @name Light properties
} }
} }
//! Returns TRUE to display light source range as sphere (positional light) or cone (spot light); TRUE by default. //! Returns TRUE to display light source range as sphere (positional light) or cone (spot light);
//! Has no effect for non-zoomable presentation. //! TRUE by default. Has no effect for non-zoomable presentation.
Standard_Boolean ToDisplayRange() const { return myToDisplayRange; } Standard_Boolean ToDisplayRange() const { return myToDisplayRange; }
//! Show/hide light source range shaded presentation. //! Show/hide light source range shaded presentation.
void SetDisplayRange (Standard_Boolean theToDisplay) void SetDisplayRange(Standard_Boolean theToDisplay)
{ {
if (myToDisplayRange != theToDisplay) if (myToDisplayRange != theToDisplay)
{ {
@@ -82,7 +81,7 @@ public: //! @name Light properties
Standard_Real Size() const { return mySize; } Standard_Real Size() const { return mySize; }
//! Sets the size of presentation. //! Sets the size of presentation.
void SetSize (Standard_Real theSize) void SetSize(Standard_Real theSize)
{ {
if (mySize != theSize) if (mySize != theSize)
{ {
@@ -95,7 +94,7 @@ public: //! @name Light properties
Standard_Integer ArcSize() const { return mySensSphereArcSize; } Standard_Integer ArcSize() const { return mySensSphereArcSize; }
//! Sets the size of sensitive sphere arc. //! Sets the size of sensitive sphere arc.
void SetArcSize (Standard_Integer theSize) void SetArcSize(Standard_Integer theSize)
{ {
if (mySensSphereArcSize != theSize) if (mySensSphereArcSize != theSize)
{ {
@@ -110,7 +109,7 @@ public: //! @name Light properties
bool IsZoomable() const { return myIsZoomable; } bool IsZoomable() const { return myIsZoomable; }
//! Sets if transform-persistence is allowed. //! Sets if transform-persistence is allowed.
void SetZoomable (bool theIsZoomable) void SetZoomable(bool theIsZoomable)
{ {
if (myIsZoomable != theIsZoomable) if (myIsZoomable != theIsZoomable)
{ {
@@ -120,7 +119,7 @@ public: //! @name Light properties
} }
//! Sets if dragging is allowed. //! Sets if dragging is allowed.
void SetDraggable (bool theIsDraggable) void SetDraggable(bool theIsDraggable)
{ {
if (myIsDraggable != theIsDraggable) if (myIsDraggable != theIsDraggable)
{ {
@@ -132,13 +131,13 @@ public: //! @name Light properties
bool ToSwitchOnClick() const { return myToSwitchOnClick; } bool ToSwitchOnClick() const { return myToSwitchOnClick; }
//! Sets if mouse click should turn light on/off. //! Sets if mouse click should turn light on/off.
void SetSwitchOnClick (bool theToHandle) { myToSwitchOnClick = theToHandle; } void SetSwitchOnClick(bool theToHandle) { myToSwitchOnClick = theToHandle; }
//! Returns a number of directional light arrows to display; 5 by default. //! Returns a number of directional light arrows to display; 5 by default.
Standard_Integer NbArrows() const { return myNbArrows; } Standard_Integer NbArrows() const { return myNbArrows; }
//! Returns a number of directional light arrows to display (supported values: 1, 3, 5, 9). //! Returns a number of directional light arrows to display (supported values: 1, 3, 5, 9).
void SetNbArrows (Standard_Integer theNbArrows) void SetNbArrows(Standard_Integer theNbArrows)
{ {
if (myNbArrows != theNbArrows) if (myNbArrows != theNbArrows)
{ {
@@ -149,25 +148,29 @@ public: //! @name Light properties
//! Returns light source icon. //! Returns light source icon.
//! @param[in] theIsEnabled marker index for enabled/disabled light source states //! @param[in] theIsEnabled marker index for enabled/disabled light source states
const Handle(Graphic3d_MarkerImage)& MarkerImage (bool theIsEnabled) const { return myMarkerImages[theIsEnabled ? 1 : 0]; } const Handle(Graphic3d_MarkerImage)& MarkerImage(bool theIsEnabled) const
{
return myMarkerImages[theIsEnabled ? 1 : 0];
}
//! Returns light source icon. //! Returns light source icon.
//! @param[in] theIsEnabled marker index for enabled/disabled light source states //! @param[in] theIsEnabled marker index for enabled/disabled light source states
Aspect_TypeOfMarker MarkerType (bool theIsEnabled) const { return myMarkerTypes[theIsEnabled ? 1 : 0]; } Aspect_TypeOfMarker MarkerType(bool theIsEnabled) const
{
return myMarkerTypes[theIsEnabled ? 1 : 0];
}
//! Sets custom icon to light source. //! Sets custom icon to light source.
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage, void SetMarkerImage(const Handle(Graphic3d_MarkerImage)& theImage, bool theIsEnabled)
bool theIsEnabled)
{ {
myMarkerImages[theIsEnabled ? 1 : 0] = theImage; myMarkerImages[theIsEnabled ? 1 : 0] = theImage;
myMarkerTypes [theIsEnabled ? 1 : 0] = !theImage.IsNull() myMarkerTypes[theIsEnabled ? 1 : 0] = !theImage.IsNull()
? Aspect_TOM_USERDEFINED ? Aspect_TOM_USERDEFINED
: (theIsEnabled ? Aspect_TOM_O_POINT : Aspect_TOM_O_X); : (theIsEnabled ? Aspect_TOM_O_POINT : Aspect_TOM_O_X);
} }
//! Sets standard icon to light source. //! Sets standard icon to light source.
void SetMarkerType (Aspect_TypeOfMarker theType, void SetMarkerType(Aspect_TypeOfMarker theType, bool theIsEnabled)
bool theIsEnabled)
{ {
myMarkerTypes[theIsEnabled ? 1 : 0] = theType; myMarkerTypes[theIsEnabled ? 1 : 0] = theType;
} }
@@ -176,34 +179,36 @@ public: //! @name Light properties
Standard_Integer NbSplitsQuadric() const { return myNbSplitsQuadric; } Standard_Integer NbSplitsQuadric() const { return myNbSplitsQuadric; }
//! Sets tessellation level for quadric surfaces. //! Sets tessellation level for quadric surfaces.
void SetNbSplitsQuadric (Standard_Integer theNbSplits) { myNbSplitsQuadric = theNbSplits; } void SetNbSplitsQuadric(Standard_Integer theNbSplits) { myNbSplitsQuadric = theNbSplits; }
//! Returns tessellation level for arrows; 20 by default. //! Returns tessellation level for arrows; 20 by default.
Standard_Integer NbSplitsArrow() const { return myNbSplitsArrow; } Standard_Integer NbSplitsArrow() const { return myNbSplitsArrow; }
//! Sets tessellation level for arrows. //! Sets tessellation level for arrows.
void SetNbSplitsArrow (Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; } void SetNbSplitsArrow(Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; }
//! Returns kind of the object. //! Returns kind of the object.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_LightSource; } virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_LightSource;
}
protected: protected:
//! Return true if specified display mode is supported: 0 for main presentation and 1 for
//! Return true if specified display mode is supported: 0 for main presentation and 1 for highlight. //! highlight.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{ {
return theMode == 0 return theMode == 0 || theMode == 1;
|| theMode == 1;
} }
//! Computes selection sensitive zones(triangulation) for light source presentation. //! Computes selection sensitive zones(triangulation) for light source presentation.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs, const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Fills presentation. //! Fills presentation.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE; const Standard_Integer theMode) Standard_OVERRIDE;
//! Drag object in the viewer. //! Drag object in the viewer.
//! @param[in] theCtx interactive context //! @param[in] theCtx interactive context
@@ -213,15 +218,17 @@ protected:
//! @param[in] theDragTo drag end point //! @param[in] theDragTo drag end point
//! @param[in] theAction drag action //! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start) //! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx, Standard_EXPORT virtual Standard_Boolean ProcessDragging(
const Handle(V3d_View)& theView, const Handle(AIS_InteractiveContext)& theCtx,
const Handle(SelectMgr_EntityOwner)& theOwner, const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theDragFrom, const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragTo, const Graphic3d_Vec2i& theDragFrom,
const AIS_DragAction theAction) Standard_OVERRIDE; const Graphic3d_Vec2i& theDragTo,
const AIS_DragAction theAction) Standard_OVERRIDE;
//! Sets new local transformation, which is propagated to Graphic3d_CLight instance. //! Sets new local transformation, which is propagated to Graphic3d_CLight instance.
Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE; Standard_EXPORT virtual void setLocalTransformation(const Handle(TopLoc_Datum3D)& theTrsf)
Standard_OVERRIDE;
//! Updates local transformation basing on a type of light source. //! Updates local transformation basing on a type of light source.
Standard_EXPORT virtual void updateLightLocalTransformation(); Standard_EXPORT virtual void updateLightLocalTransformation();
@@ -233,26 +240,26 @@ protected:
Standard_EXPORT virtual void updateLightAspects(); Standard_EXPORT virtual void updateLightAspects();
//! Compute ambient light source presentation as a sphere at view corner. //! Compute ambient light source presentation as a sphere at view corner.
Standard_EXPORT virtual void computeAmbient (const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void computeAmbient(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode); const Standard_Integer theMode);
//! Compute directional light source presentation as a set of arrows at view corner. //! Compute directional light source presentation as a set of arrows at view corner.
Standard_EXPORT virtual void computeDirectional (const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void computeDirectional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode); const Standard_Integer theMode);
//! Compute positional light source presentation as a sphere of either fixed size (no range) or of size representing a maximum range. //! Compute positional light source presentation as a sphere of either fixed size (no range) or of
Standard_EXPORT virtual void computePositional (const Handle(Prs3d_Presentation)& thePrs, //! size representing a maximum range.
const Standard_Integer theMode); Standard_EXPORT virtual void computePositional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode);
//! Compute spot light source presentation as a cone. //! Compute spot light source presentation as a cone.
Standard_EXPORT virtual void computeSpot (const Handle(Prs3d_Presentation)& thePrs, Standard_EXPORT virtual void computeSpot(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode); const Standard_Integer theMode);
protected: protected:
Handle(Graphic3d_CLight) myLightSource; //!< displayed light source
Handle(Graphic3d_CLight) myLightSource; //!< displayed light source // clang-format off
// clang-format off
Handle(Graphic3d_AspectMarker3d) myDisabledMarkerAspect; //!< disabled light source marker style Handle(Graphic3d_AspectMarker3d) myDisabledMarkerAspect; //!< disabled light source marker style
Handle(Graphic3d_AspectLine3d) myArrowLineAspectShadow; //!< arrow shadow style Handle(Graphic3d_AspectLine3d) myArrowLineAspectShadow; //!< arrow shadow style
Handle(Graphic3d_MarkerImage) myMarkerImages[2]; //!< icon of disabled (0) and enabled (1) light Handle(Graphic3d_MarkerImage) myMarkerImages[2]; //!< icon of disabled (0) and enabled (1) light
@@ -269,11 +276,10 @@ protected:
Standard_Integer mySensSphereArcSize; //! sensitive sphere arc size in pixels Standard_Integer mySensSphereArcSize; //! sensitive sphere arc size in pixels
Standard_Boolean myIsZoomable; //!< flag to allow/disallow transform-persistence when possible Standard_Boolean myIsZoomable; //!< flag to allow/disallow transform-persistence when possible
Standard_Boolean myIsDraggable; //!< flag to allow/disallow rotate directional light source by dragging Standard_Boolean myIsDraggable; //!< flag to allow/disallow rotate directional light source by dragging
// clang-format on // clang-format on
Standard_Boolean myToDisplayName; //!< flag to show/hide name Standard_Boolean myToDisplayName; //!< flag to show/hide name
Standard_Boolean myToDisplayRange; //!< flag to show/hide range of positional/spot light Standard_Boolean myToDisplayRange; //!< flag to show/hide range of positional/spot light
Standard_Boolean myToSwitchOnClick; //!< flag to handle mouse click to turn light on/off Standard_Boolean myToSwitchOnClick; //!< flag to handle mouse click to turn light on/off
}; };
//! Owner of AIS_LightSource presentation. //! Owner of AIS_LightSource presentation.
@@ -281,27 +287,27 @@ class AIS_LightSourceOwner : public SelectMgr_EntityOwner
{ {
DEFINE_STANDARD_RTTIEXT(AIS_LightSourceOwner, SelectMgr_EntityOwner) DEFINE_STANDARD_RTTIEXT(AIS_LightSourceOwner, SelectMgr_EntityOwner)
public: public:
//! Main constructor. //! Main constructor.
Standard_EXPORT AIS_LightSourceOwner (const Handle(AIS_LightSource)& theObject, Standard_EXPORT AIS_LightSourceOwner(const Handle(AIS_LightSource)& theObject,
Standard_Integer thePriority = 5); Standard_Integer thePriority = 5);
//! Handle mouse button click event. //! Handle mouse button click event.
Standard_EXPORT virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint, Standard_EXPORT virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton, Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers, Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick) Standard_OVERRIDE; bool theIsDoubleClick)
Standard_OVERRIDE;
//! Highlights selectable object's presentation with display mode in presentation manager with given highlight style. //! Highlights selectable object's presentation with display mode in presentation manager with
//! Also a check for auto-highlight is performed - if selectable object manages highlighting on its own, //! given highlight style. Also a check for auto-highlight is performed - if selectable object
//! execution will be passed to SelectMgr_SelectableObject::HilightOwnerWithColor method. //! manages highlighting on its own, execution will be passed to
Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager)& thePrsMgr, //! SelectMgr_SelectableObject::HilightOwnerWithColor method.
const Handle(Prs3d_Drawer)& theStyle, Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode) Standard_OVERRIDE; const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Always update dynamic highlighting. //! Always update dynamic highlighting.
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE; Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
}; };
#endif // _AIS_LightSource_HeaderFile #endif // _AIS_LightSource_HeaderFile

View File

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

View File

@@ -29,40 +29,43 @@ class AIS_Line : public AIS_InteractiveObject
{ {
DEFINE_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject) DEFINE_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject)
public: public:
//! Initializes the line aLine. //! Initializes the line aLine.
Standard_EXPORT AIS_Line(const Handle(Geom_Line)& aLine); Standard_EXPORT AIS_Line(const Handle(Geom_Line)& aLine);
//! Initializes a starting point aStartPoint //! Initializes a starting point aStartPoint
//! and a finishing point aEndPoint for the line. //! and a finishing point aEndPoint for the line.
Standard_EXPORT AIS_Line(const Handle(Geom_Point)& aStartPoint, const Handle(Geom_Point)& aEndPoint); Standard_EXPORT AIS_Line(const Handle(Geom_Point)& aStartPoint,
const Handle(Geom_Point)& aEndPoint);
//! Returns the signature 5. //! Returns the signature 5.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 5; } virtual Standard_Integer Signature() const Standard_OVERRIDE { return 5; }
//! Returns the type Datum. //! Returns the type Datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; } virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Constructs an infinite line. //! Constructs an infinite line.
const Handle(Geom_Line)& Line() const { return myComponent; } const Handle(Geom_Line)& Line() const { return myComponent; }
//! Returns the starting point thePStart and the end point thePEnd of the line set by SetPoints. //! Returns the starting point thePStart and the end point thePEnd of the line set by SetPoints.
void Points (Handle(Geom_Point)& thePStart, Handle(Geom_Point)& thePEnd) const void Points(Handle(Geom_Point)& thePStart, Handle(Geom_Point)& thePEnd) const
{ {
thePStart = myStartPoint; thePStart = myStartPoint;
thePEnd = myEndPoint; thePEnd = myEndPoint;
} }
//! instantiates an infinite line. //! instantiates an infinite line.
void SetLine (const Handle(Geom_Line)& theLine) void SetLine(const Handle(Geom_Line)& theLine)
{ {
myComponent = theLine; myComponent = theLine;
myLineIsSegment = Standard_False; myLineIsSegment = Standard_False;
} }
//! Sets the starting point thePStart and ending point thePEnd of the //! Sets the starting point thePStart and ending point thePEnd of the
//! infinite line to create a finite line segment. //! infinite line to create a finite line segment.
void SetPoints (const Handle(Geom_Point)& thePStart, const Handle(Geom_Point)& thePEnd) void SetPoints(const Handle(Geom_Point)& thePStart, const Handle(Geom_Point)& thePEnd)
{ {
myStartPoint = thePStart; myStartPoint = thePStart;
myEndPoint = thePEnd; myEndPoint = thePEnd;
@@ -70,11 +73,11 @@ public:
} }
//! Provides a new color setting aColor for the line in the drawing tool, or "Drawer". //! Provides a new color setting aColor for the line in the drawing tool, or "Drawer".
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE; Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
//! Provides the new width setting aValue for the line in //! Provides the new width setting aValue for the line in
//! the drawing tool, or "Drawer". //! the drawing tool, or "Drawer".
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE; Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Removes the color setting and returns the original color. //! Removes the color setting and returns the original color.
Standard_EXPORT void UnsetColor() Standard_OVERRIDE; Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
@@ -83,31 +86,28 @@ public:
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE; Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private: private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode) Standard_OVERRIDE;
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, Standard_EXPORT void ComputeInfiniteLine(const Handle(Prs3d_Presentation)& aPresentation);
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeInfiniteLine (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeSegmentLine(const Handle(Prs3d_Presentation)& aPresentation);
Standard_EXPORT void ComputeSegmentLine (const Handle(Prs3d_Presentation)& aPresentation); Standard_EXPORT void ComputeInfiniteLineSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeInfiniteLineSelection (const Handle(SelectMgr_Selection)& aSelection); Standard_EXPORT void ComputeSegmentLineSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeSegmentLineSelection (const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value. //! Replace aspects of already computed groups with the new value.
void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect); void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private: private:
Handle(Geom_Line) myComponent;
Handle(Geom_Line) myComponent;
Handle(Geom_Point) myStartPoint; Handle(Geom_Point) myStartPoint;
Handle(Geom_Point) myEndPoint; Handle(Geom_Point) myEndPoint;
Standard_Boolean myLineIsSegment; Standard_Boolean myLineIsSegment;
}; };
DEFINE_STANDARD_HANDLE(AIS_Line, AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(AIS_Line, AIS_InteractiveObject)

View File

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

View File

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

File diff suppressed because it is too large Load Diff

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