init OpenCAX Src

This commit is contained in:
JackLee 2026-02-21 00:28:54 +08:00
parent d215190f0e
commit 5f83b9c4c4
7392 changed files with 676629 additions and 0 deletions

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
/.appanalyzer

10
AppScope/app.json5 Normal file
View File

@ -0,0 +1,10 @@
{
"app": {
"bundleName": "com.example.opencax",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:layered_image",
"label": "$string:app_name"
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "OpenCAX"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,7 @@
{
"layered-image":
{
"background" : "$media:background",
"foreground" : "$media:foreground"
}
}

43
build-profile.json5 Normal file
View File

@ -0,0 +1,43 @@
{
"app": {
"signingConfigs": [],
"products": [
{
"name": "default",
"signingConfig": "default",
"targetSdkVersion": "6.0.2(22)",
"compatibleSdkVersion": "6.0.2(22)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"nativeCompiler": "BiSheng",
"strictMode": {
"caseSensitiveCheck": true,
"useNormalizedOHMUrl": true
}
}
}
],
"buildModeSet": [
{
"name": "debug",
},
{
"name": "release"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

32
code-linter.json5 Normal file
View File

@ -0,0 +1,32 @@
{
"files": [
"**/*.ets"
],
"ignore": [
"**/src/ohosTest/**/*",
"**/src/test/**/*",
"**/src/mock/**/*",
"**/node_modules/**/*",
"**/oh_modules/**/*",
"**/build/**/*",
"**/.preview/**/*"
],
"ruleSet": [
"plugin:@performance/recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@security/no-unsafe-aes": "error",
"@security/no-unsafe-hash": "error",
"@security/no-unsafe-mac": "warn",
"@security/no-unsafe-dh": "error",
"@security/no-unsafe-dsa": "error",
"@security/no-unsafe-ecdsa": "error",
"@security/no-unsafe-rsa-encrypt": "error",
"@security/no-unsafe-rsa-sign": "error",
"@security/no-unsafe-rsa-key": "error",
"@security/no-unsafe-dsa-key": "error",
"@security/no-unsafe-dh-key": "error",
"@security/no-unsafe-3des": "error"
}
}

6
entry/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

55
entry/build-profile.json5 Normal file
View File

@ -0,0 +1,55 @@
{
"apiType": "stageMode",
"buildOption": {
"resOptions": {
"copyCodeResource": {
"enable": false
}
},
"externalNativeOptions": {
"path": "./src/main/cpp/CMakeLists.txt",
"arguments": "-DOHOS_STL=c++_shared",
"cppFlags": "",
"abiFilters": [
"x86_64"
]
},
"arkOptions": {
"runtimeOnly" : {
"packages": [
"libocctrender.so"
]
}
}
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
"nativeLib": {
"debugSymbol": {
"strip": true,
"exclude": []
}
}
},
],
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}

6
entry/hvigorfile.ts Normal file
View File

@ -0,0 +1,6 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
entry/libs/x86_64/libz.so.1 Normal file

Binary file not shown.

View File

@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation

View File

@ -0,0 +1,19 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"libocctrender.so@src/main/cpp/types/libocctrender": "libocctrender.so@src/main/cpp/types/libocctrender"
},
"packages": {
"libocctrender.so@src/main/cpp/types/libocctrender": {
"name": "libocctrender.so",
"version": "1.0.0",
"resolved": "src/main/cpp/types/libocctrender",
"registryType": "local"
}
}
}

11
entry/oh-package.json5 Normal file
View File

@ -0,0 +1,11 @@
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"libocctrender.so": "file:./src/main/cpp/types/libocctrender"
}
}

View File

@ -0,0 +1,86 @@
# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(OpenCAX)
set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DOHOS_PLATFORM)
#if(DEFINED PACKAGE_FIND_FILE)
# include(${PACKAGE_FIND_FILE})
#endif()
# NAPI
include_directories(${NATIVERENDER_ROOT_PATH}
${NATIVERENDER_ROOT_PATH}/include
${NATIVERENDER_ROOT_PATH}/include/opencascade
)
# OCCT
set(OCCT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH})
set(OCCT_LIBS
${OCCT_LIB_DIR}/libTKernel.so.7.9
${OCCT_LIB_DIR}/libTKBRep.so.7.9
${OCCT_LIB_DIR}/libTKOpenGles.so.7.9
${OCCT_LIB_DIR}/libTKMath.so.7.9
${OCCT_LIB_DIR}/libTKG2d.so.7.9
${OCCT_LIB_DIR}/libTKG3d.so.7.9
${OCCT_LIB_DIR}/libTKGeomBase.so.7.9
${OCCT_LIB_DIR}/libTKGeomAlgo.so.7.9
${OCCT_LIB_DIR}/libTKTopAlgo.so.7.9
${OCCT_LIB_DIR}/libTKMesh.so.7.9
${OCCT_LIB_DIR}/libTKService.so.7.9
${OCCT_LIB_DIR}/libTKV3d.so.7.9
${OCCT_LIB_DIR}/libTKXCAF.so.7.9
${OCCT_LIB_DIR}/libTKCAF.so.7.9
${OCCT_LIB_DIR}/libTKLCAF.so.7.9
${OCCT_LIB_DIR}/libTKCDF.so.7.9
${OCCT_LIB_DIR}/libTKFillet.so.7.9
${OCCT_LIB_DIR}/libTKDESTEP.so.7.9
${OCCT_LIB_DIR}/libTKShHealing.so.7.9
${OCCT_LIB_DIR}/libTKHLR.so.7.9
${OCCT_LIB_DIR}/libTKVCAF.so.7.9
${OCCT_LIB_DIR}/libTKBO.so.7.9
${OCCT_LIB_DIR}/libTKPrim.so.7.9
${OCCT_LIB_DIR}/libTKBool.so.7.9
${OCCT_LIB_DIR}/libTKDE.so.7.9
${OCCT_LIB_DIR}/libTKXSBase.so.7.9
${OCCT_LIB_DIR}/libfreetype.so.6
${OCCT_LIB_DIR}/libfontconfig.so.1
${OCCT_LIB_DIR}/libexpat.so.1
${OCCT_LIB_DIR}/libz.so.1
${OCCT_LIB_DIR}/libbz2.so.1.0
${OCCT_LIB_DIR}/libpng16.so.16
${OCCT_LIB_DIR}/libbrotlicommon.so.1
${OCCT_LIB_DIR}/libbrotlidec.so.1
${OCCT_LIB_DIR}/libbrotlienc.so.1
)
#
add_library(occtrender SHARED
napi_init.cpp
#Header
EGLCore/EGLCore.h
OCCTRender/OCCTRender.h
OCCTRenderThread/OCCTRenderThread.h
#Cpp Src
EGLCore/EGLCore.cpp
OCCTRender/OCCTRender.cpp
OCCTRenderThread/OCCTRenderThread.cpp
)
find_library(EGL-lib EGL)
find_library(GLES-lib GLESv3)
find_library(hilog-lib hilog_ndk.z)
find_library(libace-lib ace_ndk.z)
find_library(libuv-lib uv)
target_link_libraries(occtrender PUBLIC
#EGL Hilog
${EGL-lib}
${GLES-lib}
${hilog-lib}
${libace-lib}
${libuv-lib}
libnative_window.so
libace_napi.z.so
)
target_link_libraries(occtrender PUBLIC ${OCCT_LIBS})

View File

@ -0,0 +1,74 @@
//
// Created on 2026/2/18.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
#include "EGLCore.h"
#include <GLES3/gl3.h>
#include <iostream>
EGLCore::EGLCore() : m_display(EGL_NO_DISPLAY), m_context(EGL_NO_CONTEXT), m_surface(EGL_NO_SURFACE) {}
EGLCore::~EGLCore() {
release();
}
bool EGLCore::init(EGLNativeWindowType window) {
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (m_display == EGL_NO_DISPLAY) return false;
if (!eglInitialize(m_display, nullptr, nullptr)) return false;
const EGLint attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 16,
EGL_NONE
};
EGLConfig config;
EGLint numConfigs;
eglChooseConfig(m_display, attribs, &config, 1, &numConfigs);
const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE
};
m_context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttribs);
if (m_context == EGL_NO_CONTEXT) return false;
m_surface = eglCreateWindowSurface(m_display, config, window, nullptr);
if (m_surface == EGL_NO_SURFACE) return false;
m_initialized = true;
return true;
}
void EGLCore::makeCurrent() {
if (m_initialized) {
eglMakeCurrent(m_display, m_surface, m_surface, m_context);
}
}
void EGLCore::swapBuffers() {
if (m_initialized) {
eglSwapBuffers(m_display, m_surface);
}
}
void EGLCore::release() {
if (m_display != EGL_NO_DISPLAY) {
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (m_context != EGL_NO_CONTEXT) eglDestroyContext(m_display, m_context);
if (m_surface != EGL_NO_SURFACE) eglDestroySurface(m_display, m_surface);
eglTerminate(m_display);
}
m_display = EGL_NO_DISPLAY;
m_context = EGL_NO_CONTEXT;
m_surface = EGL_NO_SURFACE;
m_initialized = false;
}

View File

@ -0,0 +1,29 @@
//
// Created on 2026/2/18.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
#ifndef EGLCORE_H
#define EGLCORE_H
#include <EGL/egl.h>
#include <EGL/eglext.h>
class EGLCore {
public:
EGLCore();
~EGLCore();
bool init(EGLNativeWindowType window);
void makeCurrent();
void swapBuffers();
void release();
private:
EGLDisplay m_display;
EGLContext m_context;
EGLSurface m_surface;
bool m_initialized = false;
};
#endif // EGLCORE_H

View File

@ -0,0 +1,94 @@
//
// Created on 2026/2/18.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
#include "OCCTRender.h"
#include <GLES3/gl3.h> // ← 提供 glViewport, glClear 等
#include <EGL/egl.h>
// OCCT 基础
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <TDF_LabelSequence.hxx>
// XCAF 应用框架
#include <XCAFApp_Application.hxx>
#include <XCAFDoc_DocumentTool.hxx> // ← 解决当前错误
#include <XCAFDoc_ShapeTool.hxx> // ← 配套使用
// STEP 导入
#include <STEPCAFControl_Reader.hxx>
#include <IFSelect_ReturnStatus.hxx>
// 可视化
#include <AIS_Shape.hxx>
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
OCCTRender::OCCTRender(int width, int height)
: m_width(width), m_height(height)
{
// 创建一个“虚拟”的 DisplayConnectionHarmonyOS 无 X11/Wayland
Handle(Aspect_DisplayConnection) aDispConnection;
// 关键:设置 OpenGl_GraphicDriver 复用当前 OpenGL context
// 第二个参数 'theIsOwnsContext' 设为 false表示不创建新 context
Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver(aDispConnection, false);
m_viewer = new V3d_Viewer(aDriver);
m_view = m_viewer->CreateView();
m_context = new AIS_InteractiveContext(m_viewer);
m_view->SetBackgroundColor(Quantity_NOC_BLACK);
m_view->Camera()->SetProjectionType(Graphic3d_Camera::Projection_Perspective);
m_view->SetImmediateUpdate(false); // 禁用自动 redraw/swap
}
OCCTRender::~OCCTRender() {
// OCCT 对象由 Handle 自动管理,通常无需手动 delete
}
void OCCTRender::render()
{
if (m_width <= 0 || m_height <= 0) return;
// 设置 OpenGL viewport由 EGLCore 控制 surface此处仅设置视口
glViewport(0, 0, m_width, m_height);
// 更新相机宽高比
m_view->Camera()->SetAspect(static_cast<Standard_Real>(m_width) / m_height);
// 让 OCCT 渲染到当前 OpenGL context 的 default framebuffer
m_view->Redraw();
// 注意:不要调用 RedrawImmediate(),也不要 swap buffer由 EGLCore 负责)
}
void OCCTRender::loadModel(const char* stepPath) {
m_context->RemoveAll(false);
auto app = XCAFApp_Application::GetApplication();
m_doc = new TDocStd_Document("XmlXCAF"); // ← 关键修改
app->NewDocument("XmlXCAF", m_doc); // ← 保持一致
STEPCAFControl_Reader reader;
IFSelect_ReturnStatus status = reader.ReadFile(stepPath);
if (status == IFSelect_RetDone) {
reader.Transfer(m_doc);
Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(m_doc->Main());
if (!shapeTool.IsNull()) {
TDF_LabelSequence labels;
shapeTool->GetFreeShapes(labels);
for (Standard_Integer i = 1; i <= labels.Length(); ++i) {
TopoDS_Shape shape;
if (shapeTool->GetShape(labels.Value(i), shape)) {
Handle(AIS_Shape) aisShape = new AIS_Shape(shape);
m_context->Display(aisShape, false);
}
}
}
}
m_view->FitAll();
}
void OCCTRender::rotateCamera(float deltaX, float deltaY) {
m_view->Rotate(deltaX * 0.01f, deltaY * 0.01f, 0.0f, true); // 相对旋转
}

View File

@ -0,0 +1,44 @@
//
// Created on 2026/2/18.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
/*
* Copyright (c) 2026 Your Company. All rights reserved.
* Description: OCCT rendering logic encapsulation.
*/
#ifndef OCCT_RENDER_H
#define OCCT_RENDER_H
#include <Graphic3d_GraphicDriver.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <XCAFApp_Application.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <TDocStd_Document.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <AIS_Shape.hxx>
class OCCTRender {
public:
OCCTRender(int width, int height); // 保持接口不变
~OCCTRender();
void loadModel(const char* stepPath);
void render();
void updateSize(int width, int height);
void rotateCamera(float deltaX, float deltaY);
private:
Handle(V3d_Viewer) m_viewer;
Handle(V3d_View) m_view;
Handle(AIS_InteractiveContext) m_context;
Handle(TDocStd_Document) m_doc;
int m_width;
int m_height;
};
#endif // OCCT_RENDER_H

View File

@ -0,0 +1,73 @@
//
// Created on 2026/2/18.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
#include "OCCTRenderThread.h"
#include <unistd.h> // for usleep
OCCTRenderThread::OCCTRenderThread(EGLNativeWindowType window, int width, int height)
: m_window(window), m_width(width), m_height(height) {}
OCCTRenderThread::~OCCTRenderThread() {
stop();
delete m_occtRender;
}
void OCCTRenderThread::start() {
m_running = true;
m_thread = std::thread(&OCCTRenderThread::renderLoop, this);
}
void OCCTRenderThread::stop() {
m_running = false;
if (m_thread.joinable()) {
m_thread.join();
}
}
void OCCTRenderThread::loadModel(const char* path) {
std::lock_guard<std::mutex> lock(m_mutex);
m_pendingModelPath = std::string(path);
m_hasPendingModel = true;
}
void OCCTRenderThread::onMouseEvent(float dx, float dy) {
m_deltaX += dx;
m_deltaY += dy;
m_hasMouseInput = true;
}
void OCCTRenderThread::renderLoop() {
if (!m_eglCore.init(m_window)) {
return;
}
m_occtRender = new OCCTRender(m_width, m_height);
while (m_running) {
m_eglCore.makeCurrent();
// Handle model loading
if (m_hasPendingModel) {
std::lock_guard<std::mutex> lock(m_mutex);
m_occtRender->loadModel(m_pendingModelPath.c_str());
m_hasPendingModel = false;
}
// Handle mouse rotation
if (m_hasMouseInput.exchange(false)) {
m_occtRender->rotateCamera(m_deltaX, m_deltaY);
m_deltaX = m_deltaY = 0.0f;
}
m_occtRender->render();
m_eglCore.swapBuffers();
usleep(16000); // ~60 FPS
}
delete m_occtRender;
m_occtRender = nullptr;
m_eglCore.release();
}

View File

@ -0,0 +1,45 @@
//
// Created on 2026/2/18.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".
#ifndef OCCT_RENDER_THREAD_H
#define OCCT_RENDER_THREAD_H
#include <thread>
#include <atomic>
#include <mutex>
#include "EGLCore/EGLCore.h"
#include "OCCTRender/OCCTRender.h"
class OCCTRenderThread {
public:
OCCTRenderThread(EGLNativeWindowType window, int width, int height);
~OCCTRenderThread();
void start();
void stop();
void loadModel(const char* path);
void onMouseEvent(float dx, float dy);
private:
void renderLoop();
std::thread m_thread;
std::atomic<bool> m_running{false};
EGLNativeWindowType m_window;
int m_width, m_height;
EGLCore m_eglCore;
OCCTRender* m_occtRender = nullptr;
std::mutex m_mutex;
std::string m_pendingModelPath;
std::atomic<bool> m_hasPendingModel{false};
float m_deltaX = 0.0f, m_deltaY = 0.0f;
std::atomic<bool> m_hasMouseInput{false};
};
#endif //OCCT_RENDER_THREAD_H

View File

@ -0,0 +1,12 @@
按照下面要求生成实现代码:
1-HarmonyOS API 版本:22
2-OpenGL ES 版本:3.0
3-OCCT 版本:7.9.3
4-分别用类名字为EGLCore OCCTRenderThread OCCTRender实现
5-实现主线程和渲染线程分离.渲染线程循环渲染
6-实现通过loadmodel加载step文件进行渲染step模型
7-实现鼠标旋转相机观察渲染的模型.
8-Arkui通过XComponent的Native进行调用实现.
9-不得使用android的实现代码.使用鸿蒙原生API实现
10-在napi_init.cpp文件中写出给arkui调用的函数.包括回调函数
11-在Index.d.ts文件中写出暴露给arkui调用的代码

View File

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

View File

@ -0,0 +1,22 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AngleDimension_HeaderFile
#define _AIS_AngleDimension_HeaderFile
#include "PrsDim_AngleDimension.hxx"
Standard_DEPRECATED("Deprecated alias to moved class")
typedef PrsDim_AngleDimension AIS_AngleDimension;
#endif // _AIS_AngleDimension_HeaderFile

View File

@ -0,0 +1,219 @@
// Created by: Anastasia BORISOVA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_Animation_HeaderFile
#define _AIS_Animation_HeaderFile
#include "AIS_AnimationTimer.hxx"
#include "NCollection_Sequence.hxx"
#include "TCollection_AsciiString.hxx"
//! Structure defining current animation progress.
struct AIS_AnimationProgress
{
Standard_Real Pts; //!< global presentation timestamp
Standard_Real LocalPts; //!< presentation within current animation
// clang-format off
Standard_Real LocalNormalized; //!< normalized position within current animation within 0..1 range
// clang-format on
AIS_AnimationProgress()
: Pts(-1.0),
LocalPts(-1.0),
LocalNormalized(-1.0)
{
}
};
DEFINE_STANDARD_HANDLE(AIS_Animation, Standard_Transient)
//! Class represents a basic animation class.
//! AIS_Animation can be used as:
//!
//! - Animation Implementor
//! Sub-classes should override method AIS_Animation::update() to perform specific animation.
//! AIS package provides limited number of such animation atoms - classes AIS_AnimationObject and
//! AIS_AnimationCamera, which could be enough for defining a simple animation. In general case,
//! application is expected defining own AIS_Animation sub-classes implementing
//! application-specific animation logic (e.g. another interpolation or another kind of
//! transformations - like color transition and others). The basic conception of
//! AIS_Animation::update() is defining an exact scene state for the current presentation
//! timestamp, providing a smooth and continuous animation well defined at any time step and in
//! any direction. So that a time difference between two sequential drawn Viewer frames can vary
//! from frame to frame without visual artifacts, increasing rendering framerate would not lead to
//! animation being executed too fast and low framerate (on slow hardware) would not lead to
//! animation played longer than defined duration. Hence, implementation should avoid usage of
//! incremental step logic or should apply it very carefully.
//!
//! - Animation Container
//! AIS_Animation (no sub-classing) can be used to aggregate a sequence of Animation items
//! (children). Each children should be defined with its own duration and start time (presentation
//! timestamp). It is possible defining collection of nested AIS_Animation items, so that within
//! each container level children define start playback time relative to its holder.
//!
//! - Animation playback Controller
//! It is suggested that application would define a single AIS_Animation instance (optional
//! sub-classing) for controlling animation playback as whole. Such controller should be filled in
//! by other AIS_Animation as children objects, and will be managed by application by calling
//! StartTimer(), UpdateTimer() and IsStopped() methods.
//!
//! Note, that AIS_Animation::StartTimer() defines a timer calculating an elapsed time, not a
//! multimedia timer executing Viewer updates at specific intervals! Application should avoid using
//! implicit and immediate Viewer updates to ensure that AIS_Animation::UpdateTimer() is called
//! before each redrawing of a Viewer content. Redrawing logic should be also managed at application
//! level for managing a smooth animation (by defining a multimedia timer provided by used GUI
//! framework executing updates at desired framerate, or as continuous redraws in loop).
class AIS_Animation : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
public:
//! Creates empty animation.
Standard_EXPORT AIS_Animation(const TCollection_AsciiString& theAnimationName);
//! Destruct object, clear arguments
Standard_EXPORT virtual ~AIS_Animation();
//! Animation name.
const TCollection_AsciiString& Name() const { return myName; }
public:
//! @return start time of the animation in the timeline
Standard_Real StartPts() const { return myPtsStart; }
//! Sets time limits for animation in the animation timeline
void SetStartPts(const Standard_Real thePtsStart) { myPtsStart = thePtsStart; }
//! @return duration of the animation in the timeline
Standard_Real Duration() const { return Max(myOwnDuration, myChildrenDuration); }
//! Update total duration considering all animations on timeline.
Standard_EXPORT void UpdateTotalDuration();
//! Return true if duration is defined.
Standard_Boolean HasOwnDuration() const { return myOwnDuration > 0.0; }
//! @return own duration of the animation in the timeline
Standard_Real OwnDuration() const { return myOwnDuration; }
//! Defines duration of the animation.
void SetOwnDuration(const Standard_Real theDuration) { myOwnDuration = theDuration; }
//! Add single animation to the timeline.
//! @param theAnimation input animation
Standard_EXPORT void Add(const Handle(AIS_Animation)& theAnimation);
//! Clear animation timeline - remove all animations from it.
Standard_EXPORT void Clear();
//! Return the child animation with the given name.
Standard_EXPORT Handle(AIS_Animation) Find(const TCollection_AsciiString& theAnimationName) const;
//! Remove the child animation.
Standard_EXPORT Standard_Boolean Remove(const Handle(AIS_Animation)& theAnimation);
//! Replace the child animation.
Standard_EXPORT Standard_Boolean Replace(const Handle(AIS_Animation)& theAnimationOld,
const Handle(AIS_Animation)& theAnimationNew);
//! Clears own children and then copy child animations from another object.
//! Copy also Start Time and Duration values.
Standard_EXPORT void CopyFrom(const Handle(AIS_Animation)& theOther);
//! Return sequence of child animations.
const NCollection_Sequence<Handle(AIS_Animation)>& Children() const { return myAnimations; }
public:
//! Start animation with internally defined timer instance.
//! Calls ::Start() internally.
//!
//! Note, that this method initializes a timer calculating an elapsed time (presentation
//! timestamps within AIS_Animation::UpdateTimer()), not a multimedia timer executing Viewer
//! updates at specific intervals! Viewer redrawing should be managed at application level, so
//! that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer
//! content.
//!
//! @param theStartPts starting timer position (presentation timestamp)
//! @param thePlaySpeed playback speed (1.0 means normal speed)
//! @param theToUpdate flag to update defined animations to specified start position
//! @param theToStopTimer flag to pause timer at the starting position
Standard_EXPORT virtual void StartTimer(const Standard_Real theStartPts,
const Standard_Real thePlaySpeed,
const Standard_Boolean theToUpdate,
const Standard_Boolean theToStopTimer = Standard_False);
//! Update single frame of animation, update timer state
//! @return current time of timeline progress.
Standard_EXPORT virtual Standard_Real UpdateTimer();
//! Return elapsed time.
Standard_Real ElapsedTime() const { return !myTimer.IsNull() ? myTimer->ElapsedTime() : 0.0; }
//! Return playback timer.
const Handle(Media_Timer)& Timer() const { return myTimer; }
//! Set playback timer.
void SetTimer(const Handle(Media_Timer)& theTimer) { myTimer = theTimer; }
public:
//! Start animation. This method changes status of the animation to Started.
//! This status defines whether animation is to be performed in the timeline or not.
//! @param theToUpdate call Update() method
Standard_EXPORT virtual void Start(const Standard_Boolean theToUpdate);
//! Pause the process timeline.
Standard_EXPORT virtual void Pause();
//! Stop animation. This method changed status of the animation to Stopped.
//! This status shows that animation will not be performed in the timeline or it is finished.
Standard_EXPORT virtual void Stop();
//! Check if animation is to be performed in the animation timeline.
//! @return True if it is stopped of finished.
bool IsStopped() { return myState != AnimationState_Started; }
//! Update single frame of animation, update timer state
//! @param[in] thePts the time moment within [0; Duration()]
//! @return True if timeline is in progress
Standard_EXPORT virtual Standard_Boolean Update(const Standard_Real thePts);
protected:
//! Process one step of the animation according to the input time progress, including all
//! children. Calls also ::update() to update own animation.
Standard_EXPORT virtual void updateWithChildren(const AIS_AnimationProgress& thePosition);
//! Update the own animation to specified position - should be overridden by sub-class.
virtual void update(const AIS_AnimationProgress& theProgress) { (void)theProgress; }
protected:
//! Defines animation state.
enum AnimationState
{
AnimationState_Started, //!< animation is in progress
AnimationState_Stopped, //!< animation is finished, force stopped or not started
AnimationState_Paused //!< animation is paused and can be started from the pause moment
};
protected:
Handle(Media_Timer) myTimer;
TCollection_AsciiString myName; //!< animation name
NCollection_Sequence<Handle(AIS_Animation)> myAnimations; //!< sequence of child animations
AnimationState myState; //!< animation state - started, stopped of paused
Standard_Real myPtsStart; //!< time of start in the timeline
Standard_Real myOwnDuration; //!< duration of animation excluding children
Standard_Real myChildrenDuration; //!< duration of animation including children
};
#endif // _AIS_Animation_HeaderFile

View File

@ -0,0 +1,49 @@
// Copyright (c) 2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AnimationAxisRotation_HeaderFile
#define _AIS_AnimationAxisRotation_HeaderFile
#include "AIS_BaseAnimationObject.hxx"
#include "gp_TrsfNLerp.hxx"
//! Animation defining object transformation.
class AIS_AnimationAxisRotation : public AIS_BaseAnimationObject
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
public:
//! Constructor with initialization.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply rotation
//! @param[in] theAxis rotation axis
//! @param[in] theAngleStart rotation angle at the start of animation
//! @param[in] theAngleEnd rotation angle at the end of animation
Standard_EXPORT AIS_AnimationAxisRotation(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
const gp_Ax1& theAxis,
const Standard_Real theAngleStart,
const Standard_Real theAngleEnd);
protected:
//! Update the progress.
Standard_EXPORT virtual void update(const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
gp_Ax1 myRotAxis; //!< rotation axis
Standard_Real myAngleStart; //!< start angle for rotation
Standard_Real myAngleEnd; //!< end angle for rotation
};
#endif // _AIS_AnimationAxisRotation_HeaderFile

View File

@ -0,0 +1,65 @@
// Created by: Anastasia BORISOVA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AnimationCamera_HeaderFile
#define _AIS_AnimationCamera_HeaderFile
#include "AIS_Animation.hxx"
class Graphic3d_Camera;
class V3d_View;
//! Camera animation.
class AIS_AnimationCamera : public AIS_Animation
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
public:
//! Main constructor.
Standard_EXPORT AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
const Handle(V3d_View)& theView);
//! Return the target view.
const Handle(V3d_View)& View() const { return myView; }
//! Set target view.
void SetView(const Handle(V3d_View)& theView) { myView = theView; }
//! Return camera start position.
const Handle(Graphic3d_Camera)& CameraStart() const { return myCamStart; }
//! Define camera start position.
void SetCameraStart(const Handle(Graphic3d_Camera)& theCameraStart)
{
myCamStart = theCameraStart;
}
//! Return camera end position.
const Handle(Graphic3d_Camera)& CameraEnd() const { return myCamEnd; }
//! Define camera end position.
void SetCameraEnd(const Handle(Graphic3d_Camera)& theCameraEnd) { myCamEnd = theCameraEnd; }
protected:
//! Update the progress.
Standard_EXPORT virtual void update(const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
protected:
Handle(V3d_View) myView; //!< view to setup camera
Handle(Graphic3d_Camera) myCamStart; //!< starting camera position
Handle(Graphic3d_Camera) myCamEnd; //!< end camera position
};
DEFINE_STANDARD_HANDLE(AIS_AnimationCamera, AIS_Animation)
#endif // _AIS_AnimationCamera_HeaderFile

View File

@ -0,0 +1,49 @@
// Created by: Anastasia BORISOVA
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AnimationObject_HeaderFile
#define _AIS_AnimationObject_HeaderFile
#include "AIS_BaseAnimationObject.hxx"
#include "gp_TrsfNLerp.hxx"
//! Animation defining object transformation.
class AIS_AnimationObject : public AIS_BaseAnimationObject
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
public:
//! Constructor with initialization.
//! Note that start/end transformations specify exactly local transformation of the object,
//! not the transformation to be applied to existing local transformation.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply local transformation
//! @param[in] theTrsfStart local transformation at the start of animation (e.g.
//! theObject->LocalTransformation())
//! @param[in] theTrsfEnd local transformation at the end of animation
Standard_EXPORT AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
const gp_Trsf& theTrsfStart,
const gp_Trsf& theTrsfEnd);
protected:
//! Update the progress.
Standard_EXPORT virtual void update(const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
gp_TrsfNLerp myTrsfLerp; //!< interpolation tool
};
#endif // _AIS_AnimationObject_HeaderFile

View File

@ -0,0 +1,21 @@
// Created by: Kirill Gavrilov
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AnimationTimer_HeaderFile
#define _AIS_AnimationTimer_HeaderFile
#include "Media_Timer.hxx"
typedef Media_Timer AIS_AnimationTimer;
#endif // _AIS_AnimationTimer_HeaderFile

View File

@ -0,0 +1,106 @@
// Created on: 1997-03-04
// Created by: Robert COUBLANC
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_AttributeFilter_HeaderFile
#define _AIS_AttributeFilter_HeaderFile
#include "Standard.hxx"
#include "Standard_Type.hxx"
#include "Quantity_NameOfColor.hxx"
#include "Standard_Real.hxx"
#include "SelectMgr_Filter.hxx"
class SelectMgr_EntityOwner;
class AIS_AttributeFilter;
DEFINE_STANDARD_HANDLE(AIS_AttributeFilter, SelectMgr_Filter)
//! Selects Interactive Objects, which have the desired width or color.
//! The filter questions each Interactive Object in local
//! context to determine whether it has an non-null
//! owner, and if so, whether it has the required color
//! and width attributes. If the object returns true in each
//! case, it is kept. If not, it is rejected.
//! This filter is used only in an open local context.
//! In the Collector viewer, you can only locate
//! Interactive Objects, which answer positively to the
//! filters, which are in position when a local context is open.
class AIS_AttributeFilter : public SelectMgr_Filter
{
public:
//! Constructs an empty attribute filter object.
//! This filter object determines whether selectable
//! interactive objects have a non-null owner.
Standard_EXPORT AIS_AttributeFilter();
//! Constructs an attribute filter object defined by the
//! color attribute aCol.
Standard_EXPORT AIS_AttributeFilter(const Quantity_NameOfColor aCol);
//! Constructs an attribute filter object defined by the line
//! width attribute aWidth.
Standard_EXPORT AIS_AttributeFilter(const Standard_Real aWidth);
//! Indicates that the Interactive Object has the color
//! setting specified by the argument aCol at construction time.
Standard_Boolean HasColor() const { return hasC; }
//! Indicates that the Interactive Object has the width
//! setting specified by the argument aWidth at
//! construction time.
Standard_Boolean HasWidth() const { return hasW; }
//! Sets the color.
void SetColor(const Quantity_NameOfColor theCol)
{
myCol = theCol;
hasC = Standard_True;
}
//! Sets the line width.
void SetWidth(const Standard_Real theWidth)
{
myWid = theWidth;
hasW = Standard_True;
}
//! Removes the setting for color from the filter.
void UnsetColor() { hasC = Standard_False; }
//! Removes the setting for width from the filter.
void UnsetWidth() { hasW = Standard_False; }
//! Indicates that the selected Interactive Object passes
//! the filter. The owner, anObj, can be either direct or
//! user. A direct owner is the corresponding
//! construction element, whereas a user is the
//! compound shape of which the entity forms a part.
//! If the Interactive Object returns Standard_True
//! when detected by the Local Context selector through
//! the mouse, the object is kept; if not, it is rejected.
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
private:
Quantity_NameOfColor myCol;
Standard_Real myWid;
Standard_Boolean hasC;
Standard_Boolean hasW;
};
#endif // _AIS_AttributeFilter_HeaderFile

View File

@ -0,0 +1,137 @@
// Created on: 1995-08-09
// Created by: Arnaud BOUZY/Odile Olivier
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_Axis_HeaderFile
#define _AIS_Axis_HeaderFile
#include "AIS_InteractiveObject.hxx"
#include "AIS_TypeOfAxis.hxx"
#include "gp_Dir.hxx"
#include "gp_Pnt.hxx"
#include "SelectMgr_Selection.hxx"
class Geom_Line;
class Geom_Axis1Placement;
class Geom_Axis2Placement;
class Prs3d_LineAspect;
//! Locates the x, y and z axes in an Interactive Object.
//! These are used to orient it correctly in presentations
//! from different viewpoints, or to construct a revolved
//! shape, for example, from one of the axes. Conversely,
//! an axis can be created to build a revolved shape and
//! then situated relative to one of the axes of the view.
class AIS_Axis : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
public:
//! Initializes the line aComponent
Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent);
//! initializes the axis2 position
//! aComponent. The coordinate system used is right-handed.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
//! Initializes the axis1 position anAxis.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis);
//! Initializes the ray as axis with start point and direction
//! @param[in] theAxis Start point and direction of the ray
//! @param[in] theLength Optional length of the ray (ray is infinite by default).
Standard_EXPORT AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength = -1);
//! Returns the axis entity aComponent and identifies it
//! as a component of a shape.
const Handle(Geom_Line)& Component() const { return myComponent; }
//! Sets the coordinates of the lin aComponent.
Standard_EXPORT void SetComponent(const Handle(Geom_Line)& aComponent);
//! Returns the position of axis2 and positions it by
//! identifying it as the x, y, or z axis and giving its
//! direction in 3D space. The coordinate system used is right-handed.
const Handle(Geom_Axis2Placement)& Axis2Placement() const { return myAx2; }
//! Allows you to provide settings for aComponent:the
//! position and direction of an axis in 3D space. The
//! coordinate system used is right-handed.
Standard_EXPORT void SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
//! Constructs a new line to serve as the axis anAxis in 3D space.
Standard_EXPORT void SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis);
//! Returns the type of axis.
AIS_TypeOfAxis TypeOfAxis() const { return myTypeOfAxis; }
//! Constructs the entity theTypeAxis to stock information
//! concerning type of axis.
void SetTypeOfAxis(const AIS_TypeOfAxis theTypeAxis) { myTypeOfAxis = theTypeAxis; }
//! Returns a signature of 2 for axis datums. When you
//! activate mode 2 by a signature, you pick AIS objects
//! of type AIS_Axis.
Standard_Boolean IsXYZAxis() const { return myIsXYZAxis; }
//! Returns true if the interactive object accepts the display mode aMode.
Standard_EXPORT Standard_Boolean
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 2; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Set required visualization parameters.
Standard_EXPORT void SetDisplayAspect(const Handle(Prs3d_LineAspect)& theNewDatumAspect);
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeFields();
private:
Handle(Geom_Line) myComponent;
Handle(Geom_Axis2Placement) myAx2;
gp_Pnt myPfirst;
gp_Pnt myPlast;
AIS_TypeOfAxis myTypeOfAxis;
Standard_Boolean myIsXYZAxis;
gp_Dir myDir;
Standard_Real myVal;
Standard_CString myText;
Handle(Prs3d_LineAspect) myLineAspect;
};
DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject)
#endif // _AIS_Axis_HeaderFile

View File

@ -0,0 +1,66 @@
// Created on: 1998-03-04
// Created by: Julia Gerasimova
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_BadEdgeFilter_HeaderFile
#define _AIS_BadEdgeFilter_HeaderFile
#include "Standard.hxx"
#include "TopTools_DataMapOfIntegerListOfShape.hxx"
#include "Standard_Integer.hxx"
#include "SelectMgr_Filter.hxx"
#include "TopAbs_ShapeEnum.hxx"
class SelectMgr_EntityOwner;
class TopoDS_Edge;
class AIS_BadEdgeFilter;
DEFINE_STANDARD_HANDLE(AIS_BadEdgeFilter, SelectMgr_Filter)
//! A Class
class AIS_BadEdgeFilter : public SelectMgr_Filter
{
public:
//! Constructs an empty filter object for bad edges.
Standard_EXPORT AIS_BadEdgeFilter();
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
Standard_OVERRIDE;
//! sets <myContour> with current contour. used by
//! IsOk.
Standard_EXPORT void SetContour(const Standard_Integer Index);
//! Adds an edge to the list of non-selectionnable
//! edges.
Standard_EXPORT void AddEdge(const TopoDS_Edge& anEdge, const Standard_Integer Index);
//! removes from the list of non-selectionnable edges
//! all edges in the contour <Index>.
Standard_EXPORT void RemoveEdges(const Standard_Integer Index);
DEFINE_STANDARD_RTTIEXT(AIS_BadEdgeFilter, SelectMgr_Filter)
protected:
private:
TopTools_DataMapOfIntegerListOfShape myBadEdges;
Standard_Integer myContour;
};
#endif // _AIS_BadEdgeFilter_HeaderFile

View File

@ -0,0 +1,45 @@
// Copyright (c) 2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_BaseAnimationObject_HeaderFile
#define _AIS_BaseAnimationObject_HeaderFile
#include "AIS_Animation.hxx"
#include "AIS_InteractiveContext.hxx"
//! Animation defining object transformation.
class AIS_BaseAnimationObject : public AIS_Animation
{
DEFINE_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
protected:
//! Constructor with initialization.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply local transformation
Standard_EXPORT AIS_BaseAnimationObject(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject);
//! Update the transformation.
Standard_EXPORT void updateTrsf(const gp_Trsf& theTrsf);
private:
//! Invalidate the viewer for proper update.
Standard_EXPORT void invalidateViewer();
protected:
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
};
#endif // _AIS_BaseAnimationObject_HeaderFile

View File

@ -0,0 +1,50 @@
// Created on: 1998-02-04
// Created by: Julia GERASIMOVA
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_C0RegularityFilter_HeaderFile
#define _AIS_C0RegularityFilter_HeaderFile
#include "Standard.hxx"
#include "TopTools_MapOfShape.hxx"
#include "SelectMgr_Filter.hxx"
#include "TopAbs_ShapeEnum.hxx"
class TopoDS_Shape;
class SelectMgr_EntityOwner;
class AIS_C0RegularityFilter;
DEFINE_STANDARD_HANDLE(AIS_C0RegularityFilter, SelectMgr_Filter)
class AIS_C0RegularityFilter : public SelectMgr_Filter
{
public:
Standard_EXPORT AIS_C0RegularityFilter(const TopoDS_Shape& aShape);
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter, SelectMgr_Filter)
protected:
private:
TopTools_MapOfShape myMapOfEdges;
};
#endif // _AIS_C0RegularityFilter_HeaderFile

View File

@ -0,0 +1,80 @@
// Created on: 2018-12-12
// Created by: Olga SURYANINOVA
// Copyright (c) 2018 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_CameraFrustum_HeaderFile
#define _AIS_CameraFrustum_HeaderFile
#include "AIS_InteractiveObject.hxx"
class Graphic3d_ArrayOfSegments;
class Graphic3d_ArrayOfTriangles;
//! Presentation for drawing camera frustum.
//! Default configuration is built with filling and some transparency.
class AIS_CameraFrustum : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
public:
//! Selection modes supported by this object
enum SelectionMode
{
SelectionMode_Edges = 0, //!< detect by edges (default)
SelectionMode_Volume = 1, //!< detect by volume
};
public:
//! Constructs camera frustum with default configuration.
Standard_EXPORT AIS_CameraFrustum();
//! Sets camera frustum.
Standard_EXPORT void SetCameraFrustum(const Handle(Graphic3d_Camera)& theCamera);
//! Setup custom color.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
//! Restore default color.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
//! Restore transparency setting.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
//! Return true if specified display mode is supported.
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const
Standard_OVERRIDE;
protected:
//! Computes presentation of camera frustum.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection.
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
private:
//! Fills triangles primitive array for camera frustum filling.
void fillTriangles();
//! Fills polylines primitive array for camera frustum borders.
void fillBorders();
protected:
NCollection_Array1<Graphic3d_Vec3d> myPoints; //!< Array of points
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for camera frustum filling
Handle(Graphic3d_ArrayOfSegments) myBorders; //!< Segments for camera frustum borders
};
#endif // _AIS_CameraFrustum_HeaderFile

View File

@ -0,0 +1,22 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_Chamf2dDimension_HeaderFile
#define _AIS_Chamf2dDimension_HeaderFile
#include "PrsDim_Chamf2dDimension.hxx"
Standard_DEPRECATED("Alias to moved class")
typedef PrsDim_Chamf2dDimension AIS_Chamf2dDimension;
#endif // _AIS_Chamf2dDimension_HeaderFile

View File

@ -0,0 +1,22 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_Chamf3dDimension_HeaderFile
#define _AIS_Chamf3dDimension_HeaderFile
#include "PrsDim_Chamf3dDimension.hxx"
Standard_DEPRECATED("Alias to moved class")
typedef PrsDim_Chamf3dDimension AIS_Chamf3dDimension;
#endif // _AIS_Chamf3dDimension_HeaderFile

View File

@ -0,0 +1,130 @@
// Created on: 1997-01-21
// Created by: Prestataire Christiane ARMAND
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_Circle_HeaderFile
#define _AIS_Circle_HeaderFile
#include "AIS_InteractiveObject.hxx"
class Geom_Circle;
//! Constructs circle datums to be used in construction of
//! composite shapes.
class AIS_Circle : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
public:
//! Initializes this algorithm for constructing AIS circle
//! datums initializes the circle aCircle
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle);
//! Initializes this algorithm for constructing AIS circle datums.
//! Initializes the circle theCircle, the arc
//! starting point theUStart, the arc ending point theUEnd,
//! and the type of sensitivity theIsFilledCircleSens.
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle,
const Standard_Real theUStart,
const Standard_Real theUEnd,
const Standard_Boolean theIsFilledCircleSens = Standard_False);
//! Returns index 6 by default.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; }
//! Indicates that the type of Interactive Object is a datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Returns the circle component defined in SetCircle.
const Handle(Geom_Circle)& Circle() const { return myComponent; }
//! Constructs instances of the starting point and the end
//! point parameters, theU1 and theU2.
void Parameters(Standard_Real& theU1, Standard_Real& theU2) const
{
theU1 = myUStart;
theU2 = myUEnd;
}
//! Allows you to provide settings for the circle datum aCircle.
void SetCircle(const Handle(Geom_Circle)& theCircle) { myComponent = theCircle; }
//! Allows you to set the parameter theU for the starting point of an arc.
void SetFirstParam(const Standard_Real theU)
{
myUStart = theU;
myCircleIsArc = Standard_True;
}
//! Allows you to provide the parameter theU for the end point of an arc.
void SetLastParam(const Standard_Real theU)
{
myUEnd = theU;
myCircleIsArc = Standard_True;
}
Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
//! Assigns the width aValue to the solid line boundary of the circle datum.
Standard_EXPORT void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
//! Removes color from the solid line boundary of the circle datum.
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
//! Removes width settings from the solid line boundary of the circle datum.
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
//! Returns the type of sensitivity for the circle;
Standard_Boolean IsFilledCircleSens() const { return myIsFilledCircleSens; }
//! Sets the type of sensitivity for the circle. If theIsFilledCircleSens set to Standard_True
//! then the whole circle will be detectable, otherwise only the boundary of the circle.
void SetFilledCircleSens(const Standard_Boolean theIsFilledCircleSens)
{
myIsFilledCircleSens = theIsFilledCircleSens;
}
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 ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
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 ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection);
Standard_EXPORT void ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection);
//! Replace aspects of already computed groups with the new value.
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private:
Handle(Geom_Circle) myComponent;
Standard_Real myUStart;
Standard_Real myUEnd;
Standard_Boolean myCircleIsArc;
Standard_Boolean myIsFilledCircleSens;
};
DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject)
#endif // _AIS_Circle_HeaderFile

View File

@ -0,0 +1,518 @@
// Created on: 2015-02-03
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_ColorScale_HeaderFile
#define _AIS_ColorScale_HeaderFile
#include "AIS_InteractiveObject.hxx"
#include "Aspect_TypeOfColorScaleData.hxx"
#include "Aspect_TypeOfColorScalePosition.hxx"
#include "Aspect_SequenceOfColor.hxx"
#include "Standard.hxx"
#include "Standard_DefineHandle.hxx"
#include "TCollection_ExtendedString.hxx"
#include "TColStd_SequenceOfExtendedString.hxx"
class AIS_ColorScale;
DEFINE_STANDARD_HANDLE(AIS_ColorScale, AIS_InteractiveObject)
//! Class for drawing a custom color scale.
//!
//! The color scale consists of rectangular color bar (composed of fixed
//! number of color intervals), optional labels, and title.
//! The labels can be positioned either at the boundaries of the intervals,
//! or at the middle of each interval.
//! Colors and labels can be either defined automatically or set by the user.
//! Automatic labels are calculated from numerical limits of the scale,
//! its type (logarithmic or plain), and formatted by specified format string.
class AIS_ColorScale : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject)
public:
//! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
const Standard_Integer theColorsCount,
const Graphic3d_Vec3d& theColorHlsMin,
const Graphic3d_Vec3d& theColorHlsMax,
Quantity_Color& theColor);
//! Calculate color according passed value; returns true if value is in range or false, if isn't
static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
const Standard_Integer theColorsCount,
Quantity_Color& theColor)
{
return FindColor(theValue,
theMin,
theMax,
theColorsCount,
Graphic3d_Vec3d(230.0, 1.0, 1.0),
Graphic3d_Vec3d(0.0, 1.0, 1.0),
theColor);
}
//! Shift hue into valid range.
//! Lightness and Saturation should be specified in valid range [0.0, 1.0],
//! however Hue might be given out of Quantity_Color range to specify desired range for
//! interpolation.
static Standard_Real hueToValidRange(const Standard_Real theHue)
{
Standard_Real aHue = theHue;
while (aHue < 0.0)
{
aHue += 360.0;
}
while (aHue > 360.0)
{
aHue -= 360.0;
}
return aHue;
}
public:
//! Default constructor.
Standard_EXPORT AIS_ColorScale();
//! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT Standard_Boolean FindColor(const Standard_Real theValue,
Quantity_Color& theColor) const;
//! Returns minimal value of color scale, 0.0 by default.
Standard_Real GetMin() const { return myMin; }
//! Sets the minimal value of color scale.
void SetMin(const Standard_Real theMin) { SetRange(theMin, GetMax()); }
//! Returns maximal value of color scale, 1.0 by default.
Standard_Real GetMax() const { return myMax; }
//! Sets the maximal value of color scale.
void SetMax(const Standard_Real theMax) { SetRange(GetMin(), theMax); }
//! Returns minimal and maximal values of color scale, 0.0 to 1.0 by default.
void GetRange(Standard_Real& theMin, Standard_Real& theMax) const
{
theMin = myMin;
theMax = myMax;
}
//! Sets the minimal and maximal value of color scale.
//! Note that values order will be ignored - the minimum and maximum values will be swapped if
//! needed.
//! ::SetReversed() should be called to swap displaying order.
Standard_EXPORT void SetRange(const Standard_Real theMin, const Standard_Real theMax);
//! Returns the hue angle corresponding to minimum value, 230 by default (blue).
Standard_Real HueMin() const { return myColorHlsMin[0]; }
//! Returns the hue angle corresponding to maximum value, 0 by default (red).
Standard_Real HueMax() const { return myColorHlsMax[0]; }
//! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default
//! (blue to red).
void HueRange(Standard_Real& theMinAngle, Standard_Real& theMaxAngle) const
{
theMinAngle = myColorHlsMin[0];
theMaxAngle = myColorHlsMax[0];
}
//! Sets hue angle range corresponding to minimum and maximum values.
//! The valid angle range is [0, 360], see Quantity_Color and Quantity_TOC_HLS for more details.
void SetHueRange(const Standard_Real theMinAngle, const Standard_Real theMaxAngle)
{
myColorHlsMin[0] = theMinAngle;
myColorHlsMax[0] = theMaxAngle;
}
//! Returns color range corresponding to minimum and maximum values, blue to red by default.
void ColorRange(Quantity_Color& theMinColor, Quantity_Color& theMaxColor) const
{
theMinColor.SetValues(hueToValidRange(myColorHlsMin[0]),
myColorHlsMin[1],
myColorHlsMin[2],
Quantity_TOC_HLS);
theMaxColor.SetValues(hueToValidRange(myColorHlsMax[0]),
myColorHlsMax[1],
myColorHlsMax[2],
Quantity_TOC_HLS);
}
//! Sets color range corresponding to minimum and maximum values.
void SetColorRange(const Quantity_Color& theMinColor, const Quantity_Color& theMaxColor)
{
theMinColor.Values(myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
theMaxColor.Values(myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
}
//! Returns the type of labels, Aspect_TOCSD_AUTO by default.
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals
//! Aspect_TOCSD_USER - user specified label is used
Aspect_TypeOfColorScaleData GetLabelType() const { return myLabelType; }
//! Sets the type of labels.
//! Aspect_TOCSD_AUTO - labels as boundary values for intervals
//! Aspect_TOCSD_USER - user specified label is used
void SetLabelType(const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; }
//! Returns the type of colors, Aspect_TOCSD_AUTO by default.
//! Aspect_TOCSD_AUTO - value between Red and Blue
//! Aspect_TOCSD_USER - user specified color from color map
Aspect_TypeOfColorScaleData GetColorType() const { return myColorType; }
//! Sets the type of colors.
//! Aspect_TOCSD_AUTO - value between Red and Blue
//! Aspect_TOCSD_USER - user specified color from color map
void SetColorType(const Aspect_TypeOfColorScaleData theType) { myColorType = theType; }
//! Returns the number of color scale intervals, 10 by default.
Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; }
//! Sets the number of color scale intervals.
Standard_EXPORT void SetNumberOfIntervals(const Standard_Integer theNum);
//! Returns the color scale title string, empty string by default.
const TCollection_ExtendedString& GetTitle() const { return myTitle; }
//! Sets the color scale title string.
void SetTitle(const TCollection_ExtendedString& theTitle) { myTitle = theTitle; }
//! Returns the format for numbers, "%.4g" by default.
//! The same like format for function printf().
//! Used if GetLabelType() is TOCSD_AUTO;
const TCollection_AsciiString& GetFormat() const { return myFormat; }
//! Returns the format of text.
const TCollection_AsciiString& Format() const { return myFormat; }
//! Sets the color scale auto label format specification.
void SetFormat(const TCollection_AsciiString& theFormat) { myFormat = theFormat; }
//! Returns the user specified label with index theIndex.
//! Index is in range from 1 to GetNumberOfIntervals() or to
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true.
//! Returns empty string if label not defined.
Standard_EXPORT TCollection_ExtendedString GetLabel(const Standard_Integer theIndex) const;
//! Returns the user specified color from color map with index (starts at 1).
//! Returns default color if index is out of range in color map.
Standard_EXPORT Quantity_Color GetIntervalColor(const Standard_Integer theIndex) const;
//! Sets the color of the specified interval.
//! Note that list is automatically resized to include specified index.
//! @param theColor color value to set
//! @param theIndex index in range [1, GetNumberOfIntervals()];
//! appended to the end of list if -1 is specified
Standard_EXPORT void SetIntervalColor(const Quantity_Color& theColor,
const Standard_Integer theIndex);
//! Returns the user specified labels.
Standard_EXPORT void GetLabels(TColStd_SequenceOfExtendedString& theLabels) const;
//! Returns the user specified labels.
const TColStd_SequenceOfExtendedString& Labels() const { return myLabels; }
//! Sets the color scale labels.
//! The length of the sequence should be equal to GetNumberOfIntervals() or to
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. If length of the sequence does not
//! much the number of intervals, then these labels will be considered as "free" and will be
//! located at the virtual intervals corresponding to the number of labels (with flag
//! IsLabelAtBorder() having the same effect as in normal case).
Standard_EXPORT void SetLabels(const TColStd_SequenceOfExtendedString& theSeq);
//! Returns the user specified colors.
Standard_EXPORT void GetColors(Aspect_SequenceOfColor& theColors) const;
//! Returns the user specified colors.
const Aspect_SequenceOfColor& GetColors() const { return myColors; }
//! Sets the color scale colors.
//! The length of the sequence should be equal to GetNumberOfIntervals().
Standard_EXPORT void SetColors(const Aspect_SequenceOfColor& theSeq);
//! Populates colors scale by colors of the same lightness value in CIE Lch
//! color space, distributed by hue, with perceptually uniform differences
//! between consequent colors.
//! See MakeUniformColors() for description of parameters.
void SetUniformColors(Standard_Real theLightness,
Standard_Real theHueFrom,
Standard_Real theHueTo)
{
SetColors(MakeUniformColors(myNbIntervals, theLightness, theHueFrom, theHueTo));
SetColorType(Aspect_TOCSD_USER);
}
//! Generates sequence of colors of the same lightness value in CIE Lch
//! color space (see #Quantity_TOC_CIELch), with hue values in the specified range.
//! The colors are distributed across the range such as to have perceptually
//! same difference between neighbour colors.
//! For each color, maximal chroma value fitting in sRGB gamut is used.
//!
//! @param theNbColors - number of colors to generate
//! @param theLightness - lightness to be used (0 is black, 100 is white, 32 is
//! lightness of pure blue)
//! @param theHueFrom - hue value at the start of the scale
//! @param theHueTo - hue value defining the end of the scale
//!
//! Hue value can be out of the range [0, 360], interpreted as modulo 360.
//! The colors of the scale will be in the order of increasing hue if
//! theHueTo > theHueFrom, and decreasing otherwise.
Standard_EXPORT static Aspect_SequenceOfColor MakeUniformColors(Standard_Integer theNbColors,
Standard_Real theLightness,
Standard_Real theHueFrom,
Standard_Real theHueTo);
//! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by
//! default.
Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; }
//! Sets the color scale labels position relative to color bar.
void SetLabelPosition(const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; }
//! Returns the position of color scale title, Aspect_TOCSP_LEFT by default.
Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; }
//! Sets the color scale title position.
Standard_DEPRECATED("AIS_ColorScale::SetTitlePosition() has no effect!")
void SetTitlePosition(const Aspect_TypeOfColorScalePosition thePos) { myTitlePos = thePos; }
//! 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.
//! - Reversed, top-down order with Maximum value on the Bottom and Minimum value on Top.
Standard_Boolean IsReversed() const { return myIsReversed; }
//! Sets true if the labels and colors used in reversed order.
void SetReversed(const Standard_Boolean theReverse) { myIsReversed = theReverse; }
//! Return TRUE if color transition between neighbor intervals
//! should be linearly interpolated, FALSE by default.
Standard_Boolean IsSmoothTransition() const { return myIsSmooth; }
//! Setup smooth color transition.
void SetSmoothTransition(const Standard_Boolean theIsSmooth) { myIsSmooth = theIsSmooth; }
//! 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:
//! - value connecting two neighbor intervals (TRUE)
//! - value in the middle of interval (FALSE)
Standard_Boolean IsLabelAtBorder() const { return myIsLabelAtBorder; }
//! Sets true if the labels are placed at border of color intervals (TRUE by default).
//! If set to False, labels will be drawn at color intervals rather than at borders.
void SetLabelAtBorder(const Standard_Boolean theOn) { myIsLabelAtBorder = theOn; }
//! Returns TRUE if the color scale has logarithmic intervals, FALSE by default.
Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; }
//! Sets true if the color scale has logarithmic intervals.
void SetLogarithmic(const Standard_Boolean isLogarithmic) { myIsLogarithmic = isLogarithmic; }
//! Sets the color scale label at index.
//! Note that list is automatically resized to include specified index.
//! @param theLabel new label text
//! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1]
//! if IsLabelAtBorder() is true;
//! 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);
//! Returns the size of color bar, 0 and 0 by default
//! (e.g. should be set by user explicitly before displaying).
void GetSize(Standard_Integer& theBreadth, Standard_Integer& theHeight) const
{
theBreadth = myBreadth;
theHeight = myHeight;
}
//! Sets the size of color bar.
void SetSize(const Standard_Integer theBreadth, const Standard_Integer theHeight)
{
myBreadth = theBreadth;
myHeight = theHeight;
}
//! Returns the breadth of color bar, 0 by default
//! (e.g. should be set by user explicitly before displaying).
Standard_Integer GetBreadth() const { return myBreadth; }
//! Sets the width of color bar.
void SetBreadth(const Standard_Integer theBreadth) { myBreadth = theBreadth; }
//! Returns the height of color bar, 0 by default
//! (e.g. should be set by user explicitly before displaying).
Standard_Integer GetHeight() const { return myHeight; }
//! Sets the height of color bar.
void SetHeight(const Standard_Integer theHeight) { myHeight = theHeight; }
//! Returns the bottom-left position of color scale, 0x0 by default.
void GetPosition(Standard_Real& theX, Standard_Real& theY) const
{
theX = myXPos;
theY = myYPos;
}
//! Sets the position of color scale.
void SetPosition(const Standard_Integer theX, const Standard_Integer theY)
{
myXPos = theX;
myYPos = theY;
}
//! Returns the left position of color scale, 0 by default.
Standard_Integer GetXPosition() const { return myXPos; }
//! Sets the left position of color scale.
void SetXPosition(const Standard_Integer theX) { myXPos = theX; }
//! Returns the bottom position of color scale, 0 by default.
Standard_Integer GetYPosition() const { return myYPos; }
//! Sets the bottom position of color scale.
void SetYPosition(const Standard_Integer theY) { myYPos = theY; }
//! Returns the font height of text labels, 20 by default.
Standard_Integer GetTextHeight() const { return myTextHeight; }
//! Sets the height of text of color scale.
void SetTextHeight(const Standard_Integer theHeight) { myTextHeight = theHeight; }
public:
//! Returns the width of text.
//! @param[in] theText the text of which to calculate width.
Standard_EXPORT Standard_Integer TextWidth(const TCollection_ExtendedString& theText) const;
//! Returns the height of text.
//! @param[in] theText the text of which to calculate height.
Standard_EXPORT Standard_Integer TextHeight(const TCollection_ExtendedString& theText) const;
Standard_EXPORT void TextSize(const TCollection_ExtendedString& theText,
const Standard_Integer theHeight,
Standard_Integer& theWidth,
Standard_Integer& theAscent,
Standard_Integer& theDescent) const;
public:
//! Return true if specified display mode is supported.
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0;
}
//! Compute presentation.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection - not implemented for color scale.
virtual void ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/) Standard_OVERRIDE
{
}
private:
//! Returns the size of color scale.
//! @param[out] theWidth the width of color scale.
//! @param[out] theHeight the height of color scale.
void SizeHint(Standard_Integer& theWidth, Standard_Integer& theHeight) const;
//! Returns the upper value of given interval, or minimum for theIndex = 0.
Standard_Real GetIntervalValue(const Standard_Integer theIndex) const;
//! Returns the color for the given value in the given interval.
//! @param[in] theValue the current value of interval
//! @param[in] theMin the min value of interval
//! @param[in] theMax the max value of interval
Quantity_Color colorFromValue(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax) const;
//! Initialize text aspect for drawing the labels.
void updateTextAspect();
//! Simple alias for Prs3d_Text::Draw().
//! @param[in] theGroup presentation group
//! @param[in] theText text to draw
//! @param[in] theX X coordinate of text position
//! @param[in] theY Y coordinate of text position
//! @param[in] theVertAlignment text vertical alignment
void drawText(const Handle(Graphic3d_Group)& theGroup,
const TCollection_ExtendedString& theText,
const Standard_Integer theX,
const Standard_Integer theY,
const Graphic3d_VerticalTextAlignment theVertAlignment);
//! Determine the maximum text label width in pixels.
Standard_Integer computeMaxLabelWidth(const TColStd_SequenceOfExtendedString& theLabels) const;
//! Draw labels.
void drawLabels(const Handle(Graphic3d_Group)& theGroup,
const TColStd_SequenceOfExtendedString& theLabels,
const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight,
const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth);
//! Draw a color bar.
void drawColorBar(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight,
const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth);
//! Draw a frame.
//! @param[in] theX the X coordinate of frame position.
//! @param[in] theY the Y coordinate of frame position.
//! @param[in] theWidth the width of frame.
//! @param[in] theHeight the height of frame.
//! @param[in] theColor the color of frame.
void drawFrame(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Quantity_Color& theColor);
private:
Standard_Real myMin; //!< values range - minimal value
Standard_Real myMax; //!< values range - maximal value
// clang-format off
Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value
Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value
TCollection_ExtendedString myTitle; //!< optional title string
TCollection_AsciiString myFormat; //!< sprintf() format for generating label from value
Standard_Integer myNbIntervals; //!< number of intervals
Aspect_TypeOfColorScaleData myColorType; //!< color type
Aspect_TypeOfColorScaleData myLabelType; //!< label type
Standard_Boolean myIsLabelAtBorder; //!< at border
Standard_Boolean myIsReversed; //!< flag indicating reversed order
Standard_Boolean myIsLogarithmic; //!< flag indicating logarithmic scale
Standard_Boolean myIsSmooth; //!< flag indicating smooth transition between the colors
Aspect_SequenceOfColor myColors; //!< sequence of custom colors
TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels
Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale
// clang-format on
Aspect_TypeOfColorScalePosition myTitlePos; //!< title position
Standard_Integer myXPos; //!< left position
Standard_Integer myYPos; //!< bottom position
Standard_Integer myBreadth; //!< color scale breadth
Standard_Integer myHeight; //!< height of the color scale
Standard_Integer mySpacing; //!< extra spacing between element
Standard_Integer myTextHeight; //!< label font height
};
#endif

View File

@ -0,0 +1,74 @@
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_ColoredDrawer_HeaderFile
#define _AIS_ColoredDrawer_HeaderFile
#include "Prs3d_Drawer.hxx"
#include "Quantity_Color.hxx"
//! Customizable properties.
class AIS_ColoredDrawer : public Prs3d_Drawer
{
DEFINE_STANDARD_RTTIEXT(AIS_ColoredDrawer, Prs3d_Drawer)
public:
//! Default constructor.
AIS_ColoredDrawer(const Handle(Prs3d_Drawer)& theLink)
: myIsHidden(false),
myHasOwnMaterial(false),
myHasOwnColor(false),
myHasOwnTransp(false),
myHasOwnWidth(false)
{
Link(theLink);
}
bool IsHidden() const { return myIsHidden; }
void SetHidden(const bool theToHide) { myIsHidden = theToHide; }
bool HasOwnMaterial() const { return myHasOwnMaterial; }
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
void SetOwnMaterial() { myHasOwnMaterial = true; }
bool HasOwnColor() const { return myHasOwnColor; }
void UnsetOwnColor() { myHasOwnColor = false; }
void SetOwnColor(const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
bool HasOwnTransparency() const { return myHasOwnTransp; }
void UnsetOwnTransparency() { myHasOwnTransp = false; }
void SetOwnTransparency(Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
bool HasOwnWidth() const { return myHasOwnWidth; }
void UnsetOwnWidth() { myHasOwnWidth = false; }
void SetOwnWidth(const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
public: //! @name list of overridden properties
bool myIsHidden;
bool myHasOwnMaterial;
bool myHasOwnColor;
bool myHasOwnTransp;
bool myHasOwnWidth;
};
DEFINE_STANDARD_HANDLE(AIS_ColoredDrawer, Prs3d_Drawer)
#endif // _AIS_ColoredDrawer_HeaderFile

View File

@ -0,0 +1,180 @@
// Created on: 2014-04-24
// Created by: Kirill Gavrilov
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_ColoredShape_HeaderFile
#define _AIS_ColoredShape_HeaderFile
#include "AIS_DataMapOfShapeDrawer.hxx"
#include "AIS_Shape.hxx"
#include "NCollection_IndexedDataMap.hxx"
#include "TopoDS_Compound.hxx"
#include "TopTools_MapOfShape.hxx"
class StdSelect_BRepOwner;
//! Presentation of the shape with customizable sub-shapes properties.
class AIS_ColoredShape : public AIS_Shape
{
public:
//! Default constructor
Standard_EXPORT AIS_ColoredShape(const TopoDS_Shape& theShape);
//! Copy constructor
Standard_EXPORT AIS_ColoredShape(const Handle(AIS_Shape)& theShape);
public: //! @name sub-shape aspects
//! Customize properties of specified sub-shape.
//! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape!
//! This method can be used to mark sub-shapes with customizable properties.
Standard_EXPORT virtual Handle(AIS_ColoredDrawer) CustomAspects(const TopoDS_Shape& theShape);
//! Reset the map of custom sub-shape aspects.
Standard_EXPORT virtual void ClearCustomAspects();
//! Reset custom properties of specified sub-shape.
//! @param theToUnregister unregister or not sub-shape from the map
Standard_EXPORT void UnsetCustomAspects(const TopoDS_Shape& theShape,
const Standard_Boolean theToUnregister = Standard_False);
//! Customize color of specified sub-shape
Standard_EXPORT void SetCustomColor(const TopoDS_Shape& theShape, const Quantity_Color& theColor);
//! Customize transparency of specified sub-shape
Standard_EXPORT void SetCustomTransparency(const TopoDS_Shape& theShape,
Standard_Real theTransparency);
//! Customize line width of specified sub-shape
Standard_EXPORT void SetCustomWidth(const TopoDS_Shape& theShape,
const Standard_Real theLineWidth);
//! Return the map of custom aspects.
const AIS_DataMapOfShapeDrawer& CustomAspectsMap() const { return myShapeColors; }
//! Return the map of custom aspects.
AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; }
public: //! @name global aspects
//! Setup color of entire shape.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
//! Setup line width of entire shape.
Standard_EXPORT virtual void SetWidth(const Standard_Real theLineWidth) Standard_OVERRIDE;
//! Sets transparency value.
Standard_EXPORT virtual void SetTransparency(const Standard_Real theValue) Standard_OVERRIDE;
//! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theAspect)
Standard_OVERRIDE;
public:
//! Removes the setting for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
//! Setup line width of entire shape.
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
protected: //! @name override presentation computation
//! Compute presentation considering sub-shape color map.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection considering sub-shape hidden state.
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
protected:
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound>
DataMapOfDrawerCompd;
protected:
//! Recursive function to map shapes.
//! @param theParentDrawer the drawer to be used for undetailed shapes (default colors)
//! @param theShapeToParse the subshape to be recursively parsed
//! @param theShapeDrawerMap shapes map Subshape (in the base shape) -> Drawer
//! @param theParentType the parent subshape type
//! @param theIsParentClosed flag indicating that specified shape is part of closed Solid
//! @param theDrawerOpenedShapePerType the array of shape types to fill
//! @param theDrawerClosedFaces the map for closed faces
Standard_EXPORT static Standard_Boolean dispatchColors(
const Handle(AIS_ColoredDrawer)& theParentDrawer,
const TopoDS_Shape& theShapeToParse,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopAbs_ShapeEnum theParentType,
const Standard_Boolean theIsParentClosed,
DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
DataMapOfDrawerCompd& theDrawerClosedFaces);
protected:
//! Extract myShapeColors map (KeyshapeColored -> Color) to subshapes map (Subshape -> Color).
//! This needed when colored shape is not part of BaseShape (but subshapes are) and actually
//! container for subshapes.
Standard_EXPORT void fillSubshapeDrawerMap(AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const;
//! Add shape to presentation
//! @param thePrs the presentation
//! @param theDrawerOpenedShapePerType the shapes map with unique attributes
//! @param theDrawerClosedFaces the map of attributes for closed faces
//! @param theMode display mode
Standard_EXPORT void addShapesWithCustomProps(
const Handle(Prs3d_Presentation)& thePrs,
const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
const DataMapOfDrawerCompd& theDrawerClosedFaces,
const Standard_Integer theMode);
//! Check all shapes from myShapeColorsfor visibility
Standard_EXPORT Standard_Boolean isShapeEntirelyVisible() const;
//! Resolve (parse) theKeyShape into subshapes, search in they for theBaseShape,
//! bind all resolved subshapes with theOriginKeyShape and store all binds in theShapeDrawerMap
//! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape ->
//! theOriginKeyShape
//! @param theKeyShape a shape to be resolved (parse) into smaller (in topological sense)
//! subshapes for new bind cycle
//! @param theDrawer assigned drawer
Standard_EXPORT void bindSubShapes(AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theKeyShape,
const Handle(AIS_ColoredDrawer)& theDrawer) const;
//! Add sub-shape to selection considering hidden state (recursively).
//! @param theParentDrawer drawer of parent shape
//! @param theShapeDrawerMap shapes map
//! @param theShape shape to compute sensitive entities
//! @param theOwner selectable owner object
//! @param theSelection selection to append new sensitive entities
//! @param theTypOfSel type of selection
//! @param theDeflection linear deflection
//! @param theDeflAngle angular deflection
Standard_EXPORT void computeSubshapeSelection(const Handle(AIS_ColoredDrawer)& theParentDrawer,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theShape,
const Handle(StdSelect_BRepOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection,
const TopAbs_ShapeEnum theTypOfSel,
const Standard_Integer thePriority,
const Standard_Real theDeflection,
const Standard_Real theDeflAngle);
protected:
AIS_DataMapOfShapeDrawer myShapeColors;
public:
DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape, AIS_Shape)
};
DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape)
#endif // _AIS_ColoredShape_HeaderFile

View File

@ -0,0 +1,22 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_ConcentricRelation_HeaderFile
#define _AIS_ConcentricRelation_HeaderFile
#include "PrsDim_ConcentricRelation.hxx"
Standard_DEPRECATED("Alias to moved class")
typedef PrsDim_ConcentricRelation AIS_ConcentricRelation;
#endif // _AIS_ConcentricRelation_HeaderFile

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