Merge branch 'FreeCAD:main' into cleanmodPart
This commit is contained in:
@@ -80,6 +80,10 @@
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['src/Mod/Spreadsheet/**/*']
|
||||
|
||||
"Mod: Start":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['src/Mod/Start/**/*']
|
||||
|
||||
"Mod: Surface":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['src/Mod/Surface/**/*/']
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
steps:
|
||||
- name: '🧹 Tag & close stale unconfirmed bugs'
|
||||
id: stale_issues
|
||||
uses: actions/stale@v9.0.0
|
||||
uses: actions/stale@v9.1.0
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: -1
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
|
||||
- name: '🧹 Close stale requested feedback issues'
|
||||
id: awaiting_issues
|
||||
uses: actions/stale@v9.0.0
|
||||
uses: actions/stale@v9.1.0
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: -1
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
|
||||
- name: '🧹 Tag & close inactive issues'
|
||||
id: inactive_issues
|
||||
uses: actions/stale@v9.0.0
|
||||
uses: actions/stale@v9.1.0
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: -1
|
||||
@@ -108,7 +108,7 @@ jobs:
|
||||
|
||||
- name: '🧹 Tag & close inactive PRs'
|
||||
id: inactive_pr
|
||||
uses: actions/stale@v9.0.0
|
||||
uses: actions/stale@v9.1.0
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: -1
|
||||
|
||||
@@ -76,66 +76,8 @@ jobs:
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install FreeCAD dependencies
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
ccache \
|
||||
doxygen \
|
||||
graphviz \
|
||||
imagemagick \
|
||||
libboost-date-time-dev \
|
||||
libboost-dev \
|
||||
libboost-filesystem-dev \
|
||||
libboost-graph-dev \
|
||||
libboost-iostreams-dev \
|
||||
libboost-program-options-dev \
|
||||
libboost-python-dev \
|
||||
libboost-regex-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcoin-dev \
|
||||
libeigen3-dev \
|
||||
libkdtree++-dev \
|
||||
libmedc-dev \
|
||||
libocct-data-exchange-dev \
|
||||
libocct-ocaf-dev \
|
||||
libocct-visualization-dev \
|
||||
libopencv-dev \
|
||||
libproj-dev \
|
||||
libpyside2-dev \
|
||||
libqt5opengl5-dev \
|
||||
libqt5svg5-dev \
|
||||
libqt5x11extras5-dev \
|
||||
libshiboken2-dev \
|
||||
libspnav-dev \
|
||||
libvtk7-dev \
|
||||
libx11-dev \
|
||||
libxerces-c-dev \
|
||||
libyaml-cpp-dev \
|
||||
libzipios++-dev \
|
||||
netgen \
|
||||
netgen-headers \
|
||||
ninja-build \
|
||||
occt-draw \
|
||||
pyqt5-dev-tools \
|
||||
pyside2-tools \
|
||||
python3-dev \
|
||||
python3-git \
|
||||
python3-markdown \
|
||||
python3-matplotlib \
|
||||
python3-packaging \
|
||||
python3-pivy \
|
||||
python3-ply \
|
||||
python3-pyside2.qtcore \
|
||||
python3-pyside2.qtgui \
|
||||
python3-pyside2.qtnetwork \
|
||||
python3-pyside2.qtsvg \
|
||||
python3-pyside2.qtwidgets \
|
||||
qtbase5-dev \
|
||||
qttools5-dev \
|
||||
shiboken2 \
|
||||
swig \
|
||||
xvfb
|
||||
run: ./package/ubuntu/install-apt-packages.sh
|
||||
|
||||
- name: Make needed directories, files and initializations
|
||||
id: Init
|
||||
run: |
|
||||
|
||||
@@ -108,7 +108,7 @@ on:
|
||||
-readability/nolint,
|
||||
+readability/nul,
|
||||
+readability/strings,
|
||||
+readability/todo,
|
||||
-readability/todo,
|
||||
+readability/utf8,
|
||||
+runtime/arrays,
|
||||
+runtime/casting,
|
||||
|
||||
@@ -4,17 +4,13 @@
|
||||
# cMake find_package() call
|
||||
|
||||
find_package(PySide6 CONFIG QUIET)
|
||||
if(NOT PySide6_FOUND)
|
||||
if(NOT PySide6_INCLUDE_DIRS AND TARGET PySide6::pyside6)
|
||||
get_property(PySide6_INCLUDE_DIRS TARGET PySide6::pyside6 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
endif()
|
||||
|
||||
if(NOT PySide6_INCLUDE_DIRS)
|
||||
find_pip_package(PySide6)
|
||||
else()
|
||||
set(PySide6_FOUND ON)
|
||||
endif()
|
||||
if(NOT PySide6_INCLUDE_DIRS AND TARGET PySide6::pyside6)
|
||||
get_property(PySide6_INCLUDE_DIRS TARGET PySide6::pyside6 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
endif()
|
||||
|
||||
if(NOT PySide6_INCLUDE_DIRS)
|
||||
find_pip_package(PySide6)
|
||||
endif()
|
||||
|
||||
# Also provide the old-style variables so we don't have to update everything yet
|
||||
|
||||
@@ -48,6 +48,8 @@ macro(CompilerChecksAndSetups)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-fdiagnostics-color ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# For now only set pedantic option for clang
|
||||
if(CMAKE_COMPILER_IS_CLANGXX)
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wno-write-strings ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
@@ -13,6 +13,8 @@ macro(InitializeFreeCADBuildOptions)
|
||||
option(FREECAD_USE_FREETYPE "Builds the features using FreeType libs" ON)
|
||||
option(FREECAD_BUILD_DEBIAN "Prepare for a build of a Debian package" OFF)
|
||||
option(FREECAD_CHECK_PIVY "Check for pivy version using Python at build time" ON)
|
||||
option(FREECAD_PARALLEL_COMPILE_JOBS "Compilation jobs pool size to fit memory limitations.")
|
||||
option(FREECAD_PARALLEL_LINK_JOBS "Linkage jobs pool size to fit memory limitations.")
|
||||
option(BUILD_WITH_CONDA "Set ON if you build FreeCAD with conda" OFF)
|
||||
option(BUILD_DYNAMIC_LINK_PYTHON "If OFF extension-modules do not link against python-libraries" ON)
|
||||
option(INSTALL_TO_SITEPACKAGES "If ON the freecad root namespace (python) is installed into python's site-packages" ON)
|
||||
@@ -77,8 +79,6 @@ macro(InitializeFreeCADBuildOptions)
|
||||
"Community Edition"
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/QtOpenGL.h.cmake ${CMAKE_BINARY_DIR}/src/QtOpenGL.h)
|
||||
|
||||
option(BUILD_DESIGNER_PLUGIN "Build and install the designer plugin" OFF)
|
||||
|
||||
if(APPLE)
|
||||
@@ -208,4 +208,22 @@ macro(InitializeFreeCADBuildOptions)
|
||||
"Please choose another build directory! Or disable the option BUILD_FORCE_DIRECTORY.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FREECAD_PARALLEL_COMPILE_JOBS)
|
||||
if(CMAKE_GENERATOR MATCHES "Ninja")
|
||||
set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${FREECAD_PARALLEL_COMPILE_JOBS})
|
||||
set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
|
||||
else()
|
||||
message(WARNING "Job pooling is only available with Ninja generators.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FREECAD_PARALLEL_LINK_JOBS)
|
||||
if(CMAKE_GENERATOR MATCHES "Ninja")
|
||||
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${FREECAD_PARALLEL_LINK_JOBS})
|
||||
set(CMAKE_JOB_POOL_LINK link_job_pool)
|
||||
else()
|
||||
message(WARNING "Job pooling is only available with Ninja generators.")
|
||||
endif()
|
||||
endif()
|
||||
endmacro(InitializeFreeCADBuildOptions)
|
||||
|
||||
@@ -89,6 +89,8 @@ macro(PrintFinalReport)
|
||||
value(FREECAD_CREATE_MAC_APP)
|
||||
value(FREECAD_USE_PYBIND11)
|
||||
value(FREECAD_USE_EXTERNAL_KDL)
|
||||
value(FREECAD_USE_PYSIDE)
|
||||
value(FREECAD_USE_SHIBOKEN)
|
||||
value(BUILD_ADDONMGR)
|
||||
value(BUILD_BIM)
|
||||
value(BUILD_ASSEMBLY)
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
macro(SetupOpenGL)
|
||||
# -------------------------------- OpenGL --------------------------------
|
||||
|
||||
# If on a system with both a legacy GL library and GLVND, prefer the legacy library.
|
||||
# This is probably needed until we no longer have any gl.*ARB calls in the codebase
|
||||
# See, e.g. SoBrepFaceSet.cpp
|
||||
set(OpenGL_GL_PREFERENCE LEGACY)
|
||||
|
||||
find_package(OpenGL)
|
||||
include(FindPackageMessage)
|
||||
if(OPENGL_GLU_FOUND)
|
||||
|
||||
@@ -59,7 +59,7 @@ macro(SetupShibokenAndPyside)
|
||||
|
||||
find_package(PySide${PYSIDE_MAJOR_VERSION} QUIET)
|
||||
|
||||
if(${PYSIDE_MAJOR_VERSION} EQUAL 5)
|
||||
if(${PYSIDE_MAJOR_VERSION} EQUAL 2)
|
||||
# Our internal FindPySide6.cmake file already provides these for PySide6
|
||||
if(NOT PYSIDE_INCLUDE_DIR AND TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION})
|
||||
get_property(PYSIDE_INCLUDE_DIR TARGET PySide${PYSIDE_MAJOR_VERSION}::pyside${PYSIDE_MAJOR_VERSION} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
||||
@@ -156,13 +156,13 @@ macro(generate_from_py BASE_NAME)
|
||||
if(NOT EXISTS "${SOURCE_CPP_PATH}")
|
||||
# assures the source files are generated at least once
|
||||
message(STATUS "${SOURCE_CPP_PATH}")
|
||||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${TOOL_NATIVE_PATH}" --outputPath "${OUTPUT_NATIVE_PATH}" "${SOURCE_NATIVE_PATH}"
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" "${TOOL_NATIVE_PATH}" --outputPath "${OUTPUT_NATIVE_PATH}" "${SOURCE_NATIVE_PATH}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME}_.h" "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME}_.cpp"
|
||||
COMMAND ${PYTHON_EXECUTABLE} "${TOOL_NATIVE_PATH}" --outputPath "${OUTPUT_NATIVE_PATH}" ${BASE_NAME}.pyi
|
||||
COMMAND ${Python3_EXECUTABLE} "${TOOL_NATIVE_PATH}" --outputPath "${OUTPUT_NATIVE_PATH}" ${BASE_NAME}.pyi
|
||||
MAIN_DEPENDENCY "${BASE_NAME}.pyi"
|
||||
DEPENDS
|
||||
"${CMAKE_SOURCE_DIR}/src/Tools/bindings/templates/templateClassPyExport.py"
|
||||
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Update package lists quietly
|
||||
sudo apt-get update -qq
|
||||
|
||||
packages=(
|
||||
ccache
|
||||
doxygen
|
||||
graphviz
|
||||
imagemagick
|
||||
libboost-date-time-dev
|
||||
libboost-dev
|
||||
libboost-filesystem-dev
|
||||
libboost-graph-dev
|
||||
libboost-iostreams-dev
|
||||
libboost-program-options-dev
|
||||
libboost-python-dev
|
||||
libboost-regex-dev
|
||||
libboost-serialization-dev
|
||||
libboost-thread-dev
|
||||
libcoin-dev
|
||||
libeigen3-dev
|
||||
libkdtree++-dev
|
||||
libmedc-dev
|
||||
libocct-data-exchange-dev
|
||||
libocct-ocaf-dev
|
||||
libocct-visualization-dev
|
||||
libopencv-dev
|
||||
libproj-dev
|
||||
libpyside2-dev
|
||||
libqt5opengl5-dev
|
||||
libqt5svg5-dev
|
||||
libqt5x11extras5-dev
|
||||
libshiboken2-dev
|
||||
libspnav-dev
|
||||
libvtk7-dev
|
||||
libx11-dev
|
||||
libxerces-c-dev
|
||||
libyaml-cpp-dev
|
||||
libzipios++-dev
|
||||
netgen
|
||||
netgen-headers
|
||||
ninja-build
|
||||
occt-draw
|
||||
pyqt5-dev-tools
|
||||
pyside2-tools
|
||||
python3-dev
|
||||
python3-git
|
||||
python3-markdown
|
||||
python3-matplotlib
|
||||
python3-packaging
|
||||
python3-pivy
|
||||
python3-ply
|
||||
python3-pyside2.qtcore
|
||||
python3-pyside2.qtgui
|
||||
python3-pyside2.qtnetwork
|
||||
python3-pyside2.qtsvg
|
||||
python3-pyside2.qtwidgets
|
||||
qtbase5-dev
|
||||
qttools5-dev
|
||||
shiboken2
|
||||
swig
|
||||
xvfb
|
||||
)
|
||||
|
||||
# Install all packages
|
||||
sudo apt-get install -y --no-install-recommends "${packages[@]}"
|
||||
@@ -18,6 +18,7 @@
|
||||
// </history>
|
||||
#include <navlib/navlib_types.h>
|
||||
// stdlib
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
+16
-19
@@ -1365,7 +1365,7 @@ void Application::addImportType(const char* Type, const char* ModuleName)
|
||||
std::string::size_type next = item.filter.find_first_of(" )", pos+1);
|
||||
std::string::size_type len = next-pos-2;
|
||||
std::string type = item.filter.substr(pos+2,len);
|
||||
item.types.push_back(type);
|
||||
item.types.push_back(std::move(type));
|
||||
pos = item.filter.find("*.", next);
|
||||
}
|
||||
|
||||
@@ -1373,12 +1373,12 @@ void Application::addImportType(const char* Type, const char* ModuleName)
|
||||
if (strncmp(Type, "FreeCAD", 7) == 0) {
|
||||
std::string AppName = Config()["ExeName"];
|
||||
AppName += item.filter.substr(7);
|
||||
item.filter = AppName;
|
||||
item.filter = std::move(AppName);
|
||||
// put to the front of the array
|
||||
_mImportTypes.insert(_mImportTypes.begin(),item);
|
||||
_mImportTypes.insert(_mImportTypes.begin(),std::move(item));
|
||||
}
|
||||
else {
|
||||
_mImportTypes.push_back(item);
|
||||
_mImportTypes.push_back(std::move(item));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1488,7 +1488,7 @@ void Application::addExportType(const char* Type, const char* ModuleName)
|
||||
std::string::size_type next = item.filter.find_first_of(" )", pos+1);
|
||||
std::string::size_type len = next-pos-2;
|
||||
std::string type = item.filter.substr(pos+2,len);
|
||||
item.types.push_back(type);
|
||||
item.types.push_back(std::move(type));
|
||||
pos = item.filter.find("*.", next);
|
||||
}
|
||||
|
||||
@@ -1496,12 +1496,12 @@ void Application::addExportType(const char* Type, const char* ModuleName)
|
||||
if (strncmp(Type, "FreeCAD", 7) == 0) {
|
||||
std::string AppName = Config()["ExeName"];
|
||||
AppName += item.filter.substr(7);
|
||||
item.filter = AppName;
|
||||
item.filter = std::move(AppName);
|
||||
// put to the front of the array
|
||||
_mExportTypes.insert(_mExportTypes.begin(),item);
|
||||
_mExportTypes.insert(_mExportTypes.begin(),std::move(item));
|
||||
}
|
||||
else {
|
||||
_mExportTypes.push_back(item);
|
||||
_mExportTypes.push_back(std::move(item));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1670,7 +1670,7 @@ void Application::slotBeforeRecompute(const Document& doc)
|
||||
|
||||
void Application::slotOpenTransaction(const Document& d, string s)
|
||||
{
|
||||
this->signalOpenTransaction(d, s);
|
||||
this->signalOpenTransaction(d, std::move(s));
|
||||
}
|
||||
|
||||
void Application::slotCommitTransaction(const Document& d)
|
||||
@@ -1748,7 +1748,7 @@ void Application::destruct()
|
||||
|
||||
// now save all other parameter files
|
||||
auto& paramMgr = _pcSingleton->mpcPramManager;
|
||||
for (auto it : paramMgr) {
|
||||
for (const auto &it : paramMgr) {
|
||||
if ((it.second != _pcSysParamMngr) && (it.second != _pcUserParamMngr)) {
|
||||
if (it.second->HasSerializer() && !it.second->IgnoreSave()) {
|
||||
Base::Console().Log("Saving %s...\n", it.first.c_str());
|
||||
@@ -2454,7 +2454,7 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
for (const auto & It : Macros)
|
||||
temp += It + ";";
|
||||
temp.erase(temp.end()-1);
|
||||
mConfig["AdditionalMacroPaths"] = temp;
|
||||
mConfig["AdditionalMacroPaths"] = std::move(temp);
|
||||
}
|
||||
|
||||
if (vm.count("python-path")) {
|
||||
@@ -2489,8 +2489,7 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
}
|
||||
|
||||
if (vm.count("output")) {
|
||||
string file = vm["output"].as<string>();
|
||||
mConfig["SaveFile"] = file;
|
||||
mConfig["SaveFile"] = vm["output"].as<string>();
|
||||
}
|
||||
|
||||
if (vm.count("hidden")) {
|
||||
@@ -2524,7 +2523,7 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
else if (testCase.empty()) {
|
||||
testCase = "TestApp.PrintAll";
|
||||
}
|
||||
mConfig["TestCase"] = testCase;
|
||||
mConfig["TestCase"] = std::move(testCase);
|
||||
mConfig["RunMode"] = "Internal";
|
||||
mConfig["ScriptFileName"] = "FreeCADTest";
|
||||
mConfig["ExitTests"] = vm.count("run-open") == 0 ? "yes" : "no";
|
||||
@@ -2561,7 +2560,7 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
if (pos != std::string::npos) {
|
||||
std::string key = it.substr(0, pos);
|
||||
std::string val = it.substr(pos + 1);
|
||||
mConfig[key] = val;
|
||||
mConfig[key] = std::move(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2876,9 +2875,7 @@ std::list<std::string> Application::getCmdLineFiles()
|
||||
// getting file name
|
||||
std::ostringstream temp;
|
||||
temp << "OpenFile" << i;
|
||||
|
||||
std::string file(mConfig[temp.str()]);
|
||||
files.push_back(file);
|
||||
files.emplace_back(mConfig[temp.str()]);
|
||||
}
|
||||
|
||||
return files;
|
||||
@@ -3405,7 +3402,7 @@ void Application::ExtractUserPath()
|
||||
|
||||
// Set the default macro directory
|
||||
//
|
||||
std::vector<std::string> macrodirs = subdirs;
|
||||
std::vector<std::string> macrodirs = std::move(subdirs); // Last use in this method, just move
|
||||
macrodirs.emplace_back("Macro");
|
||||
std::filesystem::path macro = findPath(dataHome, customData, macrodirs, true);
|
||||
mConfig["UserMacroPath"] = Base::FileInfo::pathToString(macro) + PATHSEP;
|
||||
|
||||
@@ -20,9 +20,6 @@ IF(DOCDIR)
|
||||
add_definitions(-DDOCDIR="${DOCDIR}")
|
||||
ENDIF(DOCDIR)
|
||||
|
||||
#if you want to use the old DAG structure uncomment this line
|
||||
#add_definitions(-DUSE_OLD_DAG)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
#write relevant cmake variables to a file for later access with python. Exported are all variables
|
||||
@@ -56,6 +53,10 @@ include_directories(
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PYCXX_INCLUDE_DIR}
|
||||
${Python3_INCLUDE_DIRS}
|
||||
@@ -274,7 +275,6 @@ SET(FreeCADApp_CPP_SRCS
|
||||
AutoTransaction.cpp
|
||||
Branding.cpp
|
||||
CleanupProcess.cpp
|
||||
Color.cpp
|
||||
ColorModel.cpp
|
||||
ComplexGeoData.cpp
|
||||
ComplexGeoDataPyImp.cpp
|
||||
@@ -304,7 +304,6 @@ SET(FreeCADApp_HPP_SRCS
|
||||
AutoTransaction.h
|
||||
Branding.h
|
||||
CleanupProcess.h
|
||||
Color.h
|
||||
ColorModel.h
|
||||
ComplexGeoData.h
|
||||
ElementMap.h
|
||||
|
||||
@@ -138,8 +138,8 @@ void ColorField::rebuild()
|
||||
fConstant = -fAscent * fMin;
|
||||
}
|
||||
|
||||
// fuellt das Array von Farbe 1, Index 1 bis Farbe 2, Index 2
|
||||
void ColorField::interpolate(Color clCol1, std::size_t usInd1, Color clCol2, std::size_t usInd2)
|
||||
// fills the array from color 1, index 1 to color 2, index 2
|
||||
void ColorField::interpolate(Base::Color clCol1, std::size_t usInd1, Base::Color clCol2, std::size_t usInd2)
|
||||
{
|
||||
float fStep = 1.0f, fLen = float(usInd2 - usInd1);
|
||||
|
||||
@@ -154,7 +154,7 @@ void ColorField::interpolate(Color clCol1, std::size_t usInd1, Color clCol2, std
|
||||
float ucR = clCol1.r + fR * fStep;
|
||||
float ucG = clCol1.g + fG * fStep;
|
||||
float ucB = clCol1.b + fB * fStep;
|
||||
colorField[i] = Color(ucR, ucG, ucB);
|
||||
colorField[i] = Base::Color(ucR, ucG, ucB);
|
||||
fStep += 1.0f;
|
||||
}
|
||||
}
|
||||
@@ -370,20 +370,20 @@ bool ColorLegend::setValue(std::size_t ulPos, float fVal)
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorLegend::getColor(std::size_t ulPos) const
|
||||
Base::Color ColorLegend::getColor(std::size_t ulPos) const
|
||||
{
|
||||
if (ulPos < colorFields.size()) {
|
||||
return colorFields[ulPos];
|
||||
}
|
||||
else {
|
||||
return Color();
|
||||
return Base::Color();
|
||||
}
|
||||
}
|
||||
|
||||
// color as: 0x00rrggbb
|
||||
uint32_t ColorLegend::getPackedColor(std::size_t ulPos) const
|
||||
{
|
||||
Color clRGB = getColor(ulPos);
|
||||
Base::Color clRGB = getColor(ulPos);
|
||||
return clRGB.getPackedValue();
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ std::size_t ColorLegend::addMin(const std::string& rclName)
|
||||
names.push_front(rclName);
|
||||
values.push_front(values.front() - 1.0f);
|
||||
|
||||
Color clNewRGB;
|
||||
Base::Color clNewRGB;
|
||||
clNewRGB.r = ((float)rand() / (float)RAND_MAX);
|
||||
clNewRGB.g = ((float)rand() / (float)RAND_MAX);
|
||||
clNewRGB.b = ((float)rand() / (float)RAND_MAX);
|
||||
@@ -417,7 +417,7 @@ std::size_t ColorLegend::addMax(const std::string& rclName)
|
||||
names.push_back(rclName);
|
||||
values.push_back(values.back() + 1.0f);
|
||||
|
||||
Color clNewRGB;
|
||||
Base::Color clNewRGB;
|
||||
clNewRGB.r = ((float)rand() / (float)RAND_MAX);
|
||||
clNewRGB.g = ((float)rand() / (float)RAND_MAX);
|
||||
clNewRGB.b = ((float)rand() / (float)RAND_MAX);
|
||||
@@ -481,7 +481,7 @@ void ColorLegend::resize(std::size_t ulCt)
|
||||
bool ColorLegend::setColor(std::size_t ulPos, float ucRed, float ucGreen, float ucBlue)
|
||||
{
|
||||
if (ulPos < names.size()) {
|
||||
colorFields[ulPos] = Color(ucRed, ucGreen, ucBlue);
|
||||
colorFields[ulPos] = Base::Color(ucRed, ucGreen, ucBlue);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+70
-71
@@ -32,7 +32,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace App
|
||||
{
|
||||
|
||||
@@ -64,7 +63,7 @@ namespace App
|
||||
class AppExport ValueFloatToRGB
|
||||
{
|
||||
public:
|
||||
virtual Color getColor(float fVal) const = 0;
|
||||
virtual Base::Color getColor(float fVal) const = 0;
|
||||
|
||||
protected:
|
||||
ValueFloatToRGB() = default;
|
||||
@@ -87,7 +86,7 @@ public:
|
||||
{
|
||||
return colors.size();
|
||||
}
|
||||
std::vector<Color> colors;
|
||||
std::vector<Base::Color> colors;
|
||||
};
|
||||
|
||||
class AppExport ColorModelBlueGreenRed: public ColorModel
|
||||
@@ -96,11 +95,11 @@ public:
|
||||
ColorModelBlueGreenRed()
|
||||
: ColorModel(5)
|
||||
{
|
||||
colors[0] = Color(0, 0, 1);
|
||||
colors[1] = Color(0, 1, 1);
|
||||
colors[2] = Color(0, 1, 0);
|
||||
colors[3] = Color(1, 1, 0);
|
||||
colors[4] = Color(1, 0, 0);
|
||||
colors[0] = Base::Color(0, 0, 1);
|
||||
colors[1] = Base::Color(0, 1, 1);
|
||||
colors[2] = Base::Color(0, 1, 0);
|
||||
colors[3] = Base::Color(1, 1, 0);
|
||||
colors[4] = Base::Color(1, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -110,9 +109,9 @@ public:
|
||||
ColorModelBlueCyanGreen()
|
||||
: ColorModel(3)
|
||||
{
|
||||
colors[0] = Color(0, 0, 1);
|
||||
colors[1] = Color(0, 1, 1);
|
||||
colors[2] = Color(0, 1, 0);
|
||||
colors[0] = Base::Color(0, 0, 1);
|
||||
colors[1] = Base::Color(0, 1, 1);
|
||||
colors[2] = Base::Color(0, 1, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,9 +121,9 @@ public:
|
||||
ColorModelGreenYellowRed()
|
||||
: ColorModel(3)
|
||||
{
|
||||
colors[0] = Color(0, 1, 0);
|
||||
colors[1] = Color(1, 1, 0);
|
||||
colors[2] = Color(1, 0, 0);
|
||||
colors[0] = Base::Color(0, 1, 0);
|
||||
colors[1] = Base::Color(1, 1, 0);
|
||||
colors[2] = Base::Color(1, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,11 +133,11 @@ public:
|
||||
ColorModelRedGreenBlue()
|
||||
: ColorModel(5)
|
||||
{
|
||||
colors[0] = Color(1, 0, 0);
|
||||
colors[1] = Color(1, 1, 0);
|
||||
colors[2] = Color(0, 1, 0);
|
||||
colors[3] = Color(0, 1, 1);
|
||||
colors[4] = Color(0, 0, 1);
|
||||
colors[0] = Base::Color(1, 0, 0);
|
||||
colors[1] = Base::Color(1, 1, 0);
|
||||
colors[2] = Base::Color(0, 1, 0);
|
||||
colors[3] = Base::Color(0, 1, 1);
|
||||
colors[4] = Base::Color(0, 0, 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -148,9 +147,9 @@ public:
|
||||
ColorModelGreenCyanBlue()
|
||||
: ColorModel(3)
|
||||
{
|
||||
colors[0] = Color(0, 1, 0);
|
||||
colors[1] = Color(0, 1, 1);
|
||||
colors[2] = Color(0, 0, 1);
|
||||
colors[0] = Base::Color(0, 1, 0);
|
||||
colors[1] = Base::Color(0, 1, 1);
|
||||
colors[2] = Base::Color(0, 0, 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -160,9 +159,9 @@ public:
|
||||
ColorModelRedYellowGreen()
|
||||
: ColorModel(3)
|
||||
{
|
||||
colors[0] = Color(1, 0, 0);
|
||||
colors[1] = Color(1, 1, 0);
|
||||
colors[2] = Color(0, 1, 0);
|
||||
colors[0] = Base::Color(1, 0, 0);
|
||||
colors[1] = Base::Color(1, 1, 0);
|
||||
colors[2] = Base::Color(0, 1, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -172,11 +171,11 @@ public:
|
||||
ColorModelBlueWhiteRed()
|
||||
: ColorModel(5)
|
||||
{
|
||||
colors[0] = Color(0, 0, 1);
|
||||
colors[1] = Color(float(85.0 / 255), float(170.0 / 255), 1);
|
||||
colors[2] = Color(1, 1, 1);
|
||||
colors[3] = Color(1, float(85.0 / 255), 0);
|
||||
colors[4] = Color(1, 0, 0);
|
||||
colors[0] = Base::Color(0, 0, 1);
|
||||
colors[1] = Base::Color(float(85.0 / 255), float(170.0 / 255), 1);
|
||||
colors[2] = Base::Color(1, 1, 1);
|
||||
colors[3] = Base::Color(1, float(85.0 / 255), 0);
|
||||
colors[4] = Base::Color(1, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -186,9 +185,9 @@ public:
|
||||
ColorModelBlueWhite()
|
||||
: ColorModel(3)
|
||||
{
|
||||
colors[0] = Color(0, 0, 1);
|
||||
colors[1] = Color(float(85.0 / 255), float(170.0 / 255), 1);
|
||||
colors[2] = Color(1, 1, 1);
|
||||
colors[0] = Base::Color(0, 0, 1);
|
||||
colors[1] = Base::Color(float(85.0 / 255), float(170.0 / 255), 1);
|
||||
colors[2] = Base::Color(1, 1, 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -198,9 +197,9 @@ public:
|
||||
ColorModelWhiteRed()
|
||||
: ColorModel(3)
|
||||
{
|
||||
colors[0] = Color(1, 1, 1);
|
||||
colors[1] = Color(1, float(85.0 / 255), 0);
|
||||
colors[2] = Color(1, 0, 0);
|
||||
colors[0] = Base::Color(1, 1, 1);
|
||||
colors[1] = Base::Color(1, float(85.0 / 255), 0);
|
||||
colors[2] = Base::Color(1, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -210,8 +209,8 @@ public:
|
||||
ColorModelBlackWhite()
|
||||
: ColorModel(2)
|
||||
{
|
||||
colors[0] = Color(0, 0, 0);
|
||||
colors[1] = Color(1, 1, 1);
|
||||
colors[0] = Base::Color(0, 0, 0);
|
||||
colors[1] = Base::Color(1, 1, 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -221,8 +220,8 @@ public:
|
||||
ColorModelBlackGray()
|
||||
: ColorModel(2)
|
||||
{
|
||||
colors[0] = Color(0.0f, 0.0f, 0.0f);
|
||||
colors[1] = Color(0.5f, 0.5f, 0.5f);
|
||||
colors[0] = Base::Color(0.0f, 0.0f, 0.0f);
|
||||
colors[1] = Base::Color(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -232,8 +231,8 @@ public:
|
||||
ColorModelGrayWhite()
|
||||
: ColorModel(2)
|
||||
{
|
||||
colors[0] = Color(0.5f, 0.5f, 0.5f);
|
||||
colors[1] = Color(1.0f, 1.0f, 1.0f);
|
||||
colors[0] = Base::Color(0.5f, 0.5f, 0.5f);
|
||||
colors[1] = Base::Color(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -243,8 +242,8 @@ public:
|
||||
ColorModelWhiteBlack()
|
||||
: ColorModel(2)
|
||||
{
|
||||
colors[0] = Color(1, 1, 1);
|
||||
colors[1] = Color(0, 0, 0);
|
||||
colors[0] = Base::Color(1, 1, 1);
|
||||
colors[1] = Base::Color(0, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -254,8 +253,8 @@ public:
|
||||
ColorModelWhiteGray()
|
||||
: ColorModel(2)
|
||||
{
|
||||
colors[0] = Color(1.0f, 1.0f, 1.0f);
|
||||
colors[1] = Color(0.5f, 0.5f, 0.5f);
|
||||
colors[0] = Base::Color(1.0f, 1.0f, 1.0f);
|
||||
colors[1] = Base::Color(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -265,8 +264,8 @@ public:
|
||||
ColorModelGrayBlack()
|
||||
: ColorModel(2)
|
||||
{
|
||||
colors[0] = Color(0.5f, 0.5f, 0.5f);
|
||||
colors[1] = Color(0.0f, 0.0f, 0.0f);
|
||||
colors[0] = Base::Color(0.5f, 0.5f, 0.5f);
|
||||
colors[1] = Base::Color(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -320,7 +319,7 @@ public:
|
||||
{
|
||||
return colorModel;
|
||||
}
|
||||
void setDirect(std::size_t usInd, Color clCol)
|
||||
void setDirect(std::size_t usInd, Base::Color clCol)
|
||||
{
|
||||
colorField[usInd] = clCol;
|
||||
}
|
||||
@@ -333,11 +332,11 @@ public:
|
||||
return fMax;
|
||||
}
|
||||
|
||||
Color getColor(std::size_t usIndex) const
|
||||
Base::Color getColor(std::size_t usIndex) const
|
||||
{
|
||||
return colorField[usIndex];
|
||||
}
|
||||
inline Color getColor(float fVal) const;
|
||||
inline Base::Color getColor(float fVal) const;
|
||||
inline std::size_t getColorIndex(float fVal) const;
|
||||
|
||||
protected:
|
||||
@@ -345,13 +344,13 @@ protected:
|
||||
float fMin, fMax;
|
||||
float fAscent, fConstant; // Index := _fConstant + _fAscent * WERT
|
||||
std::size_t ctColors;
|
||||
std::vector<Color> colorField;
|
||||
std::vector<Base::Color> colorField;
|
||||
|
||||
void rebuild();
|
||||
void interpolate(Color clCol1, std::size_t usPos1, Color clCol2, std::size_t usPos2);
|
||||
void interpolate(Base::Color clCol1, std::size_t usPos1, Base::Color clCol2, std::size_t usPos2);
|
||||
};
|
||||
|
||||
inline Color ColorField::getColor(float fVal) const
|
||||
inline Base::Color ColorField::getColor(float fVal) const
|
||||
{
|
||||
// if the value is outside or at the border of the range
|
||||
std::size_t ct = colorModel.getCountColors() - 1;
|
||||
@@ -362,16 +361,16 @@ inline Color ColorField::getColor(float fVal) const
|
||||
return colorModel.colors[ct];
|
||||
}
|
||||
|
||||
// get the color field position (with 0 < t < 1)
|
||||
// get the Base::Color field position (with 0 < t < 1)
|
||||
float t = (fVal - fMin) / (fMax - fMin);
|
||||
Color col(1.0f, 1.0f, 1.0f); // white as default
|
||||
Base::Color col(1.0f, 1.0f, 1.0f); // white as default
|
||||
for (std::size_t i = 0; i < ct; i++) {
|
||||
float r = (float)(i + 1) / (float)ct;
|
||||
if (t < r) {
|
||||
// calculate the exact position in the subrange
|
||||
float s = t * float(ct) - float(i);
|
||||
Color c1 = colorModel.colors[i];
|
||||
Color c2 = colorModel.colors[i + 1];
|
||||
Base::Color c1 = colorModel.colors[i];
|
||||
Base::Color c2 = colorModel.colors[i + 1];
|
||||
col.r = (1.0f - s) * c1.r + s * c2.r;
|
||||
col.g = (1.0f - s) * c1.g + s * c2.g;
|
||||
col.b = (1.0f - s) * c1.b + s * c2.b;
|
||||
@@ -484,11 +483,11 @@ public:
|
||||
return profile.fMax;
|
||||
}
|
||||
|
||||
inline Color getColor(float fVal) const;
|
||||
inline Base::Color getColor(float fVal) const;
|
||||
inline std::size_t getColorIndex(float fVal) const;
|
||||
|
||||
private:
|
||||
inline Color _getColor(float fVal) const;
|
||||
inline Base::Color _getColor(float fVal) const;
|
||||
|
||||
protected:
|
||||
void createStandardPacks();
|
||||
@@ -525,7 +524,7 @@ public:
|
||||
void removeFirst();
|
||||
void removeLast();
|
||||
|
||||
Color getColor(std::size_t ulPos) const;
|
||||
Base::Color getColor(std::size_t ulPos) const;
|
||||
uint32_t getPackedColor(std::size_t ulPos) const;
|
||||
bool setColor(std::size_t ulPos, float ucRed, float ucGreen, float ucBlue);
|
||||
bool setColor(std::size_t ulPos, unsigned long ulColor);
|
||||
@@ -548,17 +547,17 @@ public:
|
||||
inline float getMinValue() const;
|
||||
inline float getMaxValue() const;
|
||||
|
||||
inline Color getColor(float fVal) const;
|
||||
inline Base::Color getColor(float fVal) const;
|
||||
inline std::size_t getColorIndex(float fVal) const;
|
||||
|
||||
protected:
|
||||
std::deque<Color> colorFields;
|
||||
std::deque<Base::Color> colorFields;
|
||||
std::deque<std::string> names;
|
||||
std::deque<float> values;
|
||||
bool outsideGrayed {false};
|
||||
};
|
||||
|
||||
inline Color ColorLegend::getColor(float fVal) const
|
||||
inline Base::Color ColorLegend::getColor(float fVal) const
|
||||
{
|
||||
std::deque<float>::const_iterator pI;
|
||||
for (pI = values.begin(); pI != values.end(); ++pI) {
|
||||
@@ -569,7 +568,7 @@ inline Color ColorLegend::getColor(float fVal) const
|
||||
|
||||
if (outsideGrayed) {
|
||||
if ((pI == values.begin()) || (pI == values.end())) {
|
||||
return Color(0.5f, 0.5f, 0.5f);
|
||||
return Base::Color(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
else {
|
||||
return colorFields[pI - values.begin() - 1];
|
||||
@@ -617,23 +616,23 @@ inline float ColorLegend::getMaxValue() const
|
||||
return values.back();
|
||||
}
|
||||
|
||||
inline Color ColorGradient::getColor(float fVal) const
|
||||
inline Base::Color ColorGradient::getColor(float fVal) const
|
||||
{
|
||||
Color color = _getColor(fVal);
|
||||
Base::Color Color = _getColor(fVal);
|
||||
if (isOutsideInvisible()) {
|
||||
if (isOutOfRange(fVal)) {
|
||||
color.a = 0.2F;
|
||||
Color.a = 0.2F;
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
return Color;
|
||||
}
|
||||
|
||||
inline Color ColorGradient::_getColor(float fVal) const
|
||||
inline Base::Color ColorGradient::_getColor(float fVal) const
|
||||
{
|
||||
if (isOutsideGrayed()) {
|
||||
if (isOutOfRange(fVal)) {
|
||||
return Color(0.5f, 0.5f, 0.5f);
|
||||
return Base::Color(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,6 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
|
||||
#include <boost/bimap.hpp>
|
||||
#include <boost/graph/strong_components.hpp>
|
||||
|
||||
#ifdef USE_OLD_DAG
|
||||
#include <boost/graph/topological_sort.hpp>
|
||||
#include <boost/graph/depth_first_search.hpp>
|
||||
#include <boost/graph/dijkstra_shortest_paths.hpp>
|
||||
#include <boost/graph/visitors.hpp>
|
||||
#endif // USE_OLD_DAG
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <random>
|
||||
#include <unordered_map>
|
||||
@@ -2934,15 +2927,7 @@ std::vector<App::Document*> Document::getDependentDocuments(std::vector<App::Doc
|
||||
|
||||
void Document::_rebuildDependencyList(const std::vector<App::DocumentObject*>& objs)
|
||||
{
|
||||
#ifdef USE_OLD_DAG
|
||||
_buildDependencyList(objs.empty() ? d->objectArray : objs,
|
||||
false,
|
||||
0,
|
||||
&d->DepList,
|
||||
&d->VertexObjectList);
|
||||
#else
|
||||
(void)objs;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2973,156 +2958,6 @@ void Document::renameObjectIdentifiers(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_DAG
|
||||
int Document::recompute(const std::vector<App::DocumentObject*>& objs, bool force)
|
||||
{
|
||||
if (testStatus(Document::Recomputing)) {
|
||||
// this is clearly a bug in the calling instance
|
||||
throw Base::RuntimeError("Nested recomputes of a document are not allowed");
|
||||
}
|
||||
|
||||
int objectCount = 0;
|
||||
|
||||
// The 'SkipRecompute' flag can be (tmp.) set to avoid too many
|
||||
// time expensive recomputes
|
||||
if (!force && testStatus(Document::SkipRecompute)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Base::ObjectStatusLocker<Document::Status, Document> exe(Document::Recomputing, this);
|
||||
|
||||
// delete recompute log
|
||||
d->clearRecomputeLog();
|
||||
|
||||
// updates the dependency graph
|
||||
_rebuildDependencyList(objs);
|
||||
|
||||
std::list<Vertex> make_order;
|
||||
DependencyList::out_edge_iterator j, jend;
|
||||
|
||||
try {
|
||||
// this sort gives the execute
|
||||
boost::topological_sort(d->DepList, std::front_inserter(make_order));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "Document::recompute: " << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// caching vertex to DocObject
|
||||
for (std::map<DocumentObject*, Vertex>::const_iterator It1 = d->VertexObjectList.begin();
|
||||
It1 != d->VertexObjectList.end();
|
||||
++It1) {
|
||||
d->vertexMap[It1->second] = It1->first;
|
||||
}
|
||||
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << "make ordering: " << std::endl;
|
||||
#endif
|
||||
|
||||
std::set<DocumentObject*> recomputeList;
|
||||
|
||||
for (std::list<Vertex>::reverse_iterator i = make_order.rbegin(); i != make_order.rend(); ++i) {
|
||||
DocumentObject* Cur = d->vertexMap[*i];
|
||||
// Because of PropertyXLink, we should account for external objects
|
||||
// TODO: make sure it is safe to rely on getNameInDocument() to check if
|
||||
// object is in the document. If it crashes, then we should fix the code
|
||||
// to properly nullify getNameInDocument(), rather than revert back to
|
||||
// the inefficient isIn()
|
||||
// if (!Cur || !isIn(Cur)) continue;
|
||||
if (!Cur || !Cur->getNameInDocument()) {
|
||||
continue;
|
||||
}
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << Cur->getNameInDocument() << " dep on:";
|
||||
#endif
|
||||
bool NeedUpdate = false;
|
||||
|
||||
// ask the object if it should be recomputed
|
||||
if (Cur->mustExecute() == 1 || Cur->ExpressionEngine.depsAreTouched()) {
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << "[touched]";
|
||||
#endif
|
||||
NeedUpdate = true;
|
||||
}
|
||||
else { // if (Cur->mustExecute() == -1)
|
||||
// update if one of the dependencies is touched
|
||||
for (boost::tie(j, jend) = out_edges(*i, d->DepList); j != jend; ++j) {
|
||||
DocumentObject* Test = d->vertexMap[target(*j, d->DepList)];
|
||||
|
||||
if (!Test) {
|
||||
continue;
|
||||
}
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << " " << Test->getNameInDocument();
|
||||
#endif
|
||||
if (Test->isTouched()) {
|
||||
NeedUpdate = true;
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << "[touched]";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
// if one touched recompute
|
||||
if (NeedUpdate) {
|
||||
Cur->touch();
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << " => Recompute feature";
|
||||
#endif
|
||||
recomputeList.insert(Cur);
|
||||
}
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FC_LOGFEATUREUPDATE
|
||||
std::clog << "Have to recompute the following document objects" << std::endl;
|
||||
for (std::set<DocumentObject*>::const_iterator it = recomputeList.begin();
|
||||
it != recomputeList.end();
|
||||
++it) {
|
||||
std::clog << " " << (*it)->getNameInDocument() << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (std::list<Vertex>::reverse_iterator i = make_order.rbegin(); i != make_order.rend(); ++i) {
|
||||
DocumentObject* Cur = d->vertexMap[*i];
|
||||
if (!Cur || !isIn(Cur)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (recomputeList.find(Cur) != recomputeList.end()
|
||||
|| Cur->ExpressionEngine.depsAreTouched()) {
|
||||
if (_recomputeFeature(Cur)) {
|
||||
// if something happened break execution of recompute
|
||||
d->vertexMap.clear();
|
||||
return -1;
|
||||
}
|
||||
signalRecomputedObject(*Cur);
|
||||
++objectCount;
|
||||
}
|
||||
}
|
||||
|
||||
// reset all touched
|
||||
for (std::map<Vertex, DocumentObject*>::iterator it = d->vertexMap.begin();
|
||||
it != d->vertexMap.end();
|
||||
++it) {
|
||||
// TODO: check the TODO comments above for details
|
||||
// if ((it->second) && isIn(it->second))
|
||||
if ((it->second) && it->second->getNameInDocument()) {
|
||||
it->second->purgeTouched();
|
||||
}
|
||||
}
|
||||
d->vertexMap.clear();
|
||||
|
||||
signalRecomputed(*this);
|
||||
|
||||
return objectCount;
|
||||
}
|
||||
|
||||
#else // ifdef USE_OLD_DAG
|
||||
|
||||
int Document::recompute(const std::vector<App::DocumentObject*>& objs,
|
||||
bool force,
|
||||
bool* hasError,
|
||||
@@ -3315,8 +3150,6 @@ int Document::recompute(const std::vector<App::DocumentObject*>& objs,
|
||||
return objectCount;
|
||||
}
|
||||
|
||||
#endif // USE_OLD_DAG
|
||||
|
||||
/*!
|
||||
Does almost the same as topologicalSort() until no object with an input degree of zero
|
||||
can be found. It then searches for objects with an output degree of zero until neither
|
||||
@@ -3912,20 +3745,6 @@ void Document::removeObject(const char* sName)
|
||||
signalTransactionRemove(*pos->second, 0);
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_DAG
|
||||
if (!d->vertexMap.empty()) {
|
||||
// recompute of document is running
|
||||
for (std::map<Vertex, DocumentObject*>::iterator it = d->vertexMap.begin();
|
||||
it != d->vertexMap.end();
|
||||
++it) {
|
||||
if (it->second == pos->second) {
|
||||
it->second = 0; // just nullify the pointer
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // USE_OLD_DAG
|
||||
|
||||
// Before deleting we must nullify all dependent objects
|
||||
breakDependency(pos->second, true);
|
||||
|
||||
|
||||
@@ -468,27 +468,11 @@ std::vector<App::DocumentObject*> DocumentObject::getOutListOfProperty(App::Prop
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_DAG
|
||||
std::vector<App::DocumentObject*> DocumentObject::getInList(void) const
|
||||
{
|
||||
if (_pDoc) {
|
||||
return _pDoc->getInList(this);
|
||||
}
|
||||
else {
|
||||
return std::vector<App::DocumentObject*>();
|
||||
}
|
||||
}
|
||||
|
||||
#else // ifndef USE_OLD_DAG
|
||||
|
||||
const std::vector<App::DocumentObject*>& DocumentObject::getInList() const
|
||||
{
|
||||
return _inList;
|
||||
}
|
||||
|
||||
#endif // if USE_OLD_DAG
|
||||
|
||||
|
||||
// The original algorithm is highly inefficient in some special case.
|
||||
// Considering an object is linked by every other objects. After excluding this
|
||||
// object, there is another object linked by every other of the remaining
|
||||
@@ -513,41 +497,6 @@ void DocumentObject::getInListEx(std::set<App::DocumentObject*>& inSet,
|
||||
bool recursive,
|
||||
std::vector<App::DocumentObject*>* inList) const
|
||||
{
|
||||
#ifdef USE_OLD_DAG
|
||||
std::map<DocumentObject*, std::set<App::DocumentObject*>> outLists;
|
||||
|
||||
// Old DAG does not have pre-built InList, and must calculate The InList by
|
||||
// going through all objects' OutLists. So we collect all objects and their
|
||||
// outLists first here.
|
||||
for (auto doc : GetApplication().getDocuments()) {
|
||||
for (auto obj : doc->getObjects()) {
|
||||
if (!obj || !obj->isAttachedToDocument() || obj == this) {
|
||||
continue;
|
||||
}
|
||||
const auto& outList = obj->getOutList();
|
||||
outLists[obj].insert(outList.begin(), outList.end());
|
||||
}
|
||||
}
|
||||
|
||||
std::stack<DocumentObject*> pendings;
|
||||
pendings.push(const_cast<DocumentObject*>(this));
|
||||
while (pendings.size()) {
|
||||
auto obj = pendings.top();
|
||||
pendings.pop();
|
||||
for (auto& v : outLists) {
|
||||
if (v.first == obj) {
|
||||
continue;
|
||||
}
|
||||
auto& outList = v.second;
|
||||
// Check the outList to see if the object is there, and pend the
|
||||
// object for recursive check if it's not already in the inList
|
||||
if (outList.find(obj) != outList.end() && inSet.insert(v.first).second && recursive) {
|
||||
pendings.push(v.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // USE_OLD_DAG
|
||||
|
||||
if (!recursive) {
|
||||
inSet.insert(_inList.begin(), _inList.end());
|
||||
if (inList) {
|
||||
@@ -570,8 +519,6 @@ void DocumentObject::getInListEx(std::set<App::DocumentObject*>& inSet,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
std::set<App::DocumentObject*> DocumentObject::getInListEx(bool recursive) const
|
||||
@@ -618,7 +565,6 @@ std::vector<App::DocumentObject*> DocumentObject::getOutListRecursive() const
|
||||
// helper for isInInListRecursive()
|
||||
bool _isInInListRecursive(const DocumentObject* act, const DocumentObject* checkObj, int depth)
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
for (auto obj : act->getInList()) {
|
||||
if (obj == checkObj) {
|
||||
return true;
|
||||
@@ -633,11 +579,6 @@ bool _isInInListRecursive(const DocumentObject* act, const DocumentObject* check
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)act;
|
||||
(void)checkObj;
|
||||
(void)depth;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -649,23 +590,17 @@ bool DocumentObject::isInInListRecursive(DocumentObject* linkTo) const
|
||||
|
||||
bool DocumentObject::isInInList(DocumentObject* linkTo) const
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
if (std::find(_inList.begin(), _inList.end(), linkTo) != _inList.end()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
(void)linkTo;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// helper for isInOutListRecursive()
|
||||
bool _isInOutListRecursive(const DocumentObject* act, const DocumentObject* checkObj, int depth)
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
for (auto obj : act->getOutList()) {
|
||||
if (obj == checkObj) {
|
||||
return true;
|
||||
@@ -680,11 +615,6 @@ bool _isInOutListRecursive(const DocumentObject* act, const DocumentObject* chec
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)act;
|
||||
(void)checkObj;
|
||||
(void)depth;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1321,29 +1251,21 @@ void DocumentObject::unsetupObject()
|
||||
|
||||
void App::DocumentObject::_removeBackLink(DocumentObject* rmvObj)
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
// do not use erase-remove idom, as this erases ALL entries that match. we only want to remove a
|
||||
// single one.
|
||||
auto it = std::find(_inList.begin(), _inList.end(), rmvObj);
|
||||
if (it != _inList.end()) {
|
||||
_inList.erase(it);
|
||||
}
|
||||
#else
|
||||
(void)rmvObj;
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::DocumentObject::_addBackLink(DocumentObject* newObj)
|
||||
{
|
||||
#ifndef USE_OLD_DAG
|
||||
// we need to add all links, even if they are available multiple times. The reason for this is
|
||||
// the removal: If a link loses this object it removes the backlink. If we would have added it
|
||||
// only once this removal would clear the object from the inlist, even though there may be other
|
||||
// link properties from this object that link to us.
|
||||
_inList.push_back(newObj);
|
||||
#else
|
||||
(void)newObj;
|
||||
#endif // USE_OLD_DAG
|
||||
}
|
||||
|
||||
int DocumentObject::setElementVisible(const char* element, bool visible)
|
||||
|
||||
@@ -293,12 +293,8 @@ public:
|
||||
void clearOutListCache() const;
|
||||
/// get all possible paths from this to another object following the OutList
|
||||
std::vector<std::list<App::DocumentObject*>> getPathsByOutList(App::DocumentObject* to) const;
|
||||
#ifdef USE_OLD_DAG
|
||||
/// get all objects link to this object
|
||||
std::vector<App::DocumentObject*> getInList(void) const
|
||||
#else
|
||||
const std::vector<App::DocumentObject*>& getInList() const;
|
||||
#endif
|
||||
/// get all objects link directly or indirectly to this object
|
||||
std::vector<App::DocumentObject*> getInListRecursive() const;
|
||||
/** Get a set of all objects linking to this object, including possible external parent objects
|
||||
|
||||
@@ -70,7 +70,7 @@ FeatureTest::FeatureTest()
|
||||
ADD_PROPERTY(ConstraintFloat, (5.0));
|
||||
ConstraintFloat.setConstraints(&floatPercent);
|
||||
|
||||
App::Color c;
|
||||
Base::Color c;
|
||||
App::Material mat(App::Material::GOLD);
|
||||
ADD_PROPERTY(Colour, (c));
|
||||
ADD_PROPERTY(ColourList, (c));
|
||||
|
||||
@@ -327,7 +327,7 @@ App::Material Material::getDefaultAppearance()
|
||||
ParameterGrp::handle hGrp =
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
auto getColor = [hGrp](const char* parameter, App::Color& color) {
|
||||
auto getColor = [hGrp](const char* parameter, Base::Color& color) {
|
||||
uint32_t packed = color.getPackedRGB();
|
||||
packed = hGrp->GetUnsigned(parameter, packed);
|
||||
color.setPackedRGB(packed);
|
||||
@@ -351,10 +351,10 @@ App::Material Material::getDefaultAppearance()
|
||||
float red = static_cast<float>(intRandom(0, 255)) / 255.0F;
|
||||
float green = static_cast<float>(intRandom(0, 255)) / 255.0F;
|
||||
float blue = static_cast<float>(intRandom(0, 255)) / 255.0F;
|
||||
mat.diffuseColor = App::Color(red, green, blue);
|
||||
mat.diffuseColor = Base::Color(red, green, blue);
|
||||
}
|
||||
else {
|
||||
// Color = (204, 204, 230) = 3435980543UL
|
||||
// Base::Color = (204, 204, 230) = 3435980543UL
|
||||
getColor("DefaultShapeColor", mat.diffuseColor);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -24,7 +24,7 @@
|
||||
#ifndef APP_MATERIAL_H
|
||||
#define APP_MATERIAL_H
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
namespace App
|
||||
{
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
* \li Ruby
|
||||
* \li Emerald
|
||||
* Furthermore there two additional modes \a Default which defines a kind of grey metallic and
|
||||
* user defined that does nothing. The Color and the other properties of the material are
|
||||
* user defined that does nothing. The Base::Color and the other properties of the material are
|
||||
* defined in the range [0-1]. If \a MatName is an unknown material name then the type
|
||||
* USER_DEFINED is set and the material doesn't get changed.
|
||||
*/
|
||||
@@ -125,10 +125,10 @@ public:
|
||||
/** @name Properties */
|
||||
//@{
|
||||
// NOLINTBEGIN
|
||||
Color ambientColor; /**< Defines the ambient color. */
|
||||
Color diffuseColor; /**< Defines the diffuse color. */
|
||||
Color specularColor; /**< Defines the specular color. */
|
||||
Color emissiveColor; /**< Defines the emissive color. */
|
||||
Base::Color ambientColor; /**< Defines the ambient color. */
|
||||
Base::Color diffuseColor; /**< Defines the diffuse color. */
|
||||
Base::Color specularColor; /**< Defines the specular color. */
|
||||
Base::Color emissiveColor; /**< Defines the emissive color. */
|
||||
float shininess;
|
||||
float transparency;
|
||||
std::string image;
|
||||
|
||||
@@ -64,7 +64,7 @@ Satin, Metalized, Neon GNC, Chrome, Aluminium, Obsidian, Neon PHC, Jade, Ruby or
|
||||
</Attribute>
|
||||
<CustomAttributes />
|
||||
<ClassDeclarations>public:
|
||||
static App::Color toColor(PyObject* value);
|
||||
static Base::Color toColor(PyObject* value);
|
||||
</ClassDeclarations>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
|
||||
using namespace App;
|
||||
|
||||
Color MaterialPy::toColor(PyObject* value)
|
||||
Base::Color MaterialPy::toColor(PyObject* value)
|
||||
{
|
||||
Color cCol;
|
||||
Base::Color cCol;
|
||||
if (PyTuple_Check(value) && (PyTuple_Size(value) == 3 || PyTuple_Size(value) == 4)) {
|
||||
PyObject* item {};
|
||||
item = PyTuple_GetItem(value, 0);
|
||||
|
||||
+17
-37
@@ -690,7 +690,6 @@ PropertyLink::~PropertyLink()
|
||||
void PropertyLink::resetLink()
|
||||
{
|
||||
// in case this property gets dynamically removed
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain the back link in the DocumentObject class if it is from a document object
|
||||
if (_pcScope != LinkScope::Hidden && _pcLink && getContainer()
|
||||
&& getContainer()->isDerivedFrom<App::DocumentObject>()) {
|
||||
@@ -703,8 +702,6 @@ void PropertyLink::resetLink()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
_pcLink = nullptr;
|
||||
}
|
||||
|
||||
void PropertyLink::setValue(App::DocumentObject* lValue)
|
||||
@@ -716,7 +713,7 @@ void PropertyLink::setValue(App::DocumentObject* lValue)
|
||||
}
|
||||
|
||||
aboutToSetValue();
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
// maintain the back link in the DocumentObject class if it is from a document object
|
||||
if (_pcScope != LinkScope::Hidden && parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -730,7 +727,7 @@ void PropertyLink::setValue(App::DocumentObject* lValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_pcLink = lValue;
|
||||
hasSetValue();
|
||||
}
|
||||
@@ -895,7 +892,7 @@ PropertyLinkList::PropertyLinkList() = default;
|
||||
PropertyLinkList::~PropertyLinkList()
|
||||
{
|
||||
// in case this property gety dynamically removed
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
// maintain the back link in the DocumentObject class
|
||||
if (_pcScope != LinkScope::Hidden && !_lValueList.empty() && getContainer()
|
||||
&& getContainer()->isDerivedFrom<App::DocumentObject>()) {
|
||||
@@ -910,7 +907,6 @@ PropertyLinkList::~PropertyLinkList()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PropertyLinkList::setSize(int newSize)
|
||||
@@ -921,11 +917,10 @@ void PropertyLinkList::setSize(int newSize)
|
||||
continue;
|
||||
}
|
||||
_nameMap.erase(obj->getNameInDocument());
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (_pcScope != LinkScope::Hidden) {
|
||||
obj->_removeBackLink(static_cast<DocumentObject*>(getContainer()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_lValueList.resize(newSize);
|
||||
}
|
||||
@@ -955,7 +950,6 @@ void PropertyLinkList::set1Value(int idx, DocumentObject* const& value)
|
||||
|
||||
_nameMap.clear();
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
if (getContainer() && getContainer()->isDerivedFrom<App::DocumentObject>()) {
|
||||
App::DocumentObject* parent = static_cast<DocumentObject*>(getContainer());
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -969,7 +963,6 @@ void PropertyLinkList::set1Value(int idx, DocumentObject* const& value)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inherited::set1Value(idx, value);
|
||||
}
|
||||
@@ -993,7 +986,6 @@ void PropertyLinkList::setValues(const std::vector<DocumentObject*>& value)
|
||||
}
|
||||
_nameMap.clear();
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain the back link in the DocumentObject class
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -1011,7 +1003,7 @@ void PropertyLinkList::setValues(const std::vector<DocumentObject*>& value)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inherited::setValues(value);
|
||||
}
|
||||
|
||||
@@ -1298,7 +1290,7 @@ PropertyLinkSub::PropertyLinkSub() = default;
|
||||
PropertyLinkSub::~PropertyLinkSub()
|
||||
{
|
||||
// in case this property is dynamically removed
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (_pcLinkSub && getContainer()
|
||||
&& getContainer()->isDerivedFrom<App::DocumentObject>()) {
|
||||
App::DocumentObject* parent = static_cast<DocumentObject*>(getContainer());
|
||||
@@ -1310,7 +1302,6 @@ PropertyLinkSub::~PropertyLinkSub()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PropertyLinkSub::setSyncSubObject(bool enable)
|
||||
@@ -1340,7 +1331,7 @@ void PropertyLinkSub::setValue(App::DocumentObject* lValue,
|
||||
}
|
||||
}
|
||||
aboutToSetValue();
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
// otherwise the backlink contains dangling pointers
|
||||
@@ -1353,7 +1344,7 @@ void PropertyLinkSub::setValue(App::DocumentObject* lValue,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_pcLinkSub = lValue;
|
||||
_cSubList = std::move(subs);
|
||||
if (shadows.size() == _cSubList.size()) {
|
||||
@@ -2176,7 +2167,7 @@ PropertyLinkSubList::PropertyLinkSubList() = default;
|
||||
PropertyLinkSubList::~PropertyLinkSubList()
|
||||
{
|
||||
// in case this property is dynamically removed
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
// maintain backlinks
|
||||
if (!_lValueList.empty() && getContainer()
|
||||
&& getContainer()->isDerivedFrom<App::DocumentObject>()) {
|
||||
@@ -2191,7 +2182,6 @@ PropertyLinkSubList::~PropertyLinkSubList()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PropertyLinkSubList::setSyncSubObject(bool enable)
|
||||
@@ -2228,7 +2218,6 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const char* SubName)
|
||||
auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
|
||||
verifyObject(lValue, parent);
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain backlinks
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -2244,7 +2233,6 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const char* SubName)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lValue) {
|
||||
aboutToSetValue();
|
||||
@@ -2276,7 +2264,6 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,
|
||||
"PropertyLinkSubList::setValues: size of subelements list != size of objects list");
|
||||
}
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain backlinks.
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -2299,7 +2286,6 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
aboutToSetValue();
|
||||
_lValueList = lValue;
|
||||
@@ -2338,7 +2324,6 @@ void PropertyLinkSubList::setValues(std::vector<DocumentObject*>&& lValue,
|
||||
"PropertyLinkSubList::setValues: size of subelements list != size of objects list");
|
||||
}
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain backlinks.
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -2361,7 +2346,6 @@ void PropertyLinkSubList::setValues(std::vector<DocumentObject*>&& lValue,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
aboutToSetValue();
|
||||
_lValueList = std::move(lValue);
|
||||
@@ -2382,7 +2366,6 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector<std
|
||||
auto parent = dynamic_cast<App::DocumentObject*>(getContainer());
|
||||
verifyObject(lValue, parent);
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain backlinks.
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -2403,7 +2386,6 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue, const std::vector<std
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
aboutToSetValue();
|
||||
std::size_t size = SubList.size();
|
||||
@@ -2431,7 +2413,6 @@ void PropertyLinkSubList::addValue(App::DocumentObject* obj,
|
||||
auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
|
||||
verifyObject(obj, parent);
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// maintain backlinks.
|
||||
if (parent) {
|
||||
// before accessing internals make sure the object is not about to be destroyed
|
||||
@@ -2454,7 +2435,6 @@ void PropertyLinkSubList::addValue(App::DocumentObject* obj,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<DocumentObject*> valueList;
|
||||
std::vector<std::string> subList;
|
||||
@@ -3850,11 +3830,11 @@ void PropertyXLink::restoreLink(App::DocumentObject* lValue)
|
||||
setFlag(LinkDetached, false);
|
||||
setFlag(LinkRestoring);
|
||||
aboutToSetValue();
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (!owner->testStatus(ObjectStatus::Destroy) && _pcScope != LinkScope::Hidden) {
|
||||
lValue->_addBackLink(owner);
|
||||
}
|
||||
#endif
|
||||
|
||||
_pcLink = lValue;
|
||||
updateElementReference(nullptr);
|
||||
hasSetValue();
|
||||
@@ -3910,7 +3890,7 @@ void PropertyXLink::setValue(App::DocumentObject* lValue,
|
||||
}
|
||||
|
||||
setFlag(LinkDetached, false);
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (!owner->testStatus(ObjectStatus::Destroy) && _pcScope != LinkScope::Hidden) {
|
||||
if (_pcLink) {
|
||||
_pcLink->_removeBackLink(owner);
|
||||
@@ -3919,7 +3899,7 @@ void PropertyXLink::setValue(App::DocumentObject* lValue,
|
||||
lValue->_addBackLink(owner);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (docInfo != info) {
|
||||
unlink();
|
||||
docInfo = info;
|
||||
@@ -3969,11 +3949,11 @@ void PropertyXLink::setValue(std::string&& filename,
|
||||
}
|
||||
setFlag(LinkDetached, false);
|
||||
aboutToSetValue();
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (_pcLink && !owner->testStatus(ObjectStatus::Destroy) && _pcScope != LinkScope::Hidden) {
|
||||
_pcLink->_removeBackLink(owner);
|
||||
}
|
||||
#endif
|
||||
|
||||
_pcLink = nullptr;
|
||||
if (docInfo != info) {
|
||||
unlink();
|
||||
@@ -5965,7 +5945,7 @@ void PropertyXLinkContainer::clearDeps()
|
||||
if (!owner || !owner->isAttachedToDocument()) {
|
||||
return;
|
||||
}
|
||||
#ifndef USE_OLD_DAG
|
||||
|
||||
if (!owner->testStatus(ObjectStatus::Destroy)) {
|
||||
for (auto& v : _Deps) {
|
||||
auto obj = v.first;
|
||||
@@ -5975,7 +5955,7 @@ void PropertyXLinkContainer::clearDeps()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_Deps.clear();
|
||||
_XLinks.clear();
|
||||
_LinkRestored = false;
|
||||
|
||||
@@ -2223,7 +2223,7 @@ PropertyColor::~PropertyColor() = default;
|
||||
//**************************************************************************
|
||||
// Base class implementer
|
||||
|
||||
void PropertyColor::setValue(const Color& col)
|
||||
void PropertyColor::setValue(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_cCol = col;
|
||||
@@ -2244,7 +2244,7 @@ void PropertyColor::setValue(float r, float g, float b, float a)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
const Color& PropertyColor::getValue() const
|
||||
const Base::Color& PropertyColor::getValue() const
|
||||
{
|
||||
return _cCol;
|
||||
}
|
||||
@@ -2267,7 +2267,7 @@ PyObject* PropertyColor::getPyObject()
|
||||
|
||||
void PropertyColor::setPyObject(PyObject* value)
|
||||
{
|
||||
App::Color cCol;
|
||||
Base::Color cCol;
|
||||
if (PyTuple_Check(value) && (PyTuple_Size(value) == 3 || PyTuple_Size(value) == 4)) {
|
||||
PyObject* item;
|
||||
item = PyTuple_GetItem(value, 0);
|
||||
@@ -2407,7 +2407,7 @@ PyObject* PropertyColorList::getPyObject()
|
||||
return list;
|
||||
}
|
||||
|
||||
Color PropertyColorList::getPyValue(PyObject* item) const
|
||||
Base::Color PropertyColorList::getPyValue(PyObject* item) const
|
||||
{
|
||||
PropertyColor col;
|
||||
col.setPyObject(item);
|
||||
@@ -2451,7 +2451,7 @@ void PropertyColorList::RestoreDocFile(Base::Reader& reader)
|
||||
Base::InputStream str(reader);
|
||||
uint32_t uCt = 0;
|
||||
str >> uCt;
|
||||
std::vector<Color> values(uCt);
|
||||
std::vector<Base::Color> values(uCt);
|
||||
uint32_t value; // must be 32 bit long
|
||||
for (auto& it : values) {
|
||||
str >> value;
|
||||
@@ -2474,7 +2474,7 @@ void PropertyColorList::Paste(const Property& from)
|
||||
|
||||
unsigned int PropertyColorList::getMemSize() const
|
||||
{
|
||||
return static_cast<unsigned int>(_lValueList.size() * sizeof(Color));
|
||||
return static_cast<unsigned int>(_lValueList.size() * sizeof(Base::Color));
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
@@ -2495,7 +2495,7 @@ void PropertyMaterial::setValue(const Material& mat)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setValue(const Color& col)
|
||||
void PropertyMaterial::setValue(const Base::Color& col)
|
||||
{
|
||||
setDiffuseColor(col);
|
||||
}
|
||||
@@ -2515,7 +2515,7 @@ const Material& PropertyMaterial::getValue() const
|
||||
return _cMat;
|
||||
}
|
||||
|
||||
void PropertyMaterial::setAmbientColor(const Color& col)
|
||||
void PropertyMaterial::setAmbientColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_cMat.ambientColor = col;
|
||||
@@ -2536,7 +2536,7 @@ void PropertyMaterial::setAmbientColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setDiffuseColor(const Color& col)
|
||||
void PropertyMaterial::setDiffuseColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_cMat.diffuseColor = col;
|
||||
@@ -2557,7 +2557,7 @@ void PropertyMaterial::setDiffuseColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setSpecularColor(const Color& col)
|
||||
void PropertyMaterial::setSpecularColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_cMat.specularColor = col;
|
||||
@@ -2578,7 +2578,7 @@ void PropertyMaterial::setSpecularColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setEmissiveColor(const Color& col)
|
||||
void PropertyMaterial::setEmissiveColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_cMat.emissiveColor = col;
|
||||
@@ -2613,22 +2613,22 @@ void PropertyMaterial::setTransparency(float val)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
const Color& PropertyMaterial::getAmbientColor() const
|
||||
const Base::Color& PropertyMaterial::getAmbientColor() const
|
||||
{
|
||||
return _cMat.ambientColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterial::getDiffuseColor() const
|
||||
const Base::Color& PropertyMaterial::getDiffuseColor() const
|
||||
{
|
||||
return _cMat.diffuseColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterial::getSpecularColor() const
|
||||
const Base::Color& PropertyMaterial::getSpecularColor() const
|
||||
{
|
||||
return _cMat.specularColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterial::getEmissiveColor() const
|
||||
const Base::Color& PropertyMaterial::getEmissiveColor() const
|
||||
{
|
||||
return _cMat.emissiveColor;
|
||||
}
|
||||
@@ -2816,7 +2816,7 @@ void PropertyMaterialList::setValue(int index, const Material& mat)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setAmbientColor(const Color& col)
|
||||
void PropertyMaterialList::setAmbientColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
setMinimumSizeOne();
|
||||
@@ -2846,7 +2846,7 @@ void PropertyMaterialList::setAmbientColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setAmbientColor(int index, const Color& col)
|
||||
void PropertyMaterialList::setAmbientColor(int index, const Base::Color& col)
|
||||
{
|
||||
verifyIndex(index);
|
||||
|
||||
@@ -2876,7 +2876,7 @@ void PropertyMaterialList::setAmbientColor(int index, uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setDiffuseColor(const Color& col)
|
||||
void PropertyMaterialList::setDiffuseColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
setMinimumSizeOne();
|
||||
@@ -2906,7 +2906,7 @@ void PropertyMaterialList::setDiffuseColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setDiffuseColor(int index, const Color& col)
|
||||
void PropertyMaterialList::setDiffuseColor(int index, const Base::Color& col)
|
||||
{
|
||||
verifyIndex(index);
|
||||
|
||||
@@ -2936,7 +2936,7 @@ void PropertyMaterialList::setDiffuseColor(int index, uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setDiffuseColors(const std::vector<App::Color>& colors)
|
||||
void PropertyMaterialList::setDiffuseColors(const std::vector<Base::Color>& colors)
|
||||
{
|
||||
aboutToSetValue();
|
||||
setSize(colors.size(), _lValueList[0]);
|
||||
@@ -2947,7 +2947,7 @@ void PropertyMaterialList::setDiffuseColors(const std::vector<App::Color>& color
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setSpecularColor(const Color& col)
|
||||
void PropertyMaterialList::setSpecularColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
setMinimumSizeOne();
|
||||
@@ -2977,7 +2977,7 @@ void PropertyMaterialList::setSpecularColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setSpecularColor(int index, const Color& col)
|
||||
void PropertyMaterialList::setSpecularColor(int index, const Base::Color& col)
|
||||
{
|
||||
verifyIndex(index);
|
||||
|
||||
@@ -3007,7 +3007,7 @@ void PropertyMaterialList::setSpecularColor(int index, uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setEmissiveColor(const Color& col)
|
||||
void PropertyMaterialList::setEmissiveColor(const Base::Color& col)
|
||||
{
|
||||
aboutToSetValue();
|
||||
setMinimumSizeOne();
|
||||
@@ -3037,7 +3037,7 @@ void PropertyMaterialList::setEmissiveColor(uint32_t rgba)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterialList::setEmissiveColor(int index, const Color& col)
|
||||
void PropertyMaterialList::setEmissiveColor(int index, const Base::Color& col)
|
||||
{
|
||||
verifyIndex(index);
|
||||
|
||||
@@ -3118,29 +3118,29 @@ void PropertyMaterialList::setTransparencies(const std::vector<float>& transpare
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getAmbientColor() const
|
||||
const Base::Color& PropertyMaterialList::getAmbientColor() const
|
||||
{
|
||||
return _lValueList[0].ambientColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getAmbientColor(int index) const
|
||||
const Base::Color& PropertyMaterialList::getAmbientColor(int index) const
|
||||
{
|
||||
return _lValueList[index].ambientColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getDiffuseColor() const
|
||||
const Base::Color& PropertyMaterialList::getDiffuseColor() const
|
||||
{
|
||||
return _lValueList[0].diffuseColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getDiffuseColor(int index) const
|
||||
const Base::Color& PropertyMaterialList::getDiffuseColor(int index) const
|
||||
{
|
||||
return _lValueList[index].diffuseColor;
|
||||
}
|
||||
|
||||
std::vector<App::Color> PropertyMaterialList::getDiffuseColors() const
|
||||
std::vector<Base::Color> PropertyMaterialList::getDiffuseColors() const
|
||||
{
|
||||
std::vector<App::Color> list;
|
||||
std::vector<Base::Color> list;
|
||||
for (auto& material : _lValueList) {
|
||||
list.push_back(material.diffuseColor);
|
||||
}
|
||||
@@ -3148,22 +3148,22 @@ std::vector<App::Color> PropertyMaterialList::getDiffuseColors() const
|
||||
return list;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getSpecularColor() const
|
||||
const Base::Color& PropertyMaterialList::getSpecularColor() const
|
||||
{
|
||||
return _lValueList[0].specularColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getSpecularColor(int index) const
|
||||
const Base::Color& PropertyMaterialList::getSpecularColor(int index) const
|
||||
{
|
||||
return _lValueList[index].specularColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getEmissiveColor() const
|
||||
const Base::Color& PropertyMaterialList::getEmissiveColor() const
|
||||
{
|
||||
return _lValueList[0].emissiveColor;
|
||||
}
|
||||
|
||||
const Color& PropertyMaterialList::getEmissiveColor(int index) const
|
||||
const Base::Color& PropertyMaterialList::getEmissiveColor(int index) const
|
||||
{
|
||||
return _lValueList[index].emissiveColor;
|
||||
}
|
||||
|
||||
+34
-34
@@ -999,7 +999,7 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
/** Color properties
|
||||
/** Base::Color properties
|
||||
* This is the father of all properties handling colors.
|
||||
*/
|
||||
class AppExport PropertyColor: public Property
|
||||
@@ -1021,13 +1021,13 @@ public:
|
||||
|
||||
/** Sets the property
|
||||
*/
|
||||
void setValue(const Color& col);
|
||||
void setValue(const Base::Color& col);
|
||||
void setValue(float r, float g, float b, float a = 1.0F);
|
||||
void setValue(uint32_t rgba);
|
||||
|
||||
/** This method returns a string representation of the property
|
||||
*/
|
||||
const Color& getValue() const;
|
||||
const Base::Color& getValue() const;
|
||||
|
||||
const char* getEditorName() const override
|
||||
{
|
||||
@@ -1045,7 +1045,7 @@ public:
|
||||
|
||||
unsigned int getMemSize() const override
|
||||
{
|
||||
return sizeof(Color);
|
||||
return sizeof(Base::Color);
|
||||
}
|
||||
|
||||
bool isSame(const Property& other) const override
|
||||
@@ -1058,10 +1058,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Color _cCol;
|
||||
Base::Color _cCol;
|
||||
};
|
||||
|
||||
class AppExport PropertyColorList: public PropertyListsT<Color>
|
||||
class AppExport PropertyColorList: public PropertyListsT<Base::Color>
|
||||
{
|
||||
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
||||
|
||||
@@ -1091,7 +1091,7 @@ public:
|
||||
unsigned int getMemSize() const override;
|
||||
|
||||
protected:
|
||||
Color getPyValue(PyObject* py) const override;
|
||||
Base::Color getPyValue(PyObject* py) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -1118,19 +1118,19 @@ public:
|
||||
/** Sets the property
|
||||
*/
|
||||
void setValue(const Material& mat);
|
||||
void setValue(const Color& col);
|
||||
void setValue(const Base::Color& col);
|
||||
void setValue(float r, float g, float b, float a = 1.0F);
|
||||
void setValue(uint32_t rgba);
|
||||
void setAmbientColor(const Color& col);
|
||||
void setAmbientColor(const Base::Color& col);
|
||||
void setAmbientColor(float r, float g, float b, float a = 1.0F);
|
||||
void setAmbientColor(uint32_t rgba);
|
||||
void setDiffuseColor(const Color& col);
|
||||
void setDiffuseColor(const Base::Color& col);
|
||||
void setDiffuseColor(float r, float g, float b, float a = 1.0F);
|
||||
void setDiffuseColor(uint32_t rgba);
|
||||
void setSpecularColor(const Color& col);
|
||||
void setSpecularColor(const Base::Color& col);
|
||||
void setSpecularColor(float r, float g, float b, float a = 1.0F);
|
||||
void setSpecularColor(uint32_t rgba);
|
||||
void setEmissiveColor(const Color& col);
|
||||
void setEmissiveColor(const Base::Color& col);
|
||||
void setEmissiveColor(float r, float g, float b, float a = 1.0F);
|
||||
void setEmissiveColor(uint32_t rgba);
|
||||
void setShininess(float);
|
||||
@@ -1139,10 +1139,10 @@ public:
|
||||
/** This method returns a string representation of the property
|
||||
*/
|
||||
const Material& getValue() const;
|
||||
const Color& getAmbientColor() const;
|
||||
const Color& getDiffuseColor() const;
|
||||
const Color& getSpecularColor() const;
|
||||
const Color& getEmissiveColor() const;
|
||||
const Base::Color& getAmbientColor() const;
|
||||
const Base::Color& getDiffuseColor() const;
|
||||
const Base::Color& getSpecularColor() const;
|
||||
const Base::Color& getEmissiveColor() const;
|
||||
double getShininess() const;
|
||||
double getTransparency() const;
|
||||
|
||||
@@ -1204,32 +1204,32 @@ public:
|
||||
void setValue(const Material& mat);
|
||||
void setValue(int index, const Material& mat);
|
||||
|
||||
void setAmbientColor(const Color& col);
|
||||
void setAmbientColor(const Base::Color& col);
|
||||
void setAmbientColor(float r, float g, float b, float a = 1.0F);
|
||||
void setAmbientColor(uint32_t rgba);
|
||||
void setAmbientColor(int index, const Color& col);
|
||||
void setAmbientColor(int index, const Base::Color& col);
|
||||
void setAmbientColor(int index, float r, float g, float b, float a = 1.0F);
|
||||
void setAmbientColor(int index, uint32_t rgba);
|
||||
|
||||
void setDiffuseColor(const Color& col);
|
||||
void setDiffuseColor(const Base::Color& col);
|
||||
void setDiffuseColor(float r, float g, float b, float a = 1.0F);
|
||||
void setDiffuseColor(uint32_t rgba);
|
||||
void setDiffuseColor(int index, const Color& col);
|
||||
void setDiffuseColor(int index, const Base::Color& col);
|
||||
void setDiffuseColor(int index, float r, float g, float b, float a = 1.0F);
|
||||
void setDiffuseColor(int index, uint32_t rgba);
|
||||
void setDiffuseColors(const std::vector<App::Color>& colors);
|
||||
void setDiffuseColors(const std::vector<Base::Color>& colors);
|
||||
|
||||
void setSpecularColor(const Color& col);
|
||||
void setSpecularColor(const Base::Color& col);
|
||||
void setSpecularColor(float r, float g, float b, float a = 1.0F);
|
||||
void setSpecularColor(uint32_t rgba);
|
||||
void setSpecularColor(int index, const Color& col);
|
||||
void setSpecularColor(int index, const Base::Color& col);
|
||||
void setSpecularColor(int index, float r, float g, float b, float a = 1.0F);
|
||||
void setSpecularColor(int index, uint32_t rgba);
|
||||
|
||||
void setEmissiveColor(const Color& col);
|
||||
void setEmissiveColor(const Base::Color& col);
|
||||
void setEmissiveColor(float r, float g, float b, float a = 1.0F);
|
||||
void setEmissiveColor(uint32_t rgba);
|
||||
void setEmissiveColor(int index, const Color& col);
|
||||
void setEmissiveColor(int index, const Base::Color& col);
|
||||
void setEmissiveColor(int index, float r, float g, float b, float a = 1.0F);
|
||||
void setEmissiveColor(int index, uint32_t rgba);
|
||||
|
||||
@@ -1240,18 +1240,18 @@ public:
|
||||
void setTransparency(int index, float);
|
||||
void setTransparencies(const std::vector<float>& transparencies);
|
||||
|
||||
const Color& getAmbientColor() const;
|
||||
const Color& getAmbientColor(int index) const;
|
||||
const Base::Color& getAmbientColor() const;
|
||||
const Base::Color& getAmbientColor(int index) const;
|
||||
|
||||
const Color& getDiffuseColor() const;
|
||||
const Color& getDiffuseColor(int index) const;
|
||||
std::vector<App::Color> getDiffuseColors() const;
|
||||
const Base::Color& getDiffuseColor() const;
|
||||
const Base::Color& getDiffuseColor(int index) const;
|
||||
std::vector<Base::Color> getDiffuseColors() const;
|
||||
|
||||
const Color& getSpecularColor() const;
|
||||
const Color& getSpecularColor(int index) const;
|
||||
const Base::Color& getSpecularColor() const;
|
||||
const Base::Color& getSpecularColor(int index) const;
|
||||
|
||||
const Color& getEmissiveColor() const;
|
||||
const Color& getEmissiveColor(int index) const;
|
||||
const Base::Color& getEmissiveColor() const;
|
||||
const Base::Color& getEmissiveColor(int index) const;
|
||||
|
||||
float getShininess() const;
|
||||
float getShininess(int index) const;
|
||||
|
||||
@@ -464,7 +464,6 @@ void TransactionDocumentObject::applyDel(Document& Doc, TransactionalObject* pcO
|
||||
if (status == Del) {
|
||||
DocumentObject* obj = static_cast<DocumentObject*>(pcObj);
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// Make sure the backlinks of all linked objects are updated. As the links of the removed
|
||||
// object are never set to [] they also do not remove the backlink. But as they are
|
||||
// not in the document anymore we need to remove them anyway to ensure a correct graph
|
||||
@@ -472,7 +471,6 @@ void TransactionDocumentObject::applyDel(Document& Doc, TransactionalObject* pcO
|
||||
for (auto link : list) {
|
||||
link->_removeBackLink(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
// simply filling in the saved object
|
||||
Doc._removeObject(obj);
|
||||
@@ -485,13 +483,11 @@ void TransactionDocumentObject::applyNew(Document& Doc, TransactionalObject* pcO
|
||||
DocumentObject* obj = static_cast<DocumentObject*>(pcObj);
|
||||
Doc._addObject(obj, _NameInDocument.c_str());
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
// make sure the backlinks of all linked objects are updated
|
||||
auto list = obj->getOutList();
|
||||
for (auto link : list) {
|
||||
link->_addBackLink(obj);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ struct DocumentP
|
||||
unsigned int UndoMaxStackSize;
|
||||
std::string programVersion;
|
||||
mutable HasherMap hashers;
|
||||
#ifdef USE_OLD_DAG
|
||||
DependencyList DepList;
|
||||
std::map<DocumentObject*, Vertex> VertexObjectList;
|
||||
std::map<Vertex, DocumentObject*> vertexMap;
|
||||
#endif // USE_OLD_DAG
|
||||
std::multimap<const App::DocumentObject*, std::unique_ptr<App::DocumentObjectExecReturn>>
|
||||
_RecomputeLog;
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
from Metadata import export
|
||||
from PyObjectBase import PyObjectBase
|
||||
from Vector import Vector
|
||||
from Placement import Placement
|
||||
from Axis import Axis
|
||||
from typing import overload
|
||||
|
||||
@export(
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
)
|
||||
class Axis(PyObjectBase):
|
||||
"""
|
||||
Base.Axis class.
|
||||
|
||||
An Axis defines a direction and a position (base) in 3D space.
|
||||
|
||||
The following constructors are supported:
|
||||
|
||||
Axis()
|
||||
Empty constructor.
|
||||
|
||||
Axis(axis)
|
||||
Copy constructor.
|
||||
axis : Base.Axis
|
||||
|
||||
Axis(base, direction)
|
||||
Define from a position and a direction.
|
||||
base : Base.Vector
|
||||
direction : Base.Vector
|
||||
"""
|
||||
|
||||
Base: Vector = ...
|
||||
"""Base position vector of the Axis."""
|
||||
|
||||
Direction: Vector = ...
|
||||
"""Direction vector of the Axis."""
|
||||
|
||||
# fmt: off
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, axis: Axis) -> None: ...
|
||||
@overload
|
||||
def __init__(self, base: Vector, direction: Vector) -> None: ...
|
||||
# fmt: on
|
||||
|
||||
def copy(self) -> Axis:
|
||||
"""
|
||||
copy() -> Base.Axis
|
||||
|
||||
Returns a copy of this Axis.
|
||||
"""
|
||||
...
|
||||
|
||||
def move(self, vector: Vector) -> None:
|
||||
"""
|
||||
move(vector) -> None
|
||||
|
||||
Move the axis base along the given vector.
|
||||
|
||||
vector : Base.Vector
|
||||
Vector by which to move the axis.
|
||||
"""
|
||||
...
|
||||
|
||||
def multiply(self, placement: Placement) -> Axis:
|
||||
"""
|
||||
multiply(placement) -> Base.Axis
|
||||
|
||||
Multiply this axis by a placement.
|
||||
|
||||
placement : Base.Placement
|
||||
Placement by which to multiply the axis.
|
||||
"""
|
||||
...
|
||||
|
||||
def reversed(self) -> Axis:
|
||||
"""
|
||||
reversed() -> Base.Axis
|
||||
|
||||
Compute the reversed axis. This returns a new Base.Axis with
|
||||
the original direction reversed.
|
||||
"""
|
||||
...
|
||||
@@ -0,0 +1,31 @@
|
||||
from Metadata import constmethod
|
||||
from PyObjectBase import PyObjectBase
|
||||
from typing import List, Final
|
||||
|
||||
class BaseClass(PyObjectBase):
|
||||
"""
|
||||
This is the base class
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
TypeId: Final[str] = ""
|
||||
"""Is the type of the FreeCAD object with module domain"""
|
||||
|
||||
Module: Final[str] = ""
|
||||
"""Module in which this class is defined"""
|
||||
|
||||
@constmethod
|
||||
def isDerivedFrom(self, typeName: str) -> bool:
|
||||
"""
|
||||
Returns true if given type is a father
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getAllDerivedFrom(self) -> List[object]:
|
||||
"""
|
||||
Returns all descendants
|
||||
"""
|
||||
...
|
||||
@@ -0,0 +1,370 @@
|
||||
from Metadata import export, constmethod
|
||||
from PyObjectBase import PyObjectBase
|
||||
from Vector import Vector
|
||||
from Matrix import Matrix
|
||||
from typing import overload, Any, Final, Tuple, Union
|
||||
|
||||
@export(
|
||||
TwinPointer="BoundBox3d",
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
)
|
||||
class BoundBox(PyObjectBase):
|
||||
"""
|
||||
Base.BoundBox class.
|
||||
|
||||
This class represents a bounding box.
|
||||
A bounding box is a rectangular cuboid which is a way to describe outer
|
||||
boundaries and is obtained from a lot of 3D types.
|
||||
It is often used to check if a 3D entity lies in the range of another object.
|
||||
Checking for bounding interference first can save a lot of computing time!
|
||||
An invalid BoundBox is represented by inconsistent values at each direction:
|
||||
The maximum float value of the system at the minimum coordinates, and the
|
||||
opposite value at the maximum coordinates.
|
||||
|
||||
The following constructors are supported:
|
||||
|
||||
BoundBox()
|
||||
Empty constructor. Returns an invalid BoundBox.
|
||||
|
||||
BoundBox(boundBox)
|
||||
Copy constructor.
|
||||
boundBox : Base.BoundBox
|
||||
|
||||
BoundBox(xMin, yMin=0, zMin=0, xMax=0, yMax=0, zMax=0)
|
||||
Define from the minimum and maximum values at each direction.
|
||||
xMin : float
|
||||
Minimum value at x-coordinate.
|
||||
yMin : float
|
||||
Minimum value at y-coordinate.
|
||||
zMin : float
|
||||
Minimum value at z-coordinate.
|
||||
xMax : float
|
||||
Maximum value at x-coordinate.
|
||||
yMax : float
|
||||
Maximum value at y-coordinate.
|
||||
zMax : float
|
||||
Maximum value at z-coordinate.
|
||||
|
||||
App.BoundBox(min, max)
|
||||
Define from two containers representing the minimum and maximum values of the
|
||||
coordinates in each direction.
|
||||
min : Base.Vector, tuple
|
||||
Minimum values of the coordinates.
|
||||
max : Base.Vector, tuple
|
||||
Maximum values of the coordinates.
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Center: Final[Any] = None
|
||||
"""Center point of the bounding box."""
|
||||
|
||||
XMax: float = 0.0
|
||||
"""The maximum x boundary position."""
|
||||
|
||||
YMax: float = 0.0
|
||||
"""The maximum y boundary position."""
|
||||
|
||||
ZMax: float = 0.0
|
||||
"""The maximum z boundary position."""
|
||||
|
||||
XMin: float = 0.0
|
||||
"""The minimum x boundary position."""
|
||||
|
||||
YMin: float = 0.0
|
||||
"""The minimum y boundary position."""
|
||||
|
||||
ZMin: float = 0.0
|
||||
"""The minimum z boundary position."""
|
||||
|
||||
XLength: Final[float] = 0.0
|
||||
"""Length of the bounding box in x direction."""
|
||||
|
||||
YLength: Final[float] = 0.0
|
||||
"""Length of the bounding box in y direction."""
|
||||
|
||||
ZLength: Final[float] = 0.0
|
||||
"""Length of the bounding box in z direction."""
|
||||
|
||||
DiagonalLength: Final[float] = 0.0
|
||||
"""Diagonal length of the bounding box."""
|
||||
|
||||
# fmt: off
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, boundBox: "BoundBox") -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
xMin: float,
|
||||
yMin: float = 0,
|
||||
zMin: float = 0,
|
||||
xMax: float = 0,
|
||||
yMax: float = 0,
|
||||
zMax: float = 0,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
min: Union[Vector, Tuple[float, float, float]],
|
||||
max: Union[Vector, Tuple[float, float, float]],
|
||||
) -> None: ...
|
||||
# fmt: on
|
||||
|
||||
def setVoid(self) -> None:
|
||||
"""
|
||||
setVoid() -> None
|
||||
|
||||
Invalidate the bounding box.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isValid(self) -> bool:
|
||||
"""
|
||||
isValid() -> bool
|
||||
|
||||
Checks if the bounding box is valid.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def add(self, minMax: Vector) -> None: ...
|
||||
@overload
|
||||
def add(self, minMax: Tuple[float, float, float]) -> None: ...
|
||||
@overload
|
||||
def add(self, x: float, y: float, z: float) -> None: ...
|
||||
def add(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""
|
||||
add(minMax) -> None
|
||||
add(x, y, z) -> None
|
||||
|
||||
Increase the maximum values or decrease the minimum values of this BoundBox by
|
||||
replacing the current values with the given values, so the bounding box can grow
|
||||
but not shrink.
|
||||
|
||||
minMax : Base.Vector, tuple
|
||||
Values to enlarge at each direction.
|
||||
x : float
|
||||
Value to enlarge at x-direction.
|
||||
y : float
|
||||
Value to enlarge at y-direction.
|
||||
z : float
|
||||
Value to enlarge at z-direction.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getPoint(self, index: int) -> Vector:
|
||||
"""
|
||||
getPoint(index) -> Base.Vector
|
||||
|
||||
Get the point of the given index.
|
||||
The index must be in the range of [0, 7].
|
||||
|
||||
index : int
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getEdge(self, index: int) -> Tuple[Vector, ...]:
|
||||
"""
|
||||
getEdge(index) -> tuple of Base.Vector
|
||||
|
||||
Get the edge points of the given index.
|
||||
The index must be in the range of [0, 11].
|
||||
|
||||
index : int
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def closestPoint(self, point: Vector) -> Vector: ...
|
||||
@overload
|
||||
def closestPoint(self, x: float, y: float, z: float) -> Vector: ...
|
||||
@constmethod
|
||||
def closestPoint(self, *args: Any, **kwargs: Any) -> Vector:
|
||||
"""
|
||||
closestPoint(point) -> Base.Vector
|
||||
closestPoint(x, y, z) -> Base.Vector
|
||||
|
||||
Get the closest point of the bounding box to the given point.
|
||||
|
||||
point : Base.Vector, tuple
|
||||
Coordinates of the given point.
|
||||
x : float
|
||||
X-coordinate of the given point.
|
||||
y : float
|
||||
Y-coordinate of the given point.
|
||||
z : float
|
||||
Z-coordinate of the given point.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def intersect(self, boundBox2: "BoundBox") -> bool: ...
|
||||
@overload
|
||||
def intersect(
|
||||
self,
|
||||
base: Union[Vector, Tuple[float, float, float]],
|
||||
dir: Union[Vector, Tuple[float, float, float]],
|
||||
) -> bool: ...
|
||||
def intersect(self, *args: Any) -> bool:
|
||||
"""
|
||||
intersect(boundBox2) -> bool
|
||||
intersect(base, dir) -> bool
|
||||
|
||||
Checks if the given object intersects with this bounding box. That can be
|
||||
another bounding box or a line specified by base and direction.
|
||||
|
||||
boundBox2 : Base.BoundBox
|
||||
base : Base.Vector, tuple
|
||||
dir : Base.Vector, tuple
|
||||
"""
|
||||
...
|
||||
|
||||
def intersected(self, boundBox2: "BoundBox") -> "BoundBox":
|
||||
"""
|
||||
intersected(boundBox2) -> Base.BoundBox
|
||||
|
||||
Returns the intersection of this and the given bounding box.
|
||||
|
||||
boundBox2 : Base.BoundBox
|
||||
"""
|
||||
...
|
||||
|
||||
def united(self, boundBox2: "BoundBox") -> "BoundBox":
|
||||
"""
|
||||
united(boundBox2) -> Base.BoundBox
|
||||
|
||||
Returns the union of this and the given bounding box.
|
||||
|
||||
boundBox2 : Base.BoundBox
|
||||
"""
|
||||
...
|
||||
|
||||
def enlarge(self, variation: float) -> None:
|
||||
"""
|
||||
enlarge(variation) -> None
|
||||
|
||||
Decrease the minimum values and increase the maximum values by the given value.
|
||||
A negative value shrinks the bounding box.
|
||||
|
||||
variation : float
|
||||
"""
|
||||
...
|
||||
|
||||
def getIntersectionPoint(self, base: Vector, dir: Vector, epsilon: float = 0.0001) -> Vector:
|
||||
"""
|
||||
getIntersectionPoint(base, dir, epsilon=0.0001) -> Base.Vector
|
||||
|
||||
Calculate the intersection point of a line with the bounding box.
|
||||
The base point must lie inside the bounding box, if not an exception is thrown.
|
||||
|
||||
base : Base.Vector
|
||||
Base point of the line.
|
||||
dir : Base.Vector
|
||||
Direction of the line.
|
||||
epsilon : float
|
||||
Bounding box size tolerance.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def move(self, displacement: Vector) -> None: ...
|
||||
@overload
|
||||
def move(self, displacement: Tuple[float, float, float]) -> None: ...
|
||||
@overload
|
||||
def move(self, x: float, y: float, z: float) -> None: ...
|
||||
def move(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""
|
||||
move(displacement) -> None
|
||||
move(x, y, z) -> None
|
||||
|
||||
Move the bounding box by the given values.
|
||||
|
||||
displacement : Base.Vector, tuple
|
||||
Displacement at each direction.
|
||||
x : float
|
||||
Displacement at x-direction.
|
||||
y : float
|
||||
Displacement at y-direction.
|
||||
z : float
|
||||
Displacement at z-direction.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def scale(self, factor: Vector) -> None: ...
|
||||
@overload
|
||||
def scale(self, factor: Tuple[float, float, float]) -> None: ...
|
||||
@overload
|
||||
def scale(self, x: float, y: float, z: float) -> None: ...
|
||||
def scale(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""
|
||||
scale(factor) -> None
|
||||
scale(x, y, z) -> None
|
||||
|
||||
Scale the bounding box by the given values.
|
||||
|
||||
factor : Base.Vector, tuple
|
||||
Factor scale at each direction.
|
||||
x : float
|
||||
Scale at x-direction.
|
||||
y : float
|
||||
Scale at y-direction.
|
||||
z : float
|
||||
Scale at z-direction.
|
||||
"""
|
||||
...
|
||||
|
||||
def transformed(self, matrix: Matrix) -> "BoundBox":
|
||||
"""
|
||||
transformed(matrix) -> Base.BoundBox
|
||||
|
||||
Returns a new BoundBox containing the transformed rectangular cuboid
|
||||
represented by this BoundBox.
|
||||
|
||||
matrix : Base.Matrix
|
||||
Transformation matrix.
|
||||
"""
|
||||
...
|
||||
|
||||
def isCutPlane(self, base: Vector, normal: Vector) -> bool:
|
||||
"""
|
||||
isCutPlane(base, normal) -> bool
|
||||
|
||||
Check if the plane specified by base and normal intersects (cuts) this bounding
|
||||
box.
|
||||
|
||||
base : Base.Vector
|
||||
normal : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def isInside(self, object: Vector) -> bool: ...
|
||||
@overload
|
||||
def isInside(self, object: "BoundBox") -> bool: ...
|
||||
@overload
|
||||
def isInside(self, x: float, y: float, z: float) -> bool: ...
|
||||
def isInside(self, *args: Any) -> bool:
|
||||
"""
|
||||
isInside(object) -> bool
|
||||
isInside(x, y, z) -> bool
|
||||
|
||||
Check if a point or a bounding box is inside this bounding box.
|
||||
|
||||
object : Base.Vector, Base.BoundBox
|
||||
Object to check if it is inside this bounding box.
|
||||
x : float
|
||||
X-coordinate of the point to check.
|
||||
y : float
|
||||
Y-coordinate of the point to check.
|
||||
z : float
|
||||
Z-coordinate of the point to check.
|
||||
"""
|
||||
...
|
||||
@@ -10,6 +10,10 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PYCXX_INCLUDE_DIR}
|
||||
${Python3_INCLUDE_DIRS}
|
||||
@@ -75,18 +79,31 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
endif()
|
||||
|
||||
generate_from_xml(TypePy)
|
||||
generate_from_py(Type)
|
||||
generate_from_xml(BaseClassPy)
|
||||
generate_from_py(BaseClass)
|
||||
generate_from_xml(BoundBoxPy)
|
||||
generate_from_py(BoundBox)
|
||||
generate_from_xml(CoordinateSystemPy)
|
||||
generate_from_py(CoordinateSystem)
|
||||
generate_from_xml(PersistencePy)
|
||||
generate_from_py(Persistence)
|
||||
generate_from_xml(VectorPy)
|
||||
generate_from_py(Vector)
|
||||
generate_from_xml(MatrixPy)
|
||||
generate_from_py(Matrix)
|
||||
generate_from_xml(RotationPy)
|
||||
generate_from_py(Rotation)
|
||||
generate_from_xml(PlacementPy)
|
||||
generate_from_py(Placement)
|
||||
generate_from_xml(AxisPy)
|
||||
generate_from_py(Axis)
|
||||
generate_from_xml(UnitPy)
|
||||
generate_from_py(Unit)
|
||||
generate_from_xml(QuantityPy)
|
||||
generate_from_py(Quantity)
|
||||
generate_from_xml(PrecisionPy)
|
||||
generate_from_py(Precision)
|
||||
generate_from_any(Parameter.xsd Parameter.inl xmlSchemeString)
|
||||
|
||||
if(SWIG_FOUND)
|
||||
@@ -174,6 +191,7 @@ SET(FreeCADBase_CPP_SRCS
|
||||
Builder3D.cpp
|
||||
Console.cpp
|
||||
ConsoleObserver.cpp
|
||||
Color.cpp
|
||||
CoordinateSystem.cpp
|
||||
CoordinateSystemPyImp.cpp
|
||||
Debugger.cpp
|
||||
@@ -245,6 +263,7 @@ SET(FreeCADBase_HPP_SRCS
|
||||
Console.h
|
||||
ConsoleObserver.h
|
||||
Converter.h
|
||||
Color.h
|
||||
CoordinateSystem.h
|
||||
Debugger.h
|
||||
DualNumber.h
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
using namespace App;
|
||||
using namespace Base;
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <FCGlobal.h>
|
||||
|
||||
// NOLINTBEGIN(readability-magic-numbers)
|
||||
namespace App
|
||||
namespace Base
|
||||
{
|
||||
|
||||
template<class color_type>
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
|
||||
/** Color class
|
||||
*/
|
||||
class AppExport Color
|
||||
class BaseExport Color
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -226,7 +226,92 @@ public:
|
||||
float r {}, g {}, b {}, a {};
|
||||
};
|
||||
|
||||
} // namespace App
|
||||
// Specialization for Color
|
||||
template<>
|
||||
struct color_traits<Base::Color>
|
||||
{
|
||||
using color_type = Base::Color;
|
||||
color_traits() = default;
|
||||
explicit color_traits(const color_type& ct)
|
||||
: ct(ct)
|
||||
{}
|
||||
float redF() const
|
||||
{
|
||||
return ct.r;
|
||||
}
|
||||
float greenF() const
|
||||
{
|
||||
return ct.g;
|
||||
}
|
||||
float blueF() const
|
||||
{
|
||||
return ct.b;
|
||||
}
|
||||
float alphaF() const
|
||||
{
|
||||
return ct.a;
|
||||
}
|
||||
void setRedF(float red)
|
||||
{
|
||||
ct.r = red;
|
||||
}
|
||||
void setGreenF(float green)
|
||||
{
|
||||
ct.g = green;
|
||||
}
|
||||
void setBlueF(float blue)
|
||||
{
|
||||
ct.b = blue;
|
||||
}
|
||||
void setAlphaF(float alpha)
|
||||
{
|
||||
ct.a = alpha;
|
||||
}
|
||||
int red() const
|
||||
{
|
||||
return int(std::lround(ct.r * 255.0F));
|
||||
}
|
||||
int green() const
|
||||
{
|
||||
return int(std::lround(ct.g * 255.0F));
|
||||
}
|
||||
int blue() const
|
||||
{
|
||||
return int(std::lround(ct.b * 255.0F));
|
||||
}
|
||||
int alpha() const
|
||||
{
|
||||
return int(std::lround(ct.a * 255.0F));
|
||||
}
|
||||
void setRed(int red)
|
||||
{
|
||||
ct.r = static_cast<float>(red) / 255.0F;
|
||||
}
|
||||
void setGreen(int green)
|
||||
{
|
||||
ct.g = static_cast<float>(green) / 255.0F;
|
||||
}
|
||||
void setBlue(int blue)
|
||||
{
|
||||
ct.b = static_cast<float>(blue) / 255.0F;
|
||||
}
|
||||
void setAlpha(int alpha)
|
||||
{
|
||||
ct.a = static_cast<float>(alpha) / 255.0F;
|
||||
}
|
||||
static color_type makeColor(int red, int green, int blue, int alpha = 255)
|
||||
{
|
||||
return color_type {static_cast<float>(red) / 255.0F,
|
||||
static_cast<float>(green) / 255.0F,
|
||||
static_cast<float>(blue) / 255.0F,
|
||||
static_cast<float>(alpha) / 255.0F};
|
||||
}
|
||||
|
||||
private:
|
||||
color_type ct;
|
||||
};
|
||||
|
||||
} // namespace Base
|
||||
// NOLINTEND(readability-magic-numbers)
|
||||
|
||||
#endif // APP_COLOR_H
|
||||
+11
-1
@@ -1169,7 +1169,17 @@ template<Base::LogStyle category,
|
||||
inline void
|
||||
Base::ConsoleSingleton::Send(const std::string& notifiername, const char* pMsg, Args&&... args)
|
||||
{
|
||||
std::string format = fmt::sprintf(pMsg, args...);
|
||||
std::string format;
|
||||
try {
|
||||
format = fmt::sprintf(pMsg, args...);
|
||||
}
|
||||
catch (fmt::format_error& e) {
|
||||
// We can't allow an exception to propagate out of this method, which gets used in some
|
||||
// destructors. Instead, make the string's contents the error message that fmt::sprintf gave
|
||||
// us.
|
||||
format = std::string("ERROR: Invalid format string or arguments provided.\n");
|
||||
format += e.what();
|
||||
}
|
||||
|
||||
if (connectionMode == Direct) {
|
||||
Notify<category, recipient, contenttype>(notifiername, format);
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
from Metadata import export, constmethod
|
||||
from PyObjectBase import PyObjectBase
|
||||
from Axis import Axis as AxisPy
|
||||
from Vector import Vector
|
||||
from Placement import Placement
|
||||
from Rotation import Rotation
|
||||
from typing import Union
|
||||
|
||||
@export(
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
)
|
||||
class CoordinateSystem(PyObjectBase):
|
||||
"""
|
||||
Base.CoordinateSystem class.
|
||||
|
||||
An orthonormal right-handed coordinate system in 3D space.
|
||||
|
||||
CoordinateSystem()
|
||||
Empty constructor.
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Axis: AxisPy = None
|
||||
"""Set or get axis."""
|
||||
|
||||
XDirection: Vector = None
|
||||
"""Set or get X-direction."""
|
||||
|
||||
YDirection: Vector = None
|
||||
"""Set or get Y-direction."""
|
||||
|
||||
ZDirection: Vector = None
|
||||
"""Set or get Z-direction."""
|
||||
|
||||
Position: Vector = None
|
||||
"""Set or get position."""
|
||||
|
||||
def setAxes(self, axis: Union[AxisPy, Vector], xDir: Vector) -> None:
|
||||
"""
|
||||
setAxes(axis, xDir) -> None
|
||||
|
||||
Set axis or Z-direction, and X-direction.
|
||||
The X-direction is determined from the orthonormal compononent of `xDir`
|
||||
with respect to `axis` direction.
|
||||
|
||||
axis : Base.Axis, Base.Vector
|
||||
xDir : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def displacement(self, coordSystem2: "CoordinateSystem") -> Placement:
|
||||
"""
|
||||
displacement(coordSystem2) -> Base.Placement
|
||||
|
||||
Computes the placement from this to the passed coordinate system `coordSystem2`.
|
||||
|
||||
coordSystem2 : Base.CoordinateSystem
|
||||
"""
|
||||
...
|
||||
|
||||
def transformTo(self, vector: Vector) -> Vector:
|
||||
"""
|
||||
transformTo(vector) -> Base.Vector
|
||||
|
||||
Computes the coordinates of the point in coordinates of this coordinate system.
|
||||
|
||||
vector : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
def transform(self, trans: Union[Rotation, Placement]) -> None:
|
||||
"""
|
||||
transform(trans) -> None
|
||||
|
||||
Applies a transformation on this coordinate system.
|
||||
|
||||
trans : Base.Rotation, Base.Placement
|
||||
"""
|
||||
...
|
||||
|
||||
def setPlacement(self, placement: Placement) -> None:
|
||||
"""
|
||||
setPlacment(placement) -> None
|
||||
|
||||
Set placement to the coordinate system.
|
||||
|
||||
placement : Base.Placement
|
||||
"""
|
||||
...
|
||||
@@ -0,0 +1,445 @@
|
||||
from Vector import Vector
|
||||
from Metadata import export, constmethod, class_declarations, no_args
|
||||
from PyObjectBase import PyObjectBase
|
||||
from enum import IntEnum
|
||||
from typing import overload, Union, Tuple, Sequence
|
||||
|
||||
class ScaleType(IntEnum):
|
||||
Other = -1
|
||||
NoScaling = 0
|
||||
NonUniformRight = 1
|
||||
NonUniformLeft = 2
|
||||
Uniform = 3
|
||||
|
||||
@export(
|
||||
TwinPointer="Matrix4D",
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
NumberProtocol=True,
|
||||
RichCompare=True,
|
||||
)
|
||||
@class_declarations(
|
||||
"""public:
|
||||
MatrixPy(const Matrix4D & mat, PyTypeObject *T = &Type)
|
||||
:PyObjectBase(new Matrix4D(mat),T){}
|
||||
Matrix4D value() const
|
||||
{ return *(getMatrixPtr()); }
|
||||
"""
|
||||
)
|
||||
class Matrix(PyObjectBase):
|
||||
"""
|
||||
Base.Matrix class.
|
||||
|
||||
A 4x4 Matrix.
|
||||
In particular, this matrix can represent an affine transformation, that is,
|
||||
given a 3D vector `x`, apply the transformation y = M*x + b, where the matrix
|
||||
`M` is a linear map and the vector `b` is a translation.
|
||||
`y` can be obtained using a linear transformation represented by the 4x4 matrix
|
||||
`A` conformed by the augmented 3x4 matrix (M|b), augmented by row with
|
||||
(0,0,0,1), therefore: (y, 1) = A*(x, 1).
|
||||
|
||||
The following constructors are supported:
|
||||
|
||||
Matrix()
|
||||
Empty constructor.
|
||||
|
||||
Matrix(matrix)
|
||||
Copy constructor.
|
||||
matrix : Base.Matrix.
|
||||
|
||||
Matrix(*coef)
|
||||
Define from 16 coefficients of the 4x4 matrix.
|
||||
coef : sequence of float
|
||||
The sequence can have up to 16 elements which complete the matrix by rows.
|
||||
|
||||
Matrix(vector1, vector2, vector3, vector4)
|
||||
Define from four 3D vectors which represent the columns of the 3x4 submatrix,
|
||||
useful to represent an affine transformation. The fourth row is made up by
|
||||
(0,0,0,1).
|
||||
vector1 : Base.Vector
|
||||
vector2 : Base.Vector
|
||||
vector3 : Base.Vector
|
||||
vector4 : Base.Vector
|
||||
Default to (0,0,0). Optional.
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
A11: float = 0.0
|
||||
"""The (1,1) matrix element."""
|
||||
A12: float = 0.0
|
||||
"""The (1,2) matrix element."""
|
||||
A13: float = 0.0
|
||||
"""The (1,3) matrix element."""
|
||||
A14: float = 0.0
|
||||
"""The (1,4) matrix element."""
|
||||
A21: float = 0.0
|
||||
"""The (2,1) matrix element."""
|
||||
A22: float = 0.0
|
||||
"""The (2,2) matrix element."""
|
||||
A23: float = 0.0
|
||||
"""The (2,3) matrix element."""
|
||||
A24: float = 0.0
|
||||
"""The (2,4) matrix element."""
|
||||
A31: float = 0.0
|
||||
"""The (3,1) matrix element."""
|
||||
A32: float = 0.0
|
||||
"""The (3,2) matrix element."""
|
||||
A33: float = 0.0
|
||||
"""The (3,3) matrix element."""
|
||||
A34: float = 0.0
|
||||
"""The (3,4) matrix element."""
|
||||
A41: float = 0.0
|
||||
"""The (4,1) matrix element."""
|
||||
A42: float = 0.0
|
||||
"""The (4,2) matrix element."""
|
||||
A43: float = 0.0
|
||||
"""The (4,3) matrix element."""
|
||||
A44: float = 0.0
|
||||
"""The (4,4) matrix element."""
|
||||
|
||||
A: Sequence[float] = []
|
||||
"""The matrix elements."""
|
||||
|
||||
@overload
|
||||
def move(self, vector: Vector) -> None: ...
|
||||
@overload
|
||||
def move(self, x: float, y: float, z: float) -> None: ...
|
||||
def move(self, *args) -> None:
|
||||
"""
|
||||
move(vector) -> None
|
||||
move(x, y, z) -> None
|
||||
|
||||
Move the matrix along a vector, equivalent to left multiply the matrix
|
||||
by a pure translation transformation.
|
||||
|
||||
vector : Base.Vector, tuple
|
||||
x : float
|
||||
`x` translation.
|
||||
y : float
|
||||
`y` translation.
|
||||
z : float
|
||||
`z` translation.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def scale(self, vector: Vector) -> None: ...
|
||||
@overload
|
||||
def scale(self, x: float, y: float, z: float) -> None: ...
|
||||
@overload
|
||||
def scale(self, factor: float) -> None: ...
|
||||
def scale(self, *args) -> None:
|
||||
"""
|
||||
scale(vector) -> None
|
||||
scale(x, y, z) -> None
|
||||
scale(factor) -> None
|
||||
|
||||
Scale the first three rows of the matrix.
|
||||
|
||||
vector : Base.Vector
|
||||
x : float
|
||||
First row factor scale.
|
||||
y : float
|
||||
Second row factor scale.
|
||||
z : float
|
||||
Third row factor scale.
|
||||
factor : float
|
||||
global factor scale.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def hasScale(self, tol: float = 0) -> ScaleType:
|
||||
"""
|
||||
hasScale(tol=0) -> ScaleType
|
||||
|
||||
Return an enum value of ScaleType. Possible values are:
|
||||
Uniform, NonUniformLeft, NonUniformRight, NoScaling or Other
|
||||
if it's not a scale matrix.
|
||||
|
||||
tol : float
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def decompose(self) -> Tuple["Matrix", "Matrix", "Matrix", "Matrix"]:
|
||||
"""
|
||||
decompose() -> Base.Matrix, Base.Matrix, Base.Matrix, Base.Matrix
|
||||
|
||||
Return a tuple of matrices representing shear, scale, rotation and move.
|
||||
So that matrix = move * rotation * scale * shear.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
def nullify(self) -> None:
|
||||
"""
|
||||
nullify() -> None
|
||||
|
||||
Make this the null matrix.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
@constmethod
|
||||
def isNull(self) -> bool:
|
||||
"""
|
||||
isNull() -> bool
|
||||
|
||||
Check if this is the null matrix.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
def unity(self) -> None:
|
||||
"""
|
||||
unity() -> None
|
||||
|
||||
Make this matrix to unity (4D identity matrix).
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isUnity(self, tol: float = 0.0) -> bool:
|
||||
"""
|
||||
isUnity([tol=0.0]) -> bool
|
||||
|
||||
Check if this is the unit matrix (4D identity matrix).
|
||||
"""
|
||||
...
|
||||
|
||||
def transform(self, vector: Vector, matrix2: "Matrix") -> None:
|
||||
"""
|
||||
transform(vector, matrix2) -> None
|
||||
|
||||
Transform the matrix around a given point.
|
||||
Equivalent to left multiply the matrix by T*M*T_inv, where M is `matrix2`, T the
|
||||
translation generated by `vector` and T_inv the inverse translation.
|
||||
For example, if `matrix2` is a rotation, the result is the transformation generated
|
||||
by the current matrix followed by a rotation around the point represented by `vector`.
|
||||
|
||||
vector : Base.Vector
|
||||
matrix2 : Base.Matrix
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def col(self, index: int) -> Vector:
|
||||
"""
|
||||
col(index) -> Base.Vector
|
||||
|
||||
Return the vector of a column, that is, the vector generated by the three
|
||||
first elements of the specified column.
|
||||
|
||||
index : int
|
||||
Required column index.
|
||||
"""
|
||||
...
|
||||
|
||||
def setCol(self, index: int, vector: Vector) -> None:
|
||||
"""
|
||||
setCol(index, vector) -> None
|
||||
|
||||
Set the vector of a column, that is, the three first elements of the specified
|
||||
column by index.
|
||||
|
||||
index : int
|
||||
Required column index.
|
||||
vector : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def row(self, index: int) -> Vector:
|
||||
"""
|
||||
row(index) -> Base.Vector
|
||||
|
||||
Return the vector of a row, that is, the vector generated by the three
|
||||
first elements of the specified row.
|
||||
|
||||
index : int
|
||||
Required row index.
|
||||
"""
|
||||
...
|
||||
|
||||
def setRow(self, index: int, vector: Vector) -> None:
|
||||
"""
|
||||
setRow(index, vector) -> None
|
||||
|
||||
Set the vector of a row, that is, the three first elements of the specified
|
||||
row by index.
|
||||
|
||||
index : int
|
||||
Required row index.
|
||||
vector : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
@constmethod
|
||||
def diagonal(self) -> Vector:
|
||||
"""
|
||||
diagonal() -> Base.Vector
|
||||
|
||||
Return the diagonal of the 3x3 leading principal submatrix as vector.
|
||||
"""
|
||||
...
|
||||
|
||||
def setDiagonal(self, vector: Vector) -> None:
|
||||
"""
|
||||
setDiagonal(vector) -> None
|
||||
|
||||
Set the diagonal of the 3x3 leading principal submatrix.
|
||||
|
||||
vector : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
def rotateX(self, angle: float) -> None:
|
||||
"""
|
||||
rotateX(angle) -> None
|
||||
|
||||
Rotate around X axis.
|
||||
|
||||
angle : float
|
||||
Angle in radians.
|
||||
"""
|
||||
...
|
||||
|
||||
def rotateY(self, angle: float) -> None:
|
||||
"""
|
||||
rotateY(angle) -> None
|
||||
|
||||
Rotate around Y axis.
|
||||
|
||||
angle : float
|
||||
Angle in radians.
|
||||
"""
|
||||
...
|
||||
|
||||
def rotateZ(self, angle: float) -> None:
|
||||
"""
|
||||
rotateZ(angle) -> None
|
||||
|
||||
Rotate around Z axis.
|
||||
|
||||
angle : float
|
||||
Angle in radians.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def multiply(self, matrix: "Matrix") -> "Matrix": ...
|
||||
@overload
|
||||
def multiply(self, vector: Vector) -> Vector: ...
|
||||
@constmethod
|
||||
def multiply(self, obj: Union["Matrix", Vector]) -> Union["Matrix", Vector]:
|
||||
"""
|
||||
multiply(matrix) -> Base.Matrix
|
||||
multiply(vector) -> Base.Vector
|
||||
|
||||
Right multiply the matrix by the given object.
|
||||
If the argument is a vector, this is augmented to the 4D vector (`vector`, 1).
|
||||
|
||||
matrix : Base.Matrix
|
||||
vector : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def multVec(self, vector: Vector) -> Vector:
|
||||
"""
|
||||
multVec(vector) -> Base.Vector
|
||||
|
||||
Compute the transformed vector using the matrix.
|
||||
|
||||
vector : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
def invert(self) -> None:
|
||||
"""
|
||||
invert() -> None
|
||||
|
||||
Compute the inverse matrix in-place, if possible.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
@constmethod
|
||||
def inverse(self) -> "Matrix":
|
||||
"""
|
||||
inverse() -> Base.Matrix
|
||||
|
||||
Compute the inverse matrix, if possible.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
def transpose(self) -> None:
|
||||
"""
|
||||
transpose() -> None
|
||||
|
||||
Transpose the matrix in-place.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
@constmethod
|
||||
def transposed(self) -> "Matrix":
|
||||
"""
|
||||
transposed() -> Base.Matrix
|
||||
|
||||
Returns a transposed copy of this matrix.
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
@constmethod
|
||||
def determinant(self) -> float:
|
||||
"""
|
||||
determinant() -> float
|
||||
|
||||
Compute the determinant of the matrix.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isOrthogonal(self, tol: float = 1e-6) -> float:
|
||||
"""
|
||||
isOrthogonal(tol=1e-6) -> float
|
||||
|
||||
Checks if the matrix is orthogonal, i.e. M * M^T = k*I and returns
|
||||
the multiple of the identity matrix. If it's not orthogonal 0 is returned.
|
||||
|
||||
tol : float
|
||||
Tolerance used to check orthogonality.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def submatrix(self, dim: int) -> "Matrix":
|
||||
"""
|
||||
submatrix(dim) -> Base.Matrix
|
||||
|
||||
Get the leading principal submatrix of the given dimension.
|
||||
The (4 - `dim`) remaining dimensions are completed with the
|
||||
corresponding identity matrix.
|
||||
|
||||
dim : int
|
||||
Dimension parameter must be in the range [1,4].
|
||||
"""
|
||||
...
|
||||
|
||||
@no_args
|
||||
@constmethod
|
||||
def analyze(self) -> str:
|
||||
"""
|
||||
analyze() -> str
|
||||
|
||||
Analyzes the type of transformation.
|
||||
"""
|
||||
...
|
||||
@@ -1252,6 +1252,55 @@ void ParameterGrp::RemoveUnsigned(const char* Name)
|
||||
Notify(Name);
|
||||
}
|
||||
|
||||
Base::Color ParameterGrp::GetColor(const char* Name, Base::Color lPreset) const
|
||||
{
|
||||
auto packed = GetUnsigned(Name, lPreset.getPackedValue());
|
||||
|
||||
return Color(static_cast<uint32_t>(packed));
|
||||
}
|
||||
|
||||
void ParameterGrp::SetColor(const char* Name, Base::Color lValue)
|
||||
{
|
||||
SetUnsigned(Name, lValue.getPackedValue());
|
||||
}
|
||||
|
||||
std::vector<Base::Color> ParameterGrp::GetColors(const char* sFilter) const
|
||||
{
|
||||
auto packed = GetUnsigneds(sFilter);
|
||||
std::vector<Base::Color> result;
|
||||
|
||||
std::transform(packed.begin(),
|
||||
packed.end(),
|
||||
std::back_inserter(result),
|
||||
[](const unsigned long lValue) {
|
||||
return Color(static_cast<uint32_t>(lValue));
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, Base::Color>>
|
||||
ParameterGrp::GetColorMap(const char* sFilter) const
|
||||
{
|
||||
auto packed = GetUnsignedMap(sFilter);
|
||||
std::vector<std::pair<std::string, Base::Color>> result;
|
||||
|
||||
std::transform(packed.begin(),
|
||||
packed.end(),
|
||||
std::back_inserter(result),
|
||||
[](const std::pair<std::string, unsigned long>& lValue) {
|
||||
return std::make_pair(lValue.first,
|
||||
Color(static_cast<uint32_t>(lValue.second)));
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ParameterGrp::RemoveColor(const char* Name)
|
||||
{
|
||||
RemoveUnsigned(Name);
|
||||
}
|
||||
|
||||
void ParameterGrp::RemoveGrp(const char* Name)
|
||||
{
|
||||
if (!_pGroupNode) {
|
||||
|
||||
+16
-1
@@ -52,6 +52,7 @@ using PyObject = struct _object;
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Observer.h"
|
||||
#include "Color.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4251)
|
||||
@@ -83,7 +84,6 @@ XERCES_CPP_NAMESPACE_END
|
||||
|
||||
class ParameterManager;
|
||||
|
||||
|
||||
/** The parameter container class
|
||||
* This is the base class of all classes handle parameter.
|
||||
* The class contains a map of key-value pairs in a grouping
|
||||
@@ -350,6 +350,21 @@ public:
|
||||
void RemoveUnsigned(const char* Name);
|
||||
//@}
|
||||
|
||||
/** @name methods for Colors handling, colors are persisted as packed uints */
|
||||
//@{
|
||||
/// read color value or give default
|
||||
Base::Color GetColor(const char* Name, Base::Color lPreset = Base::Color(1.0, 1.0, 1.0)) const;
|
||||
/// set a color value
|
||||
void SetColor(const char* Name, Base::Color lValue);
|
||||
/// get a vector of all color values in this group
|
||||
std::vector<Base::Color> GetColors(const char* sFilter = nullptr) const;
|
||||
/// get a map with all color values and the keys of this group
|
||||
std::vector<std::pair<std::string, Base::Color>>
|
||||
GetColorMap(const char* sFilter = nullptr) const;
|
||||
/// remove a color value from this group
|
||||
void RemoveColor(const char* Name);
|
||||
//@}
|
||||
|
||||
|
||||
/** @name methods for Float handling */
|
||||
//@{
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
from Metadata import constmethod
|
||||
from BaseClass import BaseClass
|
||||
from typing import Final
|
||||
|
||||
class Persistence(BaseClass):
|
||||
"""
|
||||
Base.Persistence class.
|
||||
|
||||
Class to dump and restore the content of an object.
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Content: Final[str] = ""
|
||||
"""Content of the object in XML representation."""
|
||||
|
||||
MemSize: Final[int] = 0
|
||||
"""Memory size of the object in bytes."""
|
||||
|
||||
@constmethod
|
||||
def dumpContent(self, *, Compression: int = 3) -> bytearray:
|
||||
"""
|
||||
dumpContent(Compression=3) -> bytearray
|
||||
|
||||
Dumps the content of the object, both the XML representation and the additional
|
||||
data files required, into a byte representation.
|
||||
|
||||
Compression : int
|
||||
Set the data compression level in the range [0,9]. Set to 0 for no compression.
|
||||
"""
|
||||
...
|
||||
|
||||
def restoreContent(self, obj: object) -> None:
|
||||
# TODO: Starting with Python 3.12, collections.abc.Buffer can be used for type hinting
|
||||
"""
|
||||
restoreContent(obj) -> None
|
||||
|
||||
Restore the content of the object from a byte representation as stored by `dumpContent`.
|
||||
It could be restored from any Python object implementing the buffer protocol.
|
||||
|
||||
obj : buffer
|
||||
Object with buffer protocol support.
|
||||
"""
|
||||
...
|
||||
@@ -0,0 +1,257 @@
|
||||
from Metadata import export, constmethod, class_declarations
|
||||
from PyObjectBase import PyObjectBase
|
||||
from Matrix import Matrix as MatrixPy
|
||||
from Rotation import Rotation as RotationPy
|
||||
from Vector import Vector
|
||||
from typing import Sequence, overload
|
||||
|
||||
@export(
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
NumberProtocol=True,
|
||||
RichCompare=True,
|
||||
)
|
||||
@class_declarations(
|
||||
"""public:
|
||||
PlacementPy(const Placement & pla, PyTypeObject *T = &Type)
|
||||
:PyObjectBase(new Placement(pla),T){}
|
||||
Placement value() const
|
||||
{ return *(getPlacementPtr()); }
|
||||
"""
|
||||
)
|
||||
class Placement(PyObjectBase):
|
||||
"""
|
||||
Base.Placement class.
|
||||
|
||||
A Placement defines an orientation (rotation) and a position (base) in 3D space.
|
||||
It is used when no scaling or other distortion is needed.
|
||||
|
||||
The following constructors are supported:
|
||||
|
||||
Placement()
|
||||
Empty constructor.
|
||||
|
||||
Placement(placement)
|
||||
Copy constructor.
|
||||
placement : Base.Placement
|
||||
|
||||
Placement(matrix)
|
||||
Define from a 4D matrix consisting of rotation and translation.
|
||||
matrix : Base.Matrix
|
||||
|
||||
Placement(base, rotation)
|
||||
Define from position and rotation.
|
||||
base : Base.Vector
|
||||
rotation : Base.Rotation
|
||||
|
||||
Placement(base, rotation, center)
|
||||
Define from position and rotation with center.
|
||||
base : Base.Vector
|
||||
rotation : Base.Rotation
|
||||
center : Base.Vector
|
||||
|
||||
Placement(base, axis, angle)
|
||||
define position and rotation.
|
||||
base : Base.Vector
|
||||
axis : Base.Vector
|
||||
angle : float
|
||||
"""
|
||||
|
||||
Base: Vector = None
|
||||
"""Vector to the Base Position of the Placement."""
|
||||
|
||||
Rotation: Vector = None
|
||||
"""Orientation of the placement expressed as rotation."""
|
||||
|
||||
Matrix: MatrixPy = None
|
||||
"""Set/get matrix representation of the placement."""
|
||||
|
||||
# fmt: off
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, placement: "Placement") -> None: ...
|
||||
@overload
|
||||
def __init__(self, matrix: MatrixPy) -> None: ...
|
||||
@overload
|
||||
def __init__(self, base: Vector, rotation: RotationPy) -> None: ...
|
||||
@overload
|
||||
def __init__(self, base: Vector, rotation: RotationPy, center: Vector) -> None: ...
|
||||
@overload
|
||||
def __init__(self, base: Vector, axis: Vector, angle: float) -> None: ...
|
||||
# fmt: on
|
||||
|
||||
@constmethod
|
||||
def copy(self) -> "Placement":
|
||||
"""
|
||||
copy() -> Base.Placement
|
||||
|
||||
Returns a copy of this placement.
|
||||
"""
|
||||
...
|
||||
|
||||
def move(self, vector: Vector) -> None:
|
||||
"""
|
||||
move(vector) -> None
|
||||
|
||||
Move the placement along a vector.
|
||||
|
||||
vector : Base.Vector
|
||||
Vector by which to move the placement.
|
||||
"""
|
||||
...
|
||||
|
||||
def translate(self, vector: Vector) -> None:
|
||||
"""
|
||||
translate(vector) -> None
|
||||
|
||||
Alias to move(), to be compatible with TopoShape.translate().
|
||||
|
||||
vector : Base.Vector
|
||||
Vector by which to move the placement.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def rotate(
|
||||
self, center: Sequence[float], axis: Sequence[float], angle: float, *, comp: bool = False
|
||||
) -> None: ...
|
||||
def rotate(self, center: Vector, axis: Vector, angle: float, *, comp: bool = False) -> None:
|
||||
"""
|
||||
rotate(center, axis, angle, comp) -> None
|
||||
|
||||
Rotate the current placement around center and axis with the given angle.
|
||||
This method is compatible with TopoShape.rotate() if the (optional) keyword
|
||||
argument comp is True (default=False).
|
||||
|
||||
center : Base.Vector, sequence of float
|
||||
Rotation center.
|
||||
axis : Base.Vector, sequence of float
|
||||
Rotation axis.
|
||||
angle : float
|
||||
Rotation angle in degrees.
|
||||
comp : bool
|
||||
optional keyword only argument, if True (default=False),
|
||||
behave like TopoShape.rotate() (i.e. the resulting placements are interchangeable).
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def multiply(self, placement: "Placement") -> "Placement":
|
||||
"""
|
||||
multiply(placement) -> Base.Placement
|
||||
|
||||
Right multiply this placement with another placement.
|
||||
Also available as `*` operator.
|
||||
|
||||
placement : Base.Placement
|
||||
Placement by which to multiply this placement.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def multVec(self, vector: Vector) -> Vector:
|
||||
"""
|
||||
multVec(vector) -> Base.Vector
|
||||
|
||||
Compute the transformed vector using the placement.
|
||||
|
||||
vector : Base.Vector
|
||||
Vector to be transformed.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def toMatrix(self) -> MatrixPy:
|
||||
"""
|
||||
toMatrix() -> Base.Matrix
|
||||
|
||||
Compute the matrix representation of the placement.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def inverse(self) -> "Placement":
|
||||
"""
|
||||
inverse() -> Base.Placement
|
||||
|
||||
Compute the inverse placement.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def pow(self, t: float, shorten: bool = True) -> "Placement":
|
||||
"""
|
||||
pow(t, shorten=True) -> Base.Placement
|
||||
|
||||
Raise this placement to real power using ScLERP interpolation.
|
||||
Also available as `**` operator.
|
||||
|
||||
t : float
|
||||
Real power.
|
||||
shorten : bool
|
||||
If True, ensures rotation quaternion is net positive to make
|
||||
the path shorter.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def sclerp(self, placement2: "Placement", t: float, shorten: bool = True) -> "Placement":
|
||||
"""
|
||||
sclerp(placement2, t, shorten=True) -> Base.Placement
|
||||
|
||||
Screw Linear Interpolation (ScLERP) between this placement and `placement2`.
|
||||
Interpolation is a continuous motion along a helical path parametrized by `t`
|
||||
made of equal transforms if discretized.
|
||||
If quaternions of rotations of the two placements differ in sign, the interpolation
|
||||
will take a long path.
|
||||
|
||||
placement2 : Base.Placement
|
||||
t : float
|
||||
Parameter of helical path. t=0 returns this placement, t=1 returns
|
||||
`placement2`. t can also be outside of [0, 1] range for extrapolation.
|
||||
shorten : bool
|
||||
If True, the signs are harmonized before interpolation and the interpolation
|
||||
takes the shorter path.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def slerp(self, placement2: "Placement", t: float) -> "Placement":
|
||||
"""
|
||||
slerp(placement2, t) -> Base.Placement
|
||||
|
||||
Spherical Linear Interpolation (SLERP) between this placement and `placement2`.
|
||||
This function performs independent interpolation of rotation and movement.
|
||||
Result of such interpolation might be not what application expects, thus this tool
|
||||
might be considered for simple cases or for interpolating between small intervals.
|
||||
For more complex cases you better use the advanced sclerp() function.
|
||||
|
||||
placement2 : Base.Placement
|
||||
t : float
|
||||
Parameter of the path. t=0 returns this placement, t=1 returns `placement2`.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isIdentity(self, tol: float = 0.0) -> bool:
|
||||
"""
|
||||
isIdentity([tol=0.0]) -> bool
|
||||
|
||||
Returns True if the placement has no displacement and no rotation.
|
||||
Matrix representation is the 4D identity matrix.
|
||||
tol : float
|
||||
Tolerance used to check for identity.
|
||||
If tol is negative or zero, no tolerance is used.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isSame(self, other: "Placement", tol: float = 0.0) -> bool:
|
||||
"""
|
||||
isSame(Base.Placement, [tol=0.0]) -> bool
|
||||
|
||||
Checks whether this and the given placement are the same.
|
||||
The default tolerance is set to 0.0
|
||||
"""
|
||||
...
|
||||
@@ -78,6 +78,7 @@
|
||||
#include <mutex>
|
||||
#include <bitset>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
|
||||
// streams
|
||||
#include <iostream>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
from PyObjectBase import PyObjectBase
|
||||
|
||||
class Precision(PyObjectBase):
|
||||
"""
|
||||
This is the Precision class
|
||||
|
||||
Author: Werner Mayer (wmayer@users.sourceforge.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def angular() -> float:
|
||||
"""
|
||||
Returns the recommended precision value when checking the equality of two angles (given in radians)
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def confusion() -> float:
|
||||
"""
|
||||
Returns the recommended precision value when checking coincidence of two points in real space
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def squareConfusion() -> float:
|
||||
"""
|
||||
Returns square of confusion
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def intersection() -> float:
|
||||
"""
|
||||
Returns the precision value in real space, frequently used by intersection algorithms
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def approximation() -> float:
|
||||
"""
|
||||
Returns the precision value in real space, frequently used by approximation algorithms
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def parametric() -> float:
|
||||
"""
|
||||
Convert a real space precision to a parametric space precision
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def isInfinite() -> bool:
|
||||
"""
|
||||
Returns True if R may be considered as an infinite number
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def isPositiveInfinite() -> bool:
|
||||
"""
|
||||
Returns True if R may be considered as a positive infinite number
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def isNegativeInfinite() -> bool:
|
||||
"""
|
||||
Returns True if R may be considered as a negative infinite number
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def infinite() -> float:
|
||||
"""
|
||||
Returns a big number that can be considered as infinite
|
||||
"""
|
||||
...
|
||||
@@ -0,0 +1,6 @@
|
||||
class PyObjectBase:
|
||||
"""
|
||||
The most base class for Python bindings.
|
||||
"""
|
||||
|
||||
...
|
||||
@@ -0,0 +1,107 @@
|
||||
from Metadata import export, constmethod
|
||||
from PyObjectBase import PyObjectBase
|
||||
from typing import overload, Final, Tuple, Union
|
||||
from Unit import Unit as UnitPy
|
||||
|
||||
@export(
|
||||
NumberProtocol=True,
|
||||
RichCompare=True,
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
)
|
||||
class Quantity(PyObjectBase):
|
||||
"""
|
||||
Quantity
|
||||
defined by a value and a unit.
|
||||
|
||||
The following constructors are supported:
|
||||
Quantity() -- empty constructor
|
||||
Quantity(Value) -- empty constructor
|
||||
Quantity(Value,Unit) -- empty constructor
|
||||
Quantity(Quantity) -- copy constructor
|
||||
Quantity(string) -- arbitrary mixture of numbers and chars defining a Quantity
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Value: float = ...
|
||||
"""Numeric Value of the Quantity (in internal system mm,kg,s)"""
|
||||
|
||||
Unit: UnitPy = ...
|
||||
"""Unit of the Quantity"""
|
||||
|
||||
UserString: Final[str] = ...
|
||||
"""Unit of the Quantity"""
|
||||
|
||||
Format: dict = ...
|
||||
"""Format of the Quantity"""
|
||||
|
||||
# fmt: off
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, value: float) -> None: ...
|
||||
@overload
|
||||
def __init__(self, value: float, unit: UnitPy) -> None: ...
|
||||
@overload
|
||||
def __init__(self, quantity: "Quantity") -> None: ...
|
||||
@overload
|
||||
def __init__(self, string: str) -> None: ...
|
||||
# fmt: on
|
||||
|
||||
@constmethod
|
||||
def toStr(self, decimals: int = ...) -> str:
|
||||
"""
|
||||
toStr([decimals])
|
||||
|
||||
Returns a string representation rounded to number of decimals. If no decimals are specified then
|
||||
the internal precision is used
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def toStr(self) -> str: ...
|
||||
@overload
|
||||
def toStr(self, decimals: int) -> str: ...
|
||||
@constmethod
|
||||
def getUserPreferred(self) -> Tuple["Quantity", str]:
|
||||
"""
|
||||
Returns a quantity with the translation factor and a string with the prevered unit
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def getValueAs(self, unit: str) -> float: ...
|
||||
@overload
|
||||
def getValueAs(self, translation: float, unit_signature: int) -> float: ...
|
||||
@overload
|
||||
def getValueAs(self, unit: UnitPy) -> float: ...
|
||||
@overload
|
||||
def getValueAs(self, quantity: "Quantity") -> float: ...
|
||||
@constmethod
|
||||
def getValueAs(self, *args) -> float:
|
||||
"""
|
||||
Returns a floating point value as the provided unit
|
||||
|
||||
Following parameters are allowed:
|
||||
getValueAs('m/s') # unit string to parse
|
||||
getValueAs(2.45,1) # translation value and unit signature
|
||||
getValueAs(FreeCAD.Units.Pascal) # predefined standard units
|
||||
getValueAs(Qantity('N/m^2')) # a quantity
|
||||
getValueAs(Unit(0,1,0,0,0,0,0,0)) # a unit
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def __round__(self, ndigits: int = ...) -> Union[int, float]:
|
||||
"""
|
||||
Returns the Integral closest to x, rounding half toward even.
|
||||
When an argument is passed, work like built-in round(x, ndigits).
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def __round__(self) -> int: ...
|
||||
@overload
|
||||
def __round__(self, ndigits: int) -> float: ...
|
||||
@@ -0,0 +1,275 @@
|
||||
from Metadata import export, constmethod, class_declarations
|
||||
from PyObjectBase import PyObjectBase
|
||||
from Vector import Vector
|
||||
from Matrix import Matrix
|
||||
from typing import overload, Tuple, List, Final
|
||||
|
||||
@export(
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
NumberProtocol=True,
|
||||
RichCompare=True,
|
||||
)
|
||||
@class_declarations(
|
||||
"""public:
|
||||
RotationPy(const Rotation & mat, PyTypeObject *T = &Type)
|
||||
:PyObjectBase(new Rotation(mat),T){}
|
||||
Rotation value() const
|
||||
{ return *(getRotationPtr()); }
|
||||
"""
|
||||
)
|
||||
class Rotation(PyObjectBase):
|
||||
"""
|
||||
Base.Rotation class.
|
||||
|
||||
A Rotation using a quaternion.
|
||||
|
||||
The following constructors are supported:
|
||||
|
||||
Rotation()
|
||||
Empty constructor.
|
||||
|
||||
Rotation(rotation)
|
||||
Copy constructor.
|
||||
|
||||
Rotation(Axis, Radian)
|
||||
Rotation(Axis, Degree)
|
||||
Define from an axis and an angle (in radians or degrees according to the keyword).
|
||||
Axis : Base.Vector
|
||||
Radian : float
|
||||
Degree : float
|
||||
|
||||
Rotation(vector_start, vector_end)
|
||||
Define from two vectors (rotation from/to vector).
|
||||
vector_start : Base.Vector
|
||||
vector_end : Base.Vector
|
||||
|
||||
Rotation(angle1, angle2, angle3)
|
||||
Define from three floats (Euler angles) as yaw-pitch-roll in XY'Z'' convention.
|
||||
angle1 : float
|
||||
angle2 : float
|
||||
angle3 : float
|
||||
|
||||
Rotation(seq, angle1, angle2, angle3)
|
||||
Define from one string and three floats (Euler angles) as Euler rotation
|
||||
of a given type. Call toEulerAngles() for supported sequence types.
|
||||
seq : str
|
||||
angle1 : float
|
||||
angle2 : float
|
||||
angle3 : float
|
||||
|
||||
Rotation(x, y, z, w)
|
||||
Define from four floats (quaternion) where the quaternion is specified as:
|
||||
q = xi+yj+zk+w, i.e. the last parameter is the real part.
|
||||
x : float
|
||||
y : float
|
||||
z : float
|
||||
w : float
|
||||
|
||||
Rotation(dir1, dir2, dir3, seq)
|
||||
Define from three vectors that define rotated axes directions plus an optional
|
||||
3-characher string of capital letters 'X', 'Y', 'Z' that sets the order of
|
||||
importance of the axes (e.g., 'ZXY' means z direction is followed strictly,
|
||||
x is used but corrected if necessary, y is ignored).
|
||||
dir1 : Base.Vector
|
||||
dir2 : Base.Vector
|
||||
dir3 : Base.Vector
|
||||
seq : str
|
||||
|
||||
Rotation(matrix)
|
||||
Define from a matrix rotation in the 4D representation.
|
||||
matrix : Base.Matrix
|
||||
|
||||
Rotation(*coef)
|
||||
Define from 16 or 9 elements which represent the rotation in the 4D matrix
|
||||
representation or in the 3D matrix representation, respectively.
|
||||
coef : sequence of float
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Q: Tuple[float, ...] = ()
|
||||
"""The rotation elements (as quaternion)."""
|
||||
|
||||
Axis: object = None
|
||||
"""The rotation axis of the quaternion."""
|
||||
|
||||
RawAxis: Final[object] = None
|
||||
"""The rotation axis without normalization."""
|
||||
|
||||
Angle: float = 0.0
|
||||
"""The rotation angle of the quaternion."""
|
||||
|
||||
# TODO: Provide strongly-typed enum for `seq`
|
||||
# fmt: off
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, rotation: "Rotation") -> None: ...
|
||||
@overload
|
||||
def __init__(self, axis: Vector, angle: float) -> None: ...
|
||||
@overload
|
||||
def __init__(self, vector_start: Vector, vector_end: Vector) -> None: ...
|
||||
@overload
|
||||
def __init__(self, angle1: float, angle2: float, angle3: float) -> None: ...
|
||||
@overload
|
||||
def __init__(self, seq: str, angle1: float, angle2: float, angle3: float) -> None: ...
|
||||
@overload
|
||||
def __init__(self, x: float, y: float, z: float, w: float) -> None: ...
|
||||
@overload
|
||||
def __init__(self, dir1: Vector, dir2: Vector, dir3: Vector, seq: str) -> None: ...
|
||||
@overload
|
||||
def __init__(self, matrix: Matrix) -> None: ...
|
||||
@overload
|
||||
def __init__(self, *coef: float) -> None: ...
|
||||
# fmt: on
|
||||
|
||||
def invert(self) -> None:
|
||||
"""
|
||||
invert() -> None
|
||||
|
||||
Sets the rotation to its inverse.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def inverted(self) -> "Rotation":
|
||||
"""
|
||||
inverted() -> Base.Rotation
|
||||
|
||||
Returns the inverse of the rotation.
|
||||
"""
|
||||
...
|
||||
|
||||
def isSame(self, rotation: "Rotation", tol: float = 0) -> bool:
|
||||
"""
|
||||
isSame(rotation, tol=0) -> bool
|
||||
|
||||
Checks if `rotation` perform the same transformation as this rotation.
|
||||
|
||||
rotation : Base.Rotation
|
||||
tol : float
|
||||
Tolerance used to compare both rotations.
|
||||
If tol is negative or zero, no tolerance is used.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def multiply(self, rotation: "Rotation") -> "Rotation":
|
||||
"""
|
||||
multiply(rotation) -> Base.Rotation
|
||||
|
||||
Right multiply this rotation with another rotation.
|
||||
|
||||
rotation : Base.Rotation
|
||||
Rotation by which to multiply this rotation.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def multVec(self, vector: Vector) -> Vector:
|
||||
"""
|
||||
multVec(vector) -> Base.Vector
|
||||
|
||||
Compute the transformed vector using the rotation.
|
||||
|
||||
vector : Base.Vector
|
||||
Vector to be transformed.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def slerp(self, rotation2: "Rotation", t: float) -> "Rotation":
|
||||
"""
|
||||
slerp(rotation2, t) -> Base.Rotation
|
||||
|
||||
Spherical Linear Interpolation (SLERP) of this rotation and `rotation2`.
|
||||
|
||||
t : float
|
||||
Parameter of the path. t=0 returns this rotation, t=1 returns `rotation2`.
|
||||
"""
|
||||
...
|
||||
|
||||
def setYawPitchRoll(self, angle1: float, angle2: float, angle3: float) -> None:
|
||||
"""
|
||||
setYawPitchRoll(angle1, angle2, angle3) -> None
|
||||
|
||||
Set the Euler angles of this rotation as yaw-pitch-roll in XY'Z'' convention.
|
||||
|
||||
angle1 : float
|
||||
Angle around yaw axis in degrees.
|
||||
angle2 : float
|
||||
Angle around pitch axis in degrees.
|
||||
angle3 : float
|
||||
Angle around roll axis in degrees.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getYawPitchRoll(self) -> Tuple[float, float, float]:
|
||||
"""
|
||||
getYawPitchRoll() -> tuple
|
||||
|
||||
Get the Euler angles of this rotation as yaw-pitch-roll in XY'Z'' convention.
|
||||
The angles are given in degrees.
|
||||
"""
|
||||
...
|
||||
|
||||
def setEulerAngles(self, seq: str, angle1: float, angle2: float, angle3: float) -> None:
|
||||
"""
|
||||
setEulerAngles(seq, angle1, angle2, angle3) -> None
|
||||
|
||||
Set the Euler angles in a given sequence for this rotation.
|
||||
The angles must be given in degrees.
|
||||
|
||||
seq : str
|
||||
Euler sequence name. All possible values given by toEulerAngles().
|
||||
angle1 : float
|
||||
angle2 : float
|
||||
angle3 : float
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def toEulerAngles(self, seq: str = "") -> List[float]:
|
||||
"""
|
||||
toEulerAngles(seq) -> list
|
||||
|
||||
Get the Euler angles in a given sequence for this rotation.
|
||||
|
||||
seq : str
|
||||
Euler sequence name. If not given, the function returns
|
||||
all possible values of `seq`. Optional.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def toMatrix(self) -> Matrix:
|
||||
"""
|
||||
toMatrix() -> Base.Matrix
|
||||
|
||||
Convert the rotation to a 4D matrix representation.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isNull(self) -> bool:
|
||||
"""
|
||||
isNull() -> bool
|
||||
|
||||
Returns True if all values in the quaternion representation are zero.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isIdentity(self, tol: float = 0) -> bool:
|
||||
"""
|
||||
isIdentity(tol=0) -> bool
|
||||
|
||||
Returns True if the rotation equals the 4D identity matrix.
|
||||
tol : float
|
||||
Tolerance used to check for identity.
|
||||
If tol is negative or zero, no tolerance is used.
|
||||
"""
|
||||
...
|
||||
@@ -119,6 +119,7 @@ public:
|
||||
inline BoundBox2d(double fX1, double fY1, double fX2, double fY2);
|
||||
~BoundBox2d() = default;
|
||||
inline bool IsValid() const;
|
||||
inline bool IsInfinite() const;
|
||||
inline bool IsEqual(const BoundBox2d& bbox, double tolerance) const;
|
||||
|
||||
// operators
|
||||
@@ -477,6 +478,11 @@ inline bool BoundBox2d::IsValid() const
|
||||
return (MaxX >= MinX) && (MaxY >= MinY);
|
||||
}
|
||||
|
||||
inline bool BoundBox2d::IsInfinite() const
|
||||
{
|
||||
return MaxX >= DOUBLE_MAX && MaxY >= DOUBLE_MAX && MinX <= -DOUBLE_MAX && MinY <= -DOUBLE_MAX;
|
||||
}
|
||||
|
||||
inline bool BoundBox2d::IsEqual(const BoundBox2d& bbox, double tolerance) const
|
||||
{
|
||||
return Vector2d(MinX, MinY).IsEqual(Vector2d(bbox.MinX, bbox.MinY), tolerance)
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
from Metadata import export, forward_declarations, constmethod
|
||||
from PyObjectBase import PyObjectBase
|
||||
from typing import List, Final
|
||||
|
||||
@export(
|
||||
Twin="BaseType",
|
||||
TwinPointer="BaseType",
|
||||
Delete=True,
|
||||
)
|
||||
@forward_declarations(
|
||||
"""
|
||||
namespace Base {
|
||||
using BaseType = Type;
|
||||
}"""
|
||||
)
|
||||
class Type(PyObjectBase):
|
||||
"""
|
||||
BaseTypePy class.
|
||||
|
||||
This class provides functionality related to type management in the Base module. It's not intended for direct instantiation but for accessing type information and creating instances of various types. Instantiation is possible for classes that inherit from the Base::BaseClass class and are not abstract.
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Name: Final[str] = ""
|
||||
"""The name of the type id."""
|
||||
|
||||
Key: Final[int] = 0
|
||||
"""The key of the type id."""
|
||||
|
||||
Module: Final[str] = ""
|
||||
"""Module in which this class is defined."""
|
||||
|
||||
@staticmethod
|
||||
def fromName(name: str) -> "Type":
|
||||
"""
|
||||
fromName(name) -> Base.BaseType
|
||||
|
||||
Returns a type object by name.
|
||||
|
||||
name : str
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def fromKey(key: int) -> "Type":
|
||||
"""
|
||||
fromKey(key) -> Base.BaseType
|
||||
|
||||
Returns a type id object by key.
|
||||
|
||||
key : int
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def getNumTypes() -> int:
|
||||
"""
|
||||
getNumTypes() -> int
|
||||
|
||||
Returns the number of type ids created so far.
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def getBadType() -> "Type":
|
||||
"""
|
||||
getBadType() -> Base.BaseType
|
||||
|
||||
Returns an invalid type id.
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def getAllDerivedFrom(type: str) -> List[str]:
|
||||
"""
|
||||
getAllDerivedFrom(type) -> list
|
||||
|
||||
Returns all descendants from the given type id.
|
||||
|
||||
type : str, Base.BaseType
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getParent(self) -> "Type":
|
||||
"""
|
||||
getParent() -> Base.BaseType
|
||||
|
||||
Returns the parent type id.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isBad(self) -> bool:
|
||||
"""
|
||||
isBad() -> bool
|
||||
|
||||
Checks if the type id is invalid.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isDerivedFrom(self, type: str) -> bool:
|
||||
"""
|
||||
isDerivedFrom(type) -> bool
|
||||
|
||||
Returns true if given type id is a father of this type id.
|
||||
|
||||
type : str, Base.BaseType
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getAllDerived(self) -> List[object]:
|
||||
"""
|
||||
getAllDerived() -> list
|
||||
|
||||
Returns all descendants from this type id.
|
||||
"""
|
||||
...
|
||||
|
||||
def createInstance(self) -> object:
|
||||
"""
|
||||
createInstance() -> object
|
||||
|
||||
Creates an instance of this type id.
|
||||
"""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def createInstanceByName(name: str, load: bool = False) -> object:
|
||||
"""
|
||||
createInstanceByName(name, load=False) -> object
|
||||
|
||||
Creates an instance of the named type id.
|
||||
|
||||
name : str
|
||||
load : bool
|
||||
Load named type id module.
|
||||
"""
|
||||
...
|
||||
@@ -0,0 +1,54 @@
|
||||
from Metadata import export
|
||||
from PyObjectBase import PyObjectBase
|
||||
from Quantity import Quantity
|
||||
from Unit import Unit
|
||||
from typing import Final, Tuple, overload
|
||||
|
||||
@export(
|
||||
NumberProtocol=True,
|
||||
RichCompare=True,
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
)
|
||||
class Unit(PyObjectBase):
|
||||
"""
|
||||
Unit
|
||||
defines a unit type, calculate and compare.
|
||||
|
||||
The following constructors are supported:
|
||||
Unit() -- empty constructor
|
||||
Unit(i1,i2,i3,i4,i5,i6,i7,i8) -- unit signature
|
||||
Unit(Quantity) -- copy unit from Quantity
|
||||
Unit(Unit) -- copy constructor
|
||||
Unit(string) -- parse the string for units
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
i1: float,
|
||||
i2: float,
|
||||
i3: float,
|
||||
i4: float,
|
||||
i5: float,
|
||||
i6: float,
|
||||
i7: float,
|
||||
i8: float,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(self, quantity: Quantity) -> None: ...
|
||||
@overload
|
||||
def __init__(self, unit: Unit) -> None: ...
|
||||
@overload
|
||||
def __init__(self, string: str) -> None: ...
|
||||
|
||||
Type: Final[str] = ...
|
||||
"""holds the unit type as a string, e.g. 'Area'."""
|
||||
|
||||
Signature: Final[Tuple] = ...
|
||||
"""Returns the signature."""
|
||||
@@ -0,0 +1,320 @@
|
||||
from Metadata import export, constmethod, sequence_protocol, class_declarations
|
||||
from PyObjectBase import PyObjectBase
|
||||
from typing import overload, Sequence, TYPE_CHECKING
|
||||
|
||||
@export(
|
||||
TwinPointer="Vector3d",
|
||||
Include="Base/Vector3D.h",
|
||||
Constructor=True,
|
||||
Delete=True,
|
||||
NumberProtocol=True,
|
||||
RichCompare=True,
|
||||
)
|
||||
@sequence_protocol(
|
||||
sq_length=True,
|
||||
sq_concat=False,
|
||||
sq_repeat=False,
|
||||
sq_item=True,
|
||||
mp_subscript=True,
|
||||
sq_ass_item=True,
|
||||
mp_ass_subscript=False,
|
||||
sq_contains=False,
|
||||
sq_inplace_concat=False,
|
||||
sq_inplace_repeat=False,
|
||||
)
|
||||
@class_declarations(
|
||||
"""public:
|
||||
VectorPy(const Vector3d & vec, PyTypeObject *T = &Type)
|
||||
:PyObjectBase(new Vector3d(vec),T){}
|
||||
VectorPy(const Vector3f & vec, PyTypeObject *T = &Type)
|
||||
:PyObjectBase(new Vector3d(vec.x,vec.y,vec.z),T){}
|
||||
Vector3d value() const
|
||||
{ return *(getVectorPtr()); }
|
||||
private:
|
||||
Py::List sequence;
|
||||
"""
|
||||
)
|
||||
class Vector(PyObjectBase):
|
||||
"""
|
||||
Base.Vector class.
|
||||
|
||||
This class represents a 3D float vector.
|
||||
Useful to represent points in the 3D space.
|
||||
|
||||
The following constructors are supported:
|
||||
|
||||
Vector(x=0, y=0, z=0)
|
||||
x : float
|
||||
y : float
|
||||
z : float
|
||||
|
||||
Vector(vector)
|
||||
Copy constructor.
|
||||
vector : Base.Vector
|
||||
|
||||
Vector(seq)
|
||||
Define from a sequence of float.
|
||||
seq : sequence of float.
|
||||
|
||||
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
|
||||
Licence: LGPL
|
||||
"""
|
||||
|
||||
Length: float = 0.0
|
||||
"""Gets or sets the length of this vector."""
|
||||
|
||||
x: float = 0.0
|
||||
"""Gets or sets the X component of this vector."""
|
||||
|
||||
y: float = 0.0
|
||||
"""Gets or sets the Y component of this vector."""
|
||||
|
||||
z: float = 0.0
|
||||
"""Gets or sets the Z component of this vector."""
|
||||
|
||||
# fmt: off
|
||||
@overload
|
||||
def __init__(self, *, x: float = 0, y: float = 0, z: float = 0) -> None: ...
|
||||
@overload
|
||||
def __init__(self, vector: "Vector") -> None: ...
|
||||
@overload
|
||||
def __init__(self, seq: Sequence[float]) -> None: ...
|
||||
# fmt: on
|
||||
|
||||
@constmethod
|
||||
def __reduce__(self) -> tuple:
|
||||
"""
|
||||
__reduce__() -> tuple
|
||||
|
||||
Serialization of Vector objects.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def add(self, vector2: "Vector") -> "Vector":
|
||||
"""
|
||||
add(vector2) -> Base.Vector
|
||||
|
||||
Returns the sum of this vector and `vector2`.
|
||||
|
||||
vector2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def sub(self, vector2: "Vector") -> "Vector":
|
||||
"""
|
||||
sub(vector2) -> Base.Vector
|
||||
|
||||
Returns the difference of this vector and `vector2`.
|
||||
|
||||
vector2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def negative(self) -> "Vector":
|
||||
"""
|
||||
negative() -> Base.Vector
|
||||
|
||||
Returns the negative (opposite) of this vector.
|
||||
"""
|
||||
...
|
||||
|
||||
def scale(self, x: float, y: float, z: float) -> "Vector":
|
||||
"""
|
||||
scale(x, y, z) -> Base.Vector
|
||||
|
||||
Scales in-place this vector by the given factor in each component.
|
||||
|
||||
x : float
|
||||
x-component factor scale.
|
||||
y : float
|
||||
y-component factor scale.
|
||||
z : float
|
||||
z-component factor scale.
|
||||
"""
|
||||
...
|
||||
|
||||
def multiply(self, factor: float) -> "Vector":
|
||||
"""
|
||||
multiply(factor) -> Base.Vector
|
||||
|
||||
Multiplies in-place each component of this vector by a single factor.
|
||||
Equivalent to scale(factor, factor, factor).
|
||||
|
||||
factor : float
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def dot(self, vector2: "Vector") -> float:
|
||||
"""
|
||||
dot(vector2) -> float
|
||||
|
||||
Returns the scalar product (dot product) between this vector and `vector2`.
|
||||
|
||||
vector2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def cross(self, vector2: "Vector") -> "Vector":
|
||||
"""
|
||||
cross(vector2) -> Base.Vector
|
||||
|
||||
Returns the vector product (cross product) between this vector and `vector2`.
|
||||
|
||||
vector2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isOnLineSegment(self, vector1: "Vector", vector2: "Vector") -> bool:
|
||||
"""
|
||||
isOnLineSegment(vector1, vector2) -> bool
|
||||
|
||||
Checks if this vector is on the line segment generated by `vector1` and `vector2`.
|
||||
|
||||
vector1 : Base.Vector
|
||||
vector2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def getAngle(self, vector2: "Vector") -> float:
|
||||
"""
|
||||
getAngle(vector2) -> float
|
||||
|
||||
Returns the angle in radians between this vector and `vector2`.
|
||||
|
||||
vector2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
def normalize(self) -> "Vector":
|
||||
"""
|
||||
normalize() -> Base.Vector
|
||||
|
||||
Normalizes in-place this vector to the length of 1.0.
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isEqual(self, vector2: "Vector", tol: float = 0) -> bool:
|
||||
"""
|
||||
isEqual(vector2, tol=0) -> bool
|
||||
|
||||
Checks if the distance between the points represented by this vector
|
||||
and `vector2` is less or equal to the given tolerance.
|
||||
|
||||
vector2 : Base.Vector
|
||||
tol : float
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isParallel(self, vector2: "Vector", tol: float = 0) -> bool:
|
||||
"""
|
||||
isParallel(vector2, tol=0) -> bool
|
||||
|
||||
Checks if this vector and `vector2` are
|
||||
parallel less or equal to the given tolerance.
|
||||
|
||||
vector2 : Base.Vector
|
||||
tol : float
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def isNormal(self, vector2: "Vector", tol: float = 0) -> bool:
|
||||
"""
|
||||
isNormal(vector2, tol=0) -> bool
|
||||
|
||||
Checks if this vector and `vector2` are
|
||||
normal less or equal to the given tolerance.
|
||||
|
||||
vector2 : Base.Vector
|
||||
tol : float
|
||||
"""
|
||||
...
|
||||
|
||||
def projectToLine(self, point: "Vector", dir: "Vector") -> "Vector":
|
||||
"""
|
||||
projectToLine(point, dir) -> Base.Vector
|
||||
|
||||
Projects `point` on a line that goes through the origin with the direction `dir`.
|
||||
The result is the vector from `point` to the projected point.
|
||||
The operation is equivalent to dir_n.cross(dir_n.cross(point)), where `dir_n` is
|
||||
the vector `dir` normalized.
|
||||
The method modifies this vector instance according to result and does not
|
||||
depend on the vector itself.
|
||||
|
||||
point : Base.Vector
|
||||
dir : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
def projectToPlane(self, base: "Vector", normal: "Vector") -> "Vector":
|
||||
"""
|
||||
projectToPlane(base, normal) -> Base.Vector
|
||||
|
||||
Projects in-place this vector on a plane defined by a base point
|
||||
represented by `base` and a normal defined by `normal`.
|
||||
|
||||
base : Base.Vector
|
||||
normal : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def distanceToPoint(self, point2: "Vector") -> float:
|
||||
"""
|
||||
distanceToPoint(point2) -> float
|
||||
|
||||
Returns the distance to another point represented by `point2`.
|
||||
.
|
||||
point : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def distanceToLine(self, base: "Vector", dir: "Vector") -> float:
|
||||
"""
|
||||
distanceToLine(base, dir) -> float
|
||||
|
||||
Returns the distance between the point represented by this vector
|
||||
and a line defined by a base point represented by `base` and a
|
||||
direction `dir`.
|
||||
|
||||
base : Base.Vector
|
||||
dir : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def distanceToLineSegment(self, point1: "Vector", point2: "Vector") -> "Vector":
|
||||
"""
|
||||
distanceToLineSegment(point1, point2) -> Base.Vector
|
||||
|
||||
Returns the vector between the point represented by this vector and the point
|
||||
on the line segment with the shortest distance. The line segment is defined by
|
||||
`point1` and `point2`.
|
||||
|
||||
point1 : Base.Vector
|
||||
point2 : Base.Vector
|
||||
"""
|
||||
...
|
||||
|
||||
@constmethod
|
||||
def distanceToPlane(self, base: "Vector", normal: "Vector") -> float:
|
||||
"""
|
||||
distanceToPlane(base, normal) -> float
|
||||
|
||||
Returns the distance between this vector and a plane defined by a
|
||||
base point represented by `base` and a normal defined by `normal`.
|
||||
|
||||
base : Base.Vector
|
||||
normal : Base.Vector
|
||||
"""
|
||||
...
|
||||
+10
-1
@@ -101,6 +101,10 @@ template<class float_type>
|
||||
class Vector3
|
||||
{
|
||||
public:
|
||||
static const Vector3 UnitX;
|
||||
static const Vector3 UnitY;
|
||||
static const Vector3 UnitZ;
|
||||
|
||||
using num_type = float_type;
|
||||
using traits_type = float_traits<num_type>;
|
||||
[[nodiscard]] static constexpr num_type epsilon()
|
||||
@@ -256,7 +260,12 @@ public:
|
||||
//@}
|
||||
};
|
||||
|
||||
// global functions
|
||||
template<class float_type>
|
||||
Vector3<float_type> const Vector3<float_type>::UnitX(1.0, 0.0, 0.0);
|
||||
template<class float_type>
|
||||
Vector3<float_type> const Vector3<float_type>::UnitY(0.0, 1.0, 0.0);
|
||||
template<class float_type>
|
||||
Vector3<float_type> const Vector3<float_type>::UnitZ(0.0, 0.0, 1.0);
|
||||
|
||||
/// Returns the distance between two points
|
||||
template<class float_type>
|
||||
|
||||
+15
-2
@@ -58,6 +58,10 @@ include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/TaskView
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Quarter
|
||||
${CMAKE_CURRENT_BINARY_DIR}/DAGView
|
||||
)
|
||||
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
${PYCXX_INCLUDE_DIR}
|
||||
@@ -98,7 +102,7 @@ endif(MSVC)
|
||||
if (TARGET Coin::Coin)
|
||||
list(APPEND FreeCADGui_LIBS Coin::Coin)
|
||||
else()
|
||||
include_directories(${COIN3D_INCLUDE_DIRS})
|
||||
include_directories(SYSTEM ${COIN3D_INCLUDE_DIRS})
|
||||
link_directories(${COIN3D_LIB_DIRS})
|
||||
list(APPEND FreeCADGui_LIBS ${COIN3D_LIBRARIES})
|
||||
endif()
|
||||
@@ -112,6 +116,7 @@ if (WIN32)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${QtCore_INCLUDE_DIRS}
|
||||
${QtWidgets_INCLUDE_DIRS}
|
||||
${QtOpenGL_INCLUDE_DIRS}
|
||||
@@ -135,6 +140,7 @@ list(APPEND FreeCADGui_LIBS
|
||||
|
||||
if(${Qt5WinExtras_FOUND})
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${Qt5WinExtras_INCLUDE_DIRS}
|
||||
)
|
||||
list(APPEND FreeCADGui_LIBS
|
||||
@@ -148,7 +154,7 @@ IF(SPNAV_FOUND AND FREECAD_USE_3DCONNEXION_LEGACY)
|
||||
add_definitions(-DSPNAV_USE_X11)
|
||||
if (FREECAD_QT_MAJOR_VERSION EQUAL 5 AND UNIX AND NOT APPLE)
|
||||
find_package(Qt5X11Extras REQUIRED)
|
||||
include_directories(${Qt5X11Extras_INCLUDE_DIRS})
|
||||
include_directories(SYSTEM ${Qt5X11Extras_INCLUDE_DIRS})
|
||||
list(APPEND FreeCADGui_LIBS ${Qt5X11Extras_LIBRARIES})
|
||||
# Note that Qt6 has removed the QtX11Extras files
|
||||
endif()
|
||||
@@ -186,6 +192,7 @@ IF(SPNAV_FOUND AND FREECAD_USE_3DCONNEXION_LEGACY)
|
||||
|
||||
add_definitions(-DSPNAV_FOUND)
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${SPNAV_INCLUDE_DIR}
|
||||
)
|
||||
list(APPEND FreeCADGui_LIBS
|
||||
@@ -196,6 +203,7 @@ ENDIF(SPNAV_FOUND AND FREECAD_USE_3DCONNEXION_LEGACY)
|
||||
IF(OCULUS_FOUND)
|
||||
add_definitions(-DOCULUS_FOUND)
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${OCULUS_INCLUDE_DIRS}
|
||||
)
|
||||
list(APPEND FreeCADGui_LIBS
|
||||
@@ -206,6 +214,7 @@ ENDIF(OCULUS_FOUND)
|
||||
if(FREECAD_USE_SHIBOKEN)
|
||||
add_definitions(-DHAVE_SHIBOKEN${PYSIDE_MAJOR_VERSION})
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${SHIBOKEN_INCLUDE_DIR}
|
||||
)
|
||||
if (SHIBOKEN_LIBRARY)
|
||||
@@ -227,6 +236,7 @@ endif(FREECAD_USE_SHIBOKEN)
|
||||
|
||||
if(FREECAD_USE_PYSIDE)
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${PYSIDE_INCLUDE_DIR}
|
||||
${PYSIDE_INCLUDE_DIR}/QtCore
|
||||
${PYSIDE_INCLUDE_DIR}/QtGui
|
||||
@@ -247,6 +257,7 @@ if(FREECAD_USE_PYSIDE)
|
||||
endif ()
|
||||
endif (PYSIDE_LIBRARY)
|
||||
include_directories(
|
||||
SYSTEM
|
||||
${PYSIDE_INCLUDE_DIR}/QtWidgets
|
||||
)
|
||||
add_definitions(-DHAVE_PYSIDE${PYSIDE_MAJOR_VERSION})
|
||||
@@ -1069,6 +1080,7 @@ SET(Inventor_CPP_SRCS
|
||||
Inventor/So3DAnnotation.cpp
|
||||
Inventor/SoAutoZoomTranslation.cpp
|
||||
Inventor/SoAxisCrossKit.cpp
|
||||
Inventor/SoFCPlacementIndicatorKit.cpp
|
||||
Inventor/SoDrawingGrid.cpp
|
||||
Inventor/SoFCBackgroundGradient.cpp
|
||||
Inventor/SoFCBoundingBox.cpp
|
||||
@@ -1101,6 +1113,7 @@ SET(Inventor_SRCS
|
||||
Inventor/SmSwitchboard.h
|
||||
Inventor/SoAutoZoomTranslation.h
|
||||
Inventor/SoAxisCrossKit.h
|
||||
Inventor/SoFCPlacementIndicatorKit.h
|
||||
Inventor/SoDrawingGrid.h
|
||||
Inventor/SoFCBackgroundGradient.h
|
||||
Inventor/SoFCBoundingBox.h
|
||||
|
||||
@@ -95,7 +95,7 @@ void StdCmdRandomColor::activated(int iMsg)
|
||||
auto fGrn = (float)rand()/fMax;
|
||||
auto fBlu = (float)rand()/fMax;
|
||||
// NOLINTEND
|
||||
auto objColor = App::Color(fRed, fGrn, fBlu);
|
||||
auto objColor = Base::Color(fRed, fGrn, fBlu);
|
||||
|
||||
auto vpLink = dynamic_cast<ViewProviderLink*>(view);
|
||||
if (vpLink) {
|
||||
|
||||
@@ -668,7 +668,6 @@ void AboutDialog::copyToClipboard()
|
||||
|
||||
if (ifcopenshellVerAsStr) {
|
||||
str << "IfcOpenShell " << ifcopenshellVerAsStr << ", ";
|
||||
Py_DECREF(ifcopenshellVerAsStr);
|
||||
}
|
||||
Py_DECREF(ifcopenshellVer);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,13 @@
|
||||
#include <vector>
|
||||
#include <App/Material.h>
|
||||
|
||||
namespace App
|
||||
namespace Base
|
||||
{
|
||||
class Color;
|
||||
}
|
||||
|
||||
namespace App
|
||||
{
|
||||
class Material;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
# include <QApplication>
|
||||
# include <QFileInfo>
|
||||
# include <QMessageBox>
|
||||
# include <QOpenGLWidget>
|
||||
# include <QTextStream>
|
||||
# include <QTimer>
|
||||
# include <QStatusBar>
|
||||
@@ -1999,11 +2000,11 @@ MDIView *Document::createView(const Base::Type& typeId)
|
||||
std::list<MDIView*> theViews = this->getMDIViewsOfType(typeId);
|
||||
if (typeId == View3DInventor::getClassTypeId()) {
|
||||
|
||||
QtGLWidget* shareWidget = nullptr;
|
||||
QOpenGLWidget* shareWidget = nullptr;
|
||||
// VBO rendering doesn't work correctly when we don't share the OpenGL widgets
|
||||
if (!theViews.empty()) {
|
||||
auto firstView = static_cast<View3DInventor*>(theViews.front());
|
||||
shareWidget = qobject_cast<QtGLWidget*>(firstView->getViewer()->getGLWidget());
|
||||
shareWidget = qobject_cast<QOpenGLWidget*>(firstView->getViewer()->getGLWidget());
|
||||
|
||||
const char *ppReturn = nullptr;
|
||||
firstView->onMsg("GetCamera",&ppReturn);
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ using namespace Gui;
|
||||
// Embed complete widgets
|
||||
|
||||
Flag::Flag(QWidget* parent)
|
||||
: QtGLWidget(parent), coord(0.0f, 0.0f, 0.0f)
|
||||
: QOpenGLWidget(parent), coord(0.0f, 0.0f, 0.0f)
|
||||
{
|
||||
this->setFixedHeight(20);
|
||||
setAutoFillBackground(true);
|
||||
@@ -124,7 +124,7 @@ void Flag::setText(const QString& t)
|
||||
|
||||
void Flag::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
QtGLWidget::resizeEvent(e);
|
||||
QOpenGLWidget::resizeEvent(e);
|
||||
}
|
||||
|
||||
void Flag::mouseMoveEvent(QMouseEvent *e)
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@
|
||||
#define GUI_FLAG_H
|
||||
|
||||
#include <QLayout>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QRect>
|
||||
#include <QWidgetItem>
|
||||
#include <Inventor/SbVec3f.h>
|
||||
@@ -36,7 +37,7 @@ class View3DInventorViewer;
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class GuiExport Flag : public QtGLWidget
|
||||
class GuiExport Flag : public QOpenGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include "GLPainter.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
|
||||
@@ -51,7 +53,7 @@ bool GLPainter::begin(QPaintDevice * device)
|
||||
if (viewer)
|
||||
return false;
|
||||
|
||||
viewer = dynamic_cast<QtGLWidget*>(device);
|
||||
viewer = dynamic_cast<QOpenGLWidget*>(device);
|
||||
if (!viewer)
|
||||
return false;
|
||||
|
||||
|
||||
+2
-2
@@ -38,10 +38,10 @@
|
||||
|
||||
#include <Base/BaseClass.h>
|
||||
#include <FCGlobal.h>
|
||||
#include <QtOpenGL.h>
|
||||
#include <QPoint>
|
||||
|
||||
class QPaintDevice;
|
||||
class QOpenGLWidget;
|
||||
|
||||
namespace Gui {
|
||||
class View3DInventorViewer;
|
||||
@@ -75,10 +75,10 @@ public:
|
||||
//@}
|
||||
|
||||
private:
|
||||
QtGLWidget* viewer{nullptr};
|
||||
GLfloat depthrange[2];
|
||||
GLdouble projectionmatrix[16];
|
||||
GLint width{0}, height{0};
|
||||
QOpenGLWidget* viewer{nullptr};
|
||||
bool logicOp{false};
|
||||
bool lineStipple{false};
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
# include <Inventor/nodes/SoTranslation.h>
|
||||
#endif
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
#include <Gui/ViewParams.h>
|
||||
|
||||
#include "SoAxisCrossKit.h"
|
||||
@@ -225,23 +225,23 @@ SoAxisCrossKit::createAxes()
|
||||
set("zAxis.appearance.drawStyle", "lineWidth 1");
|
||||
|
||||
unsigned long colorLong;
|
||||
App::Color color;
|
||||
Base::Color color;
|
||||
std::stringstream parameterstring;
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
color = Base::Color(static_cast<uint32_t>(colorLong));
|
||||
parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
|
||||
set("xAxis.appearance.material", parameterstring.str().c_str());
|
||||
set("xHead.appearance.material", parameterstring.str().c_str());
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
color = Base::Color(static_cast<uint32_t>(colorLong));
|
||||
parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
|
||||
set("yAxis.appearance.material", parameterstring.str().c_str());
|
||||
set("yHead.appearance.material", parameterstring.str().c_str());
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisZColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
color = Base::Color(static_cast<uint32_t>(colorLong));
|
||||
parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
|
||||
set("zAxis.appearance.material", parameterstring.str().c_str());
|
||||
set("zHead.appearance.material", parameterstring.str().c_str());
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2024 Kacper Donat <kacper@kadet.net> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <sstream>
|
||||
|
||||
#include <Inventor/nodes/SoBaseColor.h>
|
||||
#include <Inventor/nodes/SoComplexity.h>
|
||||
#include <Inventor/nodes/SoCone.h>
|
||||
#include <Inventor/nodes/SoCylinder.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
#include <Inventor/nodes/SoLightModel.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoRotation.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoTransform.h>
|
||||
#include <Inventor/nodes/SoTranslation.h>
|
||||
#include <Inventor/nodes/SoFontStyle.h>
|
||||
#endif
|
||||
|
||||
#include "SoFCPlacementIndicatorKit.h"
|
||||
|
||||
#include "So3DAnnotation.h"
|
||||
#include "SoAxisCrossKit.h"
|
||||
|
||||
#include <SoTextLabel.h>
|
||||
#include <Utilities.h>
|
||||
#include <ViewParams.h>
|
||||
#include <ViewProvider.h>
|
||||
#include <Base/Color.h>
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
SO_KIT_SOURCE(SoFCPlacementIndicatorKit);
|
||||
|
||||
SoFCPlacementIndicatorKit::SoFCPlacementIndicatorKit()
|
||||
{
|
||||
SO_KIT_CONSTRUCTOR(SoFCPlacementIndicatorKit);
|
||||
|
||||
SO_KIT_ADD_CATALOG_ENTRY(root, SoShapeScale, false, this, "", true);
|
||||
|
||||
SO_KIT_INIT_INSTANCE();
|
||||
|
||||
SO_NODE_ADD_FIELD(coloredAxis, (true));
|
||||
SO_NODE_ADD_FIELD(scaleFactor, (scaleFactorDefault));
|
||||
SO_NODE_ADD_FIELD(axisLength, (axisLengthDefault));
|
||||
|
||||
SO_NODE_ADD_FIELD(parts, (AxisCross));
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Part, Axes);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Part, PlaneIndicator);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Part, Labels);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Part, ArrowHeads);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Part, AxisCross);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Part, AllParts);
|
||||
SO_NODE_SET_SF_ENUM_TYPE(parts, Part);
|
||||
|
||||
SO_NODE_ADD_FIELD(axes, (AllAxes));
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Axes, X);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Axes, Y);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Axes, Z);
|
||||
SO_NODE_DEFINE_ENUM_VALUE(Axes, AllAxes);
|
||||
SO_NODE_SET_SF_ENUM_TYPE(axes, Axes);
|
||||
|
||||
auto root = SO_GET_ANY_PART(this, "root", SoShapeScale);
|
||||
root->scaleFactor.connectFrom(&scaleFactor);
|
||||
|
||||
recomputeGeometry();
|
||||
}
|
||||
|
||||
void SoFCPlacementIndicatorKit::initClass()
|
||||
{
|
||||
SO_KIT_INIT_CLASS(SoFCPlacementIndicatorKit, SoBaseKit, "BaseKit");
|
||||
}
|
||||
|
||||
void SoFCPlacementIndicatorKit::notify(SoNotList* l)
|
||||
{
|
||||
SoField* field = l->getLastField();
|
||||
|
||||
if (field == &parts || field == &axes || field == &axisLength) {
|
||||
// certainly this is not the fastest way to recompute the geometry as it does recreate
|
||||
// everything from the scratch. It is however very easy to implement and this node should
|
||||
// not really change too often so the performance penalty is better than making code that
|
||||
// is harder to maintain.
|
||||
recomputeGeometry();
|
||||
return;
|
||||
}
|
||||
|
||||
SoBaseKit::notify(l);
|
||||
}
|
||||
|
||||
void SoFCPlacementIndicatorKit::recomputeGeometry()
|
||||
{
|
||||
auto root = SO_GET_ANY_PART(this, "root", SoShapeScale);
|
||||
root->setPart("shape", createGeometry());
|
||||
}
|
||||
|
||||
SoSeparator* SoFCPlacementIndicatorKit::createGeometry()
|
||||
{
|
||||
auto sep = new SoSeparator();
|
||||
|
||||
auto pcBaseColor = new SoBaseColor();
|
||||
pcBaseColor->rgb.setValue(0.7f, 0.7f, 0.5f);
|
||||
|
||||
auto pcLightModel = new SoLightModel();
|
||||
pcLightModel->model = SoLightModel::BASE_COLOR;
|
||||
|
||||
sep->addChild(pcBaseColor);
|
||||
sep->addChild(pcLightModel);
|
||||
|
||||
if (parts.getValue() & PlaneIndicator) {
|
||||
sep->addChild(createPlaneIndicator());
|
||||
}
|
||||
|
||||
if (parts.getValue() & Axes) {
|
||||
sep->addChild(createAxes());
|
||||
}
|
||||
|
||||
return sep;
|
||||
}
|
||||
|
||||
SoSeparator* SoFCPlacementIndicatorKit::createAxes()
|
||||
{
|
||||
const auto cylinderOffset = axisLength.getValue() / 2.f;
|
||||
|
||||
const auto createAxis = [&](const char* label,
|
||||
Base::Vector3d axis,
|
||||
uint32_t packedColor,
|
||||
const double offset) {
|
||||
Base::Color axisColor(packedColor);
|
||||
|
||||
auto sep = new SoSeparator;
|
||||
|
||||
auto rotation = Base::Rotation(Base::Vector3d::UnitY, axis);
|
||||
auto pcTranslate = new SoTransform();
|
||||
pcTranslate->translation.setValue(
|
||||
Base::convertTo<SbVec3f>((cylinderOffset + offset) * axis));
|
||||
pcTranslate->rotation.setValue(Base::convertTo<SbRotation>(rotation));
|
||||
|
||||
auto pcArrowShaft = new SoCylinder();
|
||||
pcArrowShaft->radius = axisThickness / 2.0f;
|
||||
pcArrowShaft->height = axisLength;
|
||||
|
||||
if (coloredAxis.getValue()) {
|
||||
auto pcBaseColor = new SoBaseColor();
|
||||
pcBaseColor->rgb.setValue(Base::convertTo<SbColor>(axisColor));
|
||||
|
||||
sep->addChild(pcBaseColor);
|
||||
}
|
||||
|
||||
sep->addChild(pcTranslate);
|
||||
sep->addChild(pcArrowShaft);
|
||||
|
||||
if (parts.getValue() & ArrowHeads) {
|
||||
auto pcArrowHeadTranslation = new SoTranslation();
|
||||
pcArrowHeadTranslation->translation.setValue(0.0, cylinderOffset, 0.0);
|
||||
|
||||
auto pcArrowHead = new SoCone();
|
||||
pcArrowHead->bottomRadius = arrowHeadRadius;
|
||||
pcArrowHead->height = arrowHeadHeight;
|
||||
|
||||
auto pcArrowHeadSeparator = new SoSeparator();
|
||||
pcArrowHeadSeparator->addChild(pcArrowHeadTranslation);
|
||||
pcArrowHeadSeparator->addChild(pcArrowHead);
|
||||
|
||||
sep->addChild(pcArrowHeadSeparator);
|
||||
}
|
||||
|
||||
if (parts.getValue() & Labels) {
|
||||
auto pcLabelSeparator = new SoSeparator();
|
||||
|
||||
auto pcLabelTranslation = new SoTranslation();
|
||||
pcLabelTranslation->translation.setValue(0.0, cylinderOffset + labelOffset, 0.0);
|
||||
pcLabelSeparator->addChild(pcLabelTranslation);
|
||||
|
||||
auto pcAxisLabel = new SoFrameLabel();
|
||||
pcAxisLabel->string.setValue(label);
|
||||
pcAxisLabel->textColor.setValue(1.0, 1.0, 1.0);
|
||||
pcAxisLabel->horAlignment = SoImage::CENTER;
|
||||
pcAxisLabel->vertAlignment = SoImage::HALF;
|
||||
pcAxisLabel->border = false;
|
||||
pcAxisLabel->frame = false;
|
||||
pcAxisLabel->textUseBaseColor = true;
|
||||
pcAxisLabel->size = labelFontSize;
|
||||
|
||||
pcLabelSeparator->addChild(pcAxisLabel);
|
||||
|
||||
sep->addChild(pcLabelSeparator);
|
||||
}
|
||||
|
||||
return sep;
|
||||
};
|
||||
|
||||
auto sep = new SoSeparator;
|
||||
|
||||
auto xyOffset = (parts.getValue() & PlaneIndicator)
|
||||
? planeIndicatorRadius + planeIndicatorMargin
|
||||
: axisMargin;
|
||||
|
||||
if (axes.getValue() & X) {
|
||||
sep->addChild(createAxis("X",
|
||||
Base::Vector3d::UnitX,
|
||||
ViewParams::instance()->getAxisXColor(),
|
||||
xyOffset));
|
||||
}
|
||||
|
||||
if (axes.getValue() & Y) {
|
||||
sep->addChild(createAxis("Y",
|
||||
Base::Vector3d::UnitY,
|
||||
ViewParams::instance()->getAxisYColor(),
|
||||
xyOffset));
|
||||
}
|
||||
|
||||
if (axes.getValue() & Z) {
|
||||
auto zOffset = (parts.getValue() & PlaneIndicator)
|
||||
? planeIndicatorMargin
|
||||
: axisMargin;
|
||||
sep->addChild(createAxis("Z",
|
||||
Base::Vector3d::UnitZ,
|
||||
ViewParams::instance()->getAxisZColor(),
|
||||
zOffset));
|
||||
}
|
||||
|
||||
return sep;
|
||||
}
|
||||
|
||||
SoSeparator* SoFCPlacementIndicatorKit::createPlaneIndicator()
|
||||
{
|
||||
// cylinders are aligned with Y axis for some reason
|
||||
auto rotation = Base::Rotation(Base::Vector3d::UnitY, Base::Vector3d::UnitZ);
|
||||
|
||||
auto pcRotation = new SoRotation();
|
||||
pcRotation->rotation = Base::convertTo<SbRotation>(rotation);
|
||||
|
||||
auto pcComplexity = new SoComplexity();
|
||||
pcComplexity->value = 1.0f;
|
||||
|
||||
auto pcCylinder = new SoCylinder();
|
||||
pcCylinder->height = 0.f;
|
||||
pcCylinder->radius = planeIndicatorRadius;
|
||||
pcCylinder->parts = SoCylinder::TOP;
|
||||
|
||||
const auto gray = Base::Color(0.75f, 0.75f, 0.75f);
|
||||
|
||||
auto pcMaterial = new SoMaterial();
|
||||
pcMaterial->diffuseColor.setValue(Base::convertTo<SbColor>(gray));
|
||||
pcMaterial->ambientColor.connectFrom(&pcMaterial->diffuseColor);
|
||||
pcMaterial->transparency = planeIndicatorTransparency;
|
||||
|
||||
auto sep = new SoSeparator;
|
||||
|
||||
sep->addChild(pcRotation);
|
||||
sep->addChild(pcMaterial);
|
||||
sep->addChild(pcComplexity);
|
||||
sep->addChild(pcCylinder);
|
||||
|
||||
return sep;
|
||||
}
|
||||
|
||||
SoFCPlacementIndicatorKit::~SoFCPlacementIndicatorKit() = default;
|
||||
|
||||
} // namespace Gui
|
||||
@@ -0,0 +1,103 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2024 Kacper Donat <kacper@kadet.net> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SOFCPLACEMENTINDICATORKIT_H
|
||||
#define SOFCPLACEMENTINDICATORKIT_H
|
||||
|
||||
#include <Inventor/nodekits/SoBaseKit.h>
|
||||
|
||||
#include <FCGlobal.h>
|
||||
|
||||
namespace Gui {
|
||||
|
||||
class GuiExport SoFCPlacementIndicatorKit : public SoBaseKit {
|
||||
using inherited = SoBaseKit;
|
||||
|
||||
static constexpr double planeIndicatorRadius = 0.4f;
|
||||
static constexpr double planeIndicatorMargin = 0.2f;
|
||||
static constexpr double planeIndicatorTransparency = 0.3f;
|
||||
|
||||
static constexpr double axisMargin = 0.0f;
|
||||
static constexpr double axisLengthDefault = 0.6f;
|
||||
static constexpr double axisThickness = 0.065f;
|
||||
|
||||
static constexpr double arrowHeadRadius = axisThickness * 1.25f;
|
||||
static constexpr double arrowHeadHeight = arrowHeadRadius * 3.f;
|
||||
|
||||
static constexpr double labelOffset = 0.4f;
|
||||
static constexpr int labelFontSize = 9;
|
||||
|
||||
static constexpr double scaleFactorDefault = 40.f;
|
||||
|
||||
SO_KIT_HEADER(SoFCPlacementIndicatorKit);
|
||||
|
||||
SO_KIT_CATALOG_ENTRY_HEADER(root);
|
||||
|
||||
public:
|
||||
SoFCPlacementIndicatorKit();
|
||||
static void initClass();
|
||||
|
||||
void notify(SoNotList* l) override;
|
||||
|
||||
// clang-format off
|
||||
enum Part
|
||||
{
|
||||
Axes = 1 << 0,
|
||||
PlaneIndicator = 1 << 1,
|
||||
Labels = 1 << 2,
|
||||
ArrowHeads = 1 << 3,
|
||||
|
||||
// common configurations
|
||||
AllParts = Axes | PlaneIndicator | Labels | ArrowHeads,
|
||||
AxisCross = Axes | Labels | ArrowHeads
|
||||
};
|
||||
|
||||
enum Axis
|
||||
{
|
||||
X = 1 << 0,
|
||||
Y = 1 << 1,
|
||||
Z = 1 << 2,
|
||||
AllAxes = X | Y | Z
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
SoSFEnum parts;
|
||||
SoSFEnum axes;
|
||||
SoSFBool coloredAxis;
|
||||
SoSFFloat scaleFactor;
|
||||
SoSFFloat axisLength;
|
||||
|
||||
private:
|
||||
void recomputeGeometry();
|
||||
|
||||
SoSeparator* createOriginIndicator();
|
||||
SoSeparator* createGeometry();
|
||||
SoSeparator* createAxes();
|
||||
SoSeparator* createPlaneIndicator();
|
||||
|
||||
~SoFCPlacementIndicatorKit() override;
|
||||
};
|
||||
|
||||
} // Gui
|
||||
|
||||
#endif //SOFCPLACEMENTINDICATORKIT_H
|
||||
@@ -40,6 +40,7 @@
|
||||
# include <QMenuBar>
|
||||
# include <QMessageBox>
|
||||
# include <QMimeData>
|
||||
# include <QOpenGLWidget>
|
||||
# include <QPainter>
|
||||
# include <QRegularExpression>
|
||||
# include <QRegularExpressionMatch>
|
||||
@@ -115,7 +116,7 @@
|
||||
#include "View3DInventor.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "Dialogs/DlgObjectSelection.h"
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
FC_LOG_LEVEL_INIT("MainWindow",false,true,true)
|
||||
|
||||
@@ -2348,15 +2349,15 @@ void MainWindow::setWindowTitle(const QString& string)
|
||||
auto format = QStringLiteral("#statusBar{color: %1}");
|
||||
if (strcmp(sReason, "colorText") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||
this->msg = format.arg(App::Color::fromPackedRGB<QColor>(col).name());
|
||||
this->msg = format.arg(Base::Color::fromPackedRGB<QColor>(col).name());
|
||||
}
|
||||
else if (strcmp(sReason, "colorWarning") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||
this->wrn = format.arg(App::Color::fromPackedRGB<QColor>(col).name());
|
||||
this->wrn = format.arg(Base::Color::fromPackedRGB<QColor>(col).name());
|
||||
}
|
||||
else if (strcmp(sReason, "colorError") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||
this->err = format.arg(App::Color::fromPackedRGB<QColor>(col).name());
|
||||
this->err = format.arg(Base::Color::fromPackedRGB<QColor>(col).name());
|
||||
}
|
||||
else if (strcmp(sReason, "colorCritical") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned(sReason);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
# include <QMessageBox>
|
||||
# include <QPainter>
|
||||
# include <QSplitter>
|
||||
# include <QSurfaceFormat>
|
||||
# include <QTimer>
|
||||
# include <QVBoxLayout>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
@@ -352,7 +353,7 @@ public:
|
||||
bool smoothing = false;
|
||||
bool glformat = false;
|
||||
int samples = View3DInventorViewer::getNumSamples();
|
||||
QtGLFormat f;
|
||||
QSurfaceFormat f;
|
||||
|
||||
if (samples > 1) {
|
||||
glformat = true;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QPixmap>
|
||||
#include <QMenu>
|
||||
#include <Inventor/SbBox.h>
|
||||
@@ -575,7 +576,7 @@ void RubberbandSelection::initialize()
|
||||
rubberband.setViewer(_pcView3D);
|
||||
rubberband.setWorking(false);
|
||||
_pcView3D->addGraphicsItem(&rubberband);
|
||||
if (QtGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
if (QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
_pcView3D->setRenderType(View3DInventorViewer::Image);
|
||||
}
|
||||
_pcView3D->redraw();
|
||||
@@ -586,7 +587,7 @@ void RubberbandSelection::terminate(bool abort)
|
||||
Q_UNUSED(abort)
|
||||
|
||||
_pcView3D->removeGraphicsItem(&rubberband);
|
||||
if (QtGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
if (QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
_pcView3D->setRenderType(View3DInventorViewer::Native);
|
||||
}
|
||||
_pcView3D->redraw();
|
||||
|
||||
+14
-12
@@ -41,11 +41,13 @@
|
||||
# include <QCursor>
|
||||
# include <QImage>
|
||||
# include <QMenu>
|
||||
# include <QOpenGLFramebufferObject>
|
||||
# include <QOpenGLTexture>
|
||||
# include <QOpenGLWidget>
|
||||
# include <QPainterPath>
|
||||
#endif
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Eigen/Dense>
|
||||
|
||||
@@ -177,9 +179,9 @@ public:
|
||||
float m_InactiveOpacity = 0.5;
|
||||
SbVec2s m_PosOffset = SbVec2s(0,0);
|
||||
|
||||
App::Color m_xColor;
|
||||
App::Color m_yColor;
|
||||
App::Color m_zColor;
|
||||
Base::Color m_xColor;
|
||||
Base::Color m_yColor;
|
||||
Base::Color m_zColor;
|
||||
|
||||
bool m_Prepared = false;
|
||||
static vector<string> m_commands;
|
||||
@@ -196,7 +198,7 @@ private:
|
||||
SbVec2s m_PosAreaBase = SbVec2s(0,0);
|
||||
SbVec2s m_PosAreaSize = SbVec2s(0,0);
|
||||
|
||||
QtGLFramebufferObject* m_PickingFramebuffer;
|
||||
QOpenGLFramebufferObject* m_PickingFramebuffer;
|
||||
Gui::View3DInventorViewer* m_View3DInventorViewer;
|
||||
|
||||
map<PickId, Face> m_Faces;
|
||||
@@ -704,8 +706,8 @@ void NaviCubeImplementation::prepare()
|
||||
if (m_PickingFramebuffer)
|
||||
delete m_PickingFramebuffer;
|
||||
m_PickingFramebuffer =
|
||||
new QtGLFramebufferObject(2 * m_CubeWidgetSize, 2 * m_CubeWidgetSize,
|
||||
QtGLFramebufferObject::CombinedDepthStencil);
|
||||
new QOpenGLFramebufferObject(2 * m_CubeWidgetSize, 2 * m_CubeWidgetSize,
|
||||
QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||
m_View3DInventorViewer->getSoRenderManager()->scheduleRedraw();
|
||||
}
|
||||
|
||||
@@ -935,7 +937,7 @@ NaviCubeImplementation::PickId NaviCubeImplementation::pickFace(short x, short y
|
||||
GLubyte pixels[4] = {0};
|
||||
if (m_PickingFramebuffer && std::abs(x) <= m_CubeWidgetSize / 2 &&
|
||||
std::abs(y) <= m_CubeWidgetSize / 2) {
|
||||
static_cast<QtGLWidget*>(m_View3DInventorViewer->viewport())->makeCurrent();
|
||||
static_cast<QOpenGLWidget*>(m_View3DInventorViewer->viewport())->makeCurrent();
|
||||
m_PickingFramebuffer->bind();
|
||||
|
||||
glViewport(0, 0, m_CubeWidgetSize * 2, m_CubeWidgetSize * 2);
|
||||
@@ -946,7 +948,7 @@ NaviCubeImplementation::PickId NaviCubeImplementation::pickFace(short x, short y
|
||||
glReadPixels(2 * x + m_CubeWidgetSize, 2 * y + m_CubeWidgetSize, 1, 1,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
|
||||
m_PickingFramebuffer->release();
|
||||
static_cast<QtGLWidget*>(m_View3DInventorViewer->viewport())->doneCurrent();
|
||||
static_cast<QOpenGLWidget*>(m_View3DInventorViewer->viewport())->doneCurrent();
|
||||
}
|
||||
return pixels[3] == 255 ? static_cast<PickId>(pixels[0]) : PickId::None;
|
||||
}
|
||||
@@ -1191,11 +1193,11 @@ void NaviCube::updateColors()
|
||||
unsigned long colorLong;
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
m_NaviCubeImplementation->m_xColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
m_NaviCubeImplementation->m_xColor = Base::Color(static_cast<uint32_t>(colorLong));
|
||||
colorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
m_NaviCubeImplementation->m_yColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
m_NaviCubeImplementation->m_yColor = Base::Color(static_cast<uint32_t>(colorLong));
|
||||
colorLong = Gui::ViewParams::instance()->getAxisZColor();
|
||||
m_NaviCubeImplementation->m_zColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
m_NaviCubeImplementation->m_zColor = Base::Color(static_cast<uint32_t>(colorLong));
|
||||
}
|
||||
|
||||
void NaviCube::setNaviCubeCommands(const std::vector<std::string>& cmd)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
#include "PrefWidgets.h"
|
||||
|
||||
@@ -562,12 +562,12 @@ void PrefColorButton::restorePreferences()
|
||||
if (!m_Restored)
|
||||
m_Default = color();
|
||||
|
||||
unsigned int icol = App::Color::asPackedRGBA<QColor>(m_Default);
|
||||
unsigned int icol = Base::Color::asPackedRGBA<QColor>(m_Default);
|
||||
|
||||
unsigned long lcol = static_cast<unsigned long>(icol);
|
||||
lcol = getWindowParameter()->GetUnsigned(entryName(), lcol);
|
||||
icol = static_cast<unsigned int>(lcol);
|
||||
QColor value = App::Color::fromPackedRGBA<QColor>(icol);
|
||||
QColor value = Base::Color::fromPackedRGBA<QColor>(icol);
|
||||
if (!this->allowTransparency())
|
||||
value.setAlpha(0xff);
|
||||
setColor(value);
|
||||
@@ -583,7 +583,7 @@ void PrefColorButton::savePreferences()
|
||||
|
||||
QColor col = color();
|
||||
// (r,g,b,a) with a = 255 (opaque)
|
||||
unsigned int icol = App::Color::asPackedRGBA<QColor>(col);
|
||||
unsigned int icol = Base::Color::asPackedRGBA<QColor>(col);
|
||||
unsigned long lcol = static_cast<unsigned long>(icol);
|
||||
getWindowParameter()->SetUnsigned( entryName(), lcol );
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <QFontDatabase>
|
||||
#endif
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
#include <Gui/PythonEditor.h>
|
||||
#include <Gui/Tools.h>
|
||||
|
||||
@@ -85,63 +85,63 @@ DlgSettingsEditor::DlgSettingsEditor(QWidget* parent)
|
||||
d = new DlgSettingsEditorP();
|
||||
QColor col;
|
||||
col = qApp->palette().windowText().color();
|
||||
unsigned int lText = App::Color::asPackedRGB<QColor>(col);
|
||||
unsigned int lText = Base::Color::asPackedRGB<QColor>(col);
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Text")), lText));
|
||||
|
||||
unsigned int lBookmarks = App::Color::asPackedRGB<QColor>(QColor(Qt::cyan));
|
||||
unsigned int lBookmarks = Base::Color::asPackedRGB<QColor>(QColor(Qt::cyan));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Bookmark")), lBookmarks));
|
||||
|
||||
unsigned int lBreakpnts = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
unsigned int lBreakpnts = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Breakpoint")), lBreakpnts));
|
||||
|
||||
unsigned int lKeywords = App::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
unsigned int lKeywords = Base::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Keyword")), lKeywords));
|
||||
|
||||
unsigned int lComments = App::Color::asPackedRGB<QColor>(QColor(0, 170, 0));
|
||||
unsigned int lComments = Base::Color::asPackedRGB<QColor>(QColor(0, 170, 0));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Comment")), lComments));
|
||||
|
||||
unsigned int lBlockCom = App::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
unsigned int lBlockCom = Base::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Block comment")), lBlockCom));
|
||||
|
||||
unsigned int lNumbers = App::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
unsigned int lNumbers = Base::Color::asPackedRGB<QColor>(QColor(Qt::blue));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Number")), lNumbers));
|
||||
|
||||
unsigned int lStrings = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
unsigned int lStrings = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("String")), lStrings));
|
||||
|
||||
unsigned int lCharacter = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
unsigned int lCharacter = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Character")), lCharacter));
|
||||
|
||||
unsigned int lClass = App::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
unsigned int lClass = Base::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Class name")), lClass));
|
||||
|
||||
unsigned int lDefine = App::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
unsigned int lDefine = Base::Color::asPackedRGB<QColor>(QColor(255, 170, 0));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Define name")), lDefine));
|
||||
|
||||
unsigned int lOperat = App::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
unsigned int lOperat = Base::Color::asPackedRGB<QColor>(QColor(160, 160, 164));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Operator")), lOperat));
|
||||
|
||||
unsigned int lPyOutput = App::Color::asPackedRGB<QColor>(QColor(170, 170, 127));
|
||||
unsigned int lPyOutput = Base::Color::asPackedRGB<QColor>(QColor(170, 170, 127));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Python output")), lPyOutput));
|
||||
|
||||
unsigned int lPyError = App::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
unsigned int lPyError = Base::Color::asPackedRGB<QColor>(QColor(Qt::red));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Python error")), lPyError));
|
||||
|
||||
unsigned int lCLine = App::Color::asPackedRGB<QColor>(QColor(224, 224, 224));
|
||||
unsigned int lCLine = Base::Color::asPackedRGB<QColor>(QColor(224, 224, 224));
|
||||
d->colormap.push_back(
|
||||
QPair<QString, unsigned int>(QString::fromLatin1(QT_TR_NOOP("Current line highlight")),
|
||||
lCLine));
|
||||
@@ -195,14 +195,14 @@ void DlgSettingsEditor::onDisplayItemsCurrentItemChanged(QTreeWidgetItem* item)
|
||||
{
|
||||
int index = ui->displayItems->indexOfTopLevelItem(item);
|
||||
unsigned int col = d->colormap[index].second;
|
||||
ui->colorButton->setColor(App::Color::fromPackedRGB<QColor>(col));
|
||||
ui->colorButton->setColor(Base::Color::fromPackedRGB<QColor>(col));
|
||||
}
|
||||
|
||||
/** Updates the color map if a color was changed */
|
||||
void DlgSettingsEditor::onColorButtonChanged()
|
||||
{
|
||||
QColor col = ui->colorButton->color();
|
||||
unsigned int lcol = App::Color::asPackedRGB<QColor>(col);
|
||||
unsigned int lcol = Base::Color::asPackedRGB<QColor>(col);
|
||||
|
||||
int index = ui->displayItems->indexOfTopLevelItem(ui->displayItems->currentItem());
|
||||
d->colormap[index].second = lcol;
|
||||
@@ -272,7 +272,7 @@ void DlgSettingsEditor::loadSettings()
|
||||
auto col = static_cast<unsigned long>(textColor);
|
||||
col = hGrp->GetUnsigned(textType.toLatin1(), col);
|
||||
textColor = static_cast<unsigned int>(col);
|
||||
QColor color = App::Color::fromPackedRGB<QColor>(col);
|
||||
QColor color = Base::Color::fromPackedRGB<QColor>(col);
|
||||
pythonSyntax->setColor(textType, color);
|
||||
}
|
||||
|
||||
|
||||
@@ -327,6 +327,10 @@ void DlgSettingsLightSources::resetSettingsToDefaults()
|
||||
{
|
||||
PreferencePage::resetSettingsToDefaults();
|
||||
|
||||
hGrp->RemoveASCII("HeadlightDirection");
|
||||
hGrp->RemoveASCII("BacklightDirection");
|
||||
hGrp->RemoveASCII("FillLightDirection");
|
||||
|
||||
loadSettings();
|
||||
configureViewer();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#endif
|
||||
|
||||
#include <Base/Interpreter.h>
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
#include "PythonConsole.h"
|
||||
#include "PythonConsolePy.h"
|
||||
@@ -947,7 +947,7 @@ void PythonConsole::changeEvent(QEvent *e)
|
||||
else if (e->type() == QEvent::StyleChange) {
|
||||
QPalette pal = qApp->palette();
|
||||
QColor color = pal.windowText().color();
|
||||
unsigned int text = App::Color::asPackedRGB<QColor>(color);
|
||||
unsigned int text = Base::Color::asPackedRGB<QColor>(color);
|
||||
auto value = static_cast<unsigned long>(text);
|
||||
// if this parameter is not already set use the style's window text color
|
||||
value = getWindowParameter()->GetUnsigned("Text", value);
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
#include <QOpenGLDebugMessage>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPaintEngine>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
#include <QMetaObject>
|
||||
#include <QOpenGLDebugLogger>
|
||||
#include <QOpenGLDebugMessage>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPaintEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QWindow>
|
||||
@@ -230,7 +231,7 @@ public:
|
||||
};
|
||||
|
||||
/*! constructor */
|
||||
QuarterWidget::QuarterWidget(const QtGLFormat & format, QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f)
|
||||
QuarterWidget::QuarterWidget(const QSurfaceFormat & format, QWidget * parent, const QOpenGLWidget * sharewidget, Qt::WindowFlags f)
|
||||
: inherited(parent)
|
||||
{
|
||||
Q_UNUSED(f);
|
||||
@@ -238,15 +239,15 @@ QuarterWidget::QuarterWidget(const QtGLFormat & format, QWidget * parent, const
|
||||
}
|
||||
|
||||
/*! constructor */
|
||||
QuarterWidget::QuarterWidget(QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f)
|
||||
QuarterWidget::QuarterWidget(QWidget * parent, const QOpenGLWidget * sharewidget, Qt::WindowFlags f)
|
||||
: inherited(parent)
|
||||
{
|
||||
Q_UNUSED(f);
|
||||
this->constructor(QtGLFormat(), sharewidget);
|
||||
this->constructor(QSurfaceFormat(), sharewidget);
|
||||
}
|
||||
|
||||
/*! constructor */
|
||||
QuarterWidget::QuarterWidget(QtGLContext * context, QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f)
|
||||
QuarterWidget::QuarterWidget(QOpenGLContext * context, QWidget * parent, const QOpenGLWidget * sharewidget, Qt::WindowFlags f)
|
||||
: inherited(parent)
|
||||
{
|
||||
Q_UNUSED(f);
|
||||
@@ -254,7 +255,7 @@ QuarterWidget::QuarterWidget(QtGLContext * context, QWidget * parent, const QtGL
|
||||
}
|
||||
|
||||
void
|
||||
QuarterWidget::constructor(const QtGLFormat & format, const QtGLWidget * sharewidget)
|
||||
QuarterWidget::constructor(const QSurfaceFormat & format, const QOpenGLWidget * sharewidget)
|
||||
{
|
||||
QGraphicsScene* scene = new QGraphicsScene(this);
|
||||
setScene(scene);
|
||||
@@ -856,7 +857,7 @@ void QuarterWidget::paintEvent(QPaintEvent* event)
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
||||
QtGLWidget* w = static_cast<QtGLWidget*>(this->viewport());
|
||||
QOpenGLWidget* w = static_cast<QOpenGLWidget*>(this->viewport());
|
||||
if (!w->isValid()) {
|
||||
qWarning() << "No valid GL context found!";
|
||||
return;
|
||||
|
||||
@@ -39,10 +39,12 @@
|
||||
#include <QColor>
|
||||
#include <QGraphicsView>
|
||||
#include <QUrl>
|
||||
#include <QtOpenGL.h>
|
||||
|
||||
#include "Basic.h"
|
||||
|
||||
class QOpenGLContext;
|
||||
class QOpenGLWidget;
|
||||
class QSurfaceFormat;
|
||||
|
||||
class QMenu;
|
||||
class SoNode;
|
||||
@@ -114,9 +116,9 @@ public:
|
||||
|
||||
|
||||
public:
|
||||
explicit QuarterWidget(QWidget * parent = nullptr, const QtGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
explicit QuarterWidget(QtGLContext * context, QWidget * parent = nullptr, const QtGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = nullptr, const QtGLWidget * shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
explicit QuarterWidget(QWidget * parent = nullptr, const QOpenGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
explicit QuarterWidget(QOpenGLContext * context, QWidget * parent = nullptr, const QOpenGLWidget * sharewidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
explicit QuarterWidget(const QSurfaceFormat & format, QWidget * parent = nullptr, const QOpenGLWidget * shareWidget = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
~QuarterWidget() override;
|
||||
|
||||
TransparencyType transparencyType() const;
|
||||
@@ -203,7 +205,7 @@ protected:
|
||||
virtual bool updateDevicePixelRatio();
|
||||
|
||||
private:
|
||||
void constructor(const QtGLFormat& format, const QtGLWidget* sharewidget);
|
||||
void constructor(const QSurfaceFormat& format, const QOpenGLWidget* sharewidget);
|
||||
friend class QuarterWidgetP;
|
||||
class QuarterWidgetP * pimpl;
|
||||
bool initialized;
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QMenu>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include <Inventor/SoEventManager.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
@@ -63,12 +65,12 @@ using namespace SIM::Coin3D::Quarter;
|
||||
class QuarterWidgetP_cachecontext {
|
||||
public:
|
||||
uint32_t id;
|
||||
SbList <const QtGLWidget *> widgetlist;
|
||||
SbList <const QOpenGLWidget *> widgetlist;
|
||||
};
|
||||
|
||||
static SbList <QuarterWidgetP_cachecontext *> * cachecontext_list = nullptr;
|
||||
|
||||
QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sharewidget)
|
||||
QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QOpenGLWidget * sharewidget)
|
||||
: master(masterptr),
|
||||
scene(nullptr),
|
||||
eventfilter(nullptr),
|
||||
@@ -104,7 +106,7 @@ QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sha
|
||||
|
||||
QuarterWidgetP::~QuarterWidgetP()
|
||||
{
|
||||
QtGLWidget* glMaster = static_cast<QtGLWidget*>(this->master->viewport());
|
||||
QOpenGLWidget* glMaster = static_cast<QOpenGLWidget*>(this->master->viewport());
|
||||
removeFromCacheContext(this->cachecontext, glMaster);
|
||||
delete this->contextmenu;
|
||||
}
|
||||
@@ -133,7 +135,7 @@ QuarterWidgetP::getCacheContextId() const
|
||||
}
|
||||
|
||||
QuarterWidgetP_cachecontext *
|
||||
QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget)
|
||||
QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QOpenGLWidget * sharewidget)
|
||||
{
|
||||
if (!cachecontext_list) {
|
||||
// FIXME: static memory leak
|
||||
@@ -144,34 +146,34 @@ QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QtGLWidget * shar
|
||||
|
||||
for (int j = 0; j < cachecontext->widgetlist.getLength(); j++) {
|
||||
if (cachecontext->widgetlist[j] == sharewidget) {
|
||||
cachecontext->widgetlist.append(static_cast<const QtGLWidget*>(widget->viewport()));
|
||||
cachecontext->widgetlist.append(static_cast<const QOpenGLWidget*>(widget->viewport()));
|
||||
return cachecontext;
|
||||
}
|
||||
}
|
||||
}
|
||||
QuarterWidgetP_cachecontext * cachecontext = new QuarterWidgetP_cachecontext;
|
||||
cachecontext->id = SoGLCacheContextElement::getUniqueCacheContext();
|
||||
cachecontext->widgetlist.append(static_cast<const QtGLWidget*>(widget->viewport()));
|
||||
cachecontext->widgetlist.append(static_cast<const QOpenGLWidget*>(widget->viewport()));
|
||||
cachecontext_list->append(cachecontext);
|
||||
|
||||
return cachecontext;
|
||||
}
|
||||
|
||||
void
|
||||
QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QtGLWidget * widget)
|
||||
QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QOpenGLWidget * widget)
|
||||
{
|
||||
context->widgetlist.removeItem((const QtGLWidget*) widget);
|
||||
context->widgetlist.removeItem((const QOpenGLWidget*) widget);
|
||||
|
||||
if (context->widgetlist.getLength() == 0) { // last context in this share group?
|
||||
assert(cachecontext_list);
|
||||
|
||||
for (int i = 0; i < cachecontext_list->getLength(); i++) {
|
||||
if ((*cachecontext_list)[i] == context) {
|
||||
QtGLContext* glcontext = widget->context();
|
||||
QOpenGLContext* glcontext = widget->context();
|
||||
if (glcontext) {
|
||||
// set the context while calling destructingContext() (might trigger OpenGL calls)
|
||||
if (glcontext->isValid()) {
|
||||
const_cast<QtGLWidget*> (widget)->makeCurrent();
|
||||
const_cast<QOpenGLWidget*> (widget)->makeCurrent();
|
||||
}
|
||||
// fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818
|
||||
(void) cc_glglue_instance(context->id);
|
||||
@@ -180,7 +182,7 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co
|
||||
SoContextHandler::destructingContext(context->id);
|
||||
if (glcontext) {
|
||||
if (glcontext->isValid()) {
|
||||
const_cast<QtGLWidget*> (widget)->doneCurrent();
|
||||
const_cast<QOpenGLWidget*> (widget)->doneCurrent();
|
||||
}
|
||||
}
|
||||
delete context;
|
||||
@@ -191,9 +193,9 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co
|
||||
}
|
||||
|
||||
void
|
||||
QuarterWidgetP::replaceGLWidget(const QtGLWidget * newviewport)
|
||||
QuarterWidgetP::replaceGLWidget(const QOpenGLWidget * newviewport)
|
||||
{
|
||||
QtGLWidget* oldviewport = static_cast<QtGLWidget*>(this->master->viewport());
|
||||
QOpenGLWidget* oldviewport = static_cast<QOpenGLWidget*>(this->master->viewport());
|
||||
cachecontext->widgetlist.removeItem(oldviewport);
|
||||
cachecontext->widgetlist.append(newviewport);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#include <Inventor/SbBasic.h>
|
||||
#include <QList>
|
||||
#include <QUrl>
|
||||
#include <QtOpenGL.h>
|
||||
|
||||
class QOpenGLWidget;
|
||||
|
||||
class SoNode;
|
||||
class SoCamera;
|
||||
@@ -61,7 +61,7 @@ class ContextMenu;
|
||||
class QuarterWidgetP {
|
||||
public:
|
||||
|
||||
QuarterWidgetP(class QuarterWidget * master, const QtGLWidget * sharewidget);
|
||||
QuarterWidgetP(class QuarterWidget * master, const QOpenGLWidget * sharewidget);
|
||||
~QuarterWidgetP();
|
||||
|
||||
SoCamera * searchForCamera(SoNode * root);
|
||||
@@ -109,11 +109,11 @@ public:
|
||||
mutable ContextMenu * contextmenu;
|
||||
|
||||
static bool nativeEventFilter(void * message, long * result);
|
||||
void replaceGLWidget(const QtGLWidget * newviewport);
|
||||
void replaceGLWidget(const QOpenGLWidget * newviewport);
|
||||
|
||||
private:
|
||||
QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget);
|
||||
static void removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QtGLWidget * widget);
|
||||
QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QOpenGLWidget * sharewidget);
|
||||
static void removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QOpenGLWidget * widget);
|
||||
};
|
||||
|
||||
#endif // QUARTER_QUARTERWIDGETP_H
|
||||
|
||||
@@ -34,11 +34,16 @@
|
||||
#include <Inventor/nodes/SoPerspectiveCamera.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
|
||||
#if !defined(FC_OS_MACOSX)
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# ifdef FC_OS_MACOSX
|
||||
# include <OpenGL/gl.h>
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glu.h>
|
||||
# include <GL/glext.h>
|
||||
#endif
|
||||
# include <GL/glu.h>
|
||||
# endif
|
||||
|
||||
#include "SoQTQuarterAdaptor.h"
|
||||
|
||||
@@ -148,7 +153,7 @@ constexpr const int defaultSize = 100;
|
||||
|
||||
// NOLINTBEGIN(readability-implicit-bool-conversion)
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent,
|
||||
const QtGLWidget* sharewidget,
|
||||
const QOpenGLWidget* sharewidget,
|
||||
Qt::WindowFlags flags)
|
||||
: QuarterWidget(parent, sharewidget, flags)
|
||||
, matrixaction(SbViewportRegion(defaultSize, defaultSize))
|
||||
@@ -156,9 +161,9 @@ SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent,
|
||||
init();
|
||||
}
|
||||
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QtGLFormat& format,
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QSurfaceFormat& format,
|
||||
QWidget* parent,
|
||||
const QtGLWidget* shareWidget,
|
||||
const QOpenGLWidget* shareWidget,
|
||||
Qt::WindowFlags flags)
|
||||
: QuarterWidget(format, parent, shareWidget, flags)
|
||||
, matrixaction(SbViewportRegion(defaultSize, defaultSize))
|
||||
@@ -166,9 +171,9 @@ SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QtGLFormat& f
|
||||
init();
|
||||
}
|
||||
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QtGLContext* context,
|
||||
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QOpenGLContext* context,
|
||||
QWidget* parent,
|
||||
const QtGLWidget* sharewidget,
|
||||
const QOpenGLWidget* sharewidget,
|
||||
Qt::WindowFlags flags)
|
||||
: QuarterWidget(context, parent, sharewidget, flags)
|
||||
, matrixaction(SbViewportRegion(defaultSize, defaultSize))
|
||||
@@ -638,7 +643,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::draw2DString(
|
||||
const char* str,
|
||||
SbVec2s glsize,
|
||||
SbVec2f position,
|
||||
App::Color color = App::Color(1.0F, 1.0F, 0.0F)) // retains yellow as default color
|
||||
Base::Color color = Base::Color(1.0F, 1.0F, 0.0F)) // retains yellow as default color
|
||||
{
|
||||
// Store GL state.
|
||||
glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT);
|
||||
|
||||
@@ -27,10 +27,13 @@
|
||||
#include <Inventor/lists/SoCallbackList.h>
|
||||
#include <Inventor/sensors/SoTimerSensor.h>
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
#include "QuarterWidget.h"
|
||||
|
||||
class QOpenGLContext;
|
||||
class QOpenGLWidget;
|
||||
class QSurfaceFormat;
|
||||
|
||||
class SbViewportRegion;
|
||||
class SoCamera;
|
||||
@@ -50,15 +53,15 @@ class QUARTER_DLL_API SoQTQuarterAdaptor : public QuarterWidget {
|
||||
|
||||
public:
|
||||
explicit SoQTQuarterAdaptor(QWidget* parent = nullptr,
|
||||
const QtGLWidget* sharewidget = nullptr,
|
||||
const QOpenGLWidget* sharewidget = nullptr,
|
||||
Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
explicit SoQTQuarterAdaptor(const QtGLFormat& format,
|
||||
explicit SoQTQuarterAdaptor(const QSurfaceFormat& format,
|
||||
QWidget* parent = nullptr,
|
||||
const QtGLWidget* shareWidget = nullptr,
|
||||
const QOpenGLWidget* shareWidget = nullptr,
|
||||
Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
explicit SoQTQuarterAdaptor(QtGLContext* context,
|
||||
explicit SoQTQuarterAdaptor(QOpenGLContext* context,
|
||||
QWidget* parent = nullptr,
|
||||
const QtGLWidget* sharewidget = nullptr,
|
||||
const QOpenGLWidget* sharewidget = nullptr,
|
||||
Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
~SoQTQuarterAdaptor() override;
|
||||
|
||||
@@ -152,7 +155,7 @@ private:
|
||||
SoNode * m_storedcamera = nullptr;
|
||||
|
||||
protected:
|
||||
static void draw2DString(const char * str, SbVec2s glsize, SbVec2f position, App::Color color);
|
||||
static void draw2DString(const char * str, SbVec2s glsize, SbVec2f position, Base::Color color);
|
||||
static void printString(const char * str);
|
||||
SbVec2f framesPerSecond; // NOLINT
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include <Base/Interpreter.h>
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
#include "ReportView.h"
|
||||
#include "Application.h"
|
||||
@@ -566,7 +566,7 @@ void ReportOutput::changeEvent(QEvent *ev)
|
||||
if (ev->type() == QEvent::StyleChange) {
|
||||
QPalette pal = qApp->palette();
|
||||
QColor color = pal.windowText().color();
|
||||
unsigned int text = App::Color::asPackedRGB<QColor>(color);
|
||||
unsigned int text = Base::Color::asPackedRGB<QColor>(color);
|
||||
auto value = static_cast<unsigned long>(text);
|
||||
// if this parameter is not already set use the style's window text color
|
||||
value = getWindowParameter()->GetUnsigned("colorText", value);
|
||||
@@ -831,7 +831,7 @@ void ReportOutput::OnChange(Base::Subject<const char*> &rCaller, const char * sR
|
||||
}
|
||||
else if (strcmp(sReason, "colorText") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned( sReason );
|
||||
reportHl->setTextColor(App::Color::fromPackedRGB<QColor>(col));
|
||||
reportHl->setTextColor(Base::Color::fromPackedRGB<QColor>(col));
|
||||
}
|
||||
else if (strcmp(sReason, "colorCriticalText") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned( sReason );
|
||||
@@ -839,15 +839,15 @@ void ReportOutput::OnChange(Base::Subject<const char*> &rCaller, const char * sR
|
||||
}
|
||||
else if (strcmp(sReason, "colorLogging") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned( sReason );
|
||||
reportHl->setLogColor(App::Color::fromPackedRGB<QColor>(col));
|
||||
reportHl->setLogColor(Base::Color::fromPackedRGB<QColor>(col));
|
||||
}
|
||||
else if (strcmp(sReason, "colorWarning") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned( sReason );
|
||||
reportHl->setWarningColor(App::Color::fromPackedRGB<QColor>(col));
|
||||
reportHl->setWarningColor(Base::Color::fromPackedRGB<QColor>(col));
|
||||
}
|
||||
else if (strcmp(sReason, "colorError") == 0) {
|
||||
unsigned long col = rclGrp.GetUnsigned( sReason );
|
||||
reportHl->setErrorColor(App::Color::fromPackedRGB<QColor>(col));
|
||||
reportHl->setErrorColor(Base::Color::fromPackedRGB<QColor>(col));
|
||||
}
|
||||
else if (strcmp(sReason, "checkGoToEnd") == 0) {
|
||||
gotoEnd = rclGrp.GetBool(sReason, gotoEnd);
|
||||
|
||||
@@ -34,8 +34,6 @@ std::vector<SelectionObserverPython*> SelectionObserverPython::_instances;
|
||||
|
||||
void SelectionObserverPythonHandler::init(PyObject* obj)
|
||||
{
|
||||
this->inst = obj;
|
||||
|
||||
#undef FC_PY_ELEMENT
|
||||
#define FC_PY_ELEMENT(_name) FC_PY_GetCallable(obj,#_name,py_##_name);
|
||||
FC_PY_SEL_OBSERVER
|
||||
@@ -209,7 +207,7 @@ void SelectionObserverPythonHandler::removePreselection(const SelectionChanges&
|
||||
|
||||
|
||||
SelectionObserverPython::SelectionObserverPython(const Py::Object& obj, ResolveMode resolve)
|
||||
: SelectionObserver(true, resolve)
|
||||
: SelectionObserver(true, resolve), inst(obj)
|
||||
{
|
||||
this->init(obj.ptr());
|
||||
}
|
||||
|
||||
@@ -52,8 +52,6 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
PyObject* inst{nullptr};
|
||||
|
||||
#define FC_PY_SEL_OBSERVER \
|
||||
FC_PY_ELEMENT(onSelectionChanged) \
|
||||
FC_PY_ELEMENT(addSelection) \
|
||||
|
||||
@@ -884,7 +884,7 @@ SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight )
|
||||
|
||||
SoState *state = action->getState();
|
||||
|
||||
QtGLWidget* window;
|
||||
QOpenGLWidget* window;
|
||||
SoGLRenderAction *glAction;
|
||||
SoGLWidgetElement::get(state, window);
|
||||
SoGLRenderActionElement::get(state, glAction);
|
||||
|
||||
@@ -125,8 +125,8 @@ int SoFCSelectionContext::merge(int status, SoFCSelectionContextBasePtr &output,
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SoFCSelectionContextEx::setColors(
|
||||
const std::map<std::string,App::Color> &colors, const std::string &element) {
|
||||
std::map<int,App::Color> tmp;
|
||||
const std::map<std::string,Base::Color> &colors, const std::string &element) {
|
||||
std::map<int,Base::Color> tmp;
|
||||
auto it = colors.find("");
|
||||
if(it!=colors.end())
|
||||
tmp[-1] = it->second;
|
||||
@@ -149,7 +149,7 @@ bool SoFCSelectionContextEx::setColors(
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t SoFCSelectionContextEx::packColor(const App::Color &c, bool &hasTransparency) {
|
||||
uint32_t SoFCSelectionContextEx::packColor(const Base::Color &c, bool &hasTransparency) {
|
||||
float trans = std::max(trans0,c.a);
|
||||
if(trans>0)
|
||||
hasTransparency = true;
|
||||
|
||||
@@ -105,11 +105,11 @@ using SoFCSelectionContextExPtr = std::shared_ptr<SoFCSelectionContextEx>;
|
||||
|
||||
struct GuiExport SoFCSelectionContextEx : SoFCSelectionContext
|
||||
{
|
||||
std::map<int,App::Color> colors;
|
||||
std::map<int,Base::Color> colors;
|
||||
float trans0 = 0.0;
|
||||
|
||||
bool setColors(const std::map<std::string,App::Color> &colors, const std::string &element);
|
||||
uint32_t packColor(const App::Color &c, bool &hasTransparency);
|
||||
bool setColors(const std::map<std::string,Base::Color> &colors, const std::string &element);
|
||||
uint32_t packColor(const Base::Color &c, bool &hasTransparency);
|
||||
bool applyColor(int idx, std::vector<uint32_t> &packedColors, bool &hasTransparency);
|
||||
bool isSingleColor(uint32_t &color, bool &hasTransparency);
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/GeoFeature.h>
|
||||
#include <App/ElementNamingUtils.h>
|
||||
@@ -788,7 +790,7 @@ void SoFCUnifiedSelection::GLRenderBelowPath(SoGLRenderAction * action)
|
||||
// this is called when a selection gate forbade to select an object
|
||||
// and the user moved the mouse to an empty area
|
||||
this->preSelection = -1;
|
||||
QtGLWidget* window;
|
||||
QOpenGLWidget* window;
|
||||
SoState *state = action->getState();
|
||||
SoGLWidgetElement::get(state, window);
|
||||
QWidget* parent = window ? window->parentWidget() : nullptr;
|
||||
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
return overrideColor;
|
||||
}
|
||||
|
||||
void setColorOverride(App::Color c) {
|
||||
void setColorOverride(Base::Color c) {
|
||||
overrideColor = true;
|
||||
colorOverride = SbColor(c.r,c.g,c.b);
|
||||
transOverride = c.a;
|
||||
@@ -425,13 +425,13 @@ public:
|
||||
_secondary = enable;
|
||||
}
|
||||
|
||||
const std::map<std::string,App::Color> &getColors() const {
|
||||
const std::map<std::string,Base::Color> &getColors() const {
|
||||
return _colors;
|
||||
}
|
||||
void setColors(const std::map<std::string,App::Color> &colors) {
|
||||
void setColors(const std::map<std::string,Base::Color> &colors) {
|
||||
_colors = colors;
|
||||
}
|
||||
void swapColors(std::map<std::string,App::Color> &colors) {
|
||||
void swapColors(std::map<std::string,Base::Color> &colors) {
|
||||
_colors.swap(colors);
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ private:
|
||||
Type _type;
|
||||
SbColor _color;
|
||||
const SoDetail* _det{nullptr};
|
||||
std::map<std::string,App::Color> _colors;
|
||||
std::map<std::string,Base::Color> _colors;
|
||||
bool _secondary;
|
||||
};
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ void SoFCColorBar::customize(SoFCColorBarBase* child)
|
||||
}
|
||||
}
|
||||
|
||||
App::Color SoFCColorBar::getColor( float fVal ) const
|
||||
Base::Color SoFCColorBar::getColor( float fVal ) const
|
||||
{
|
||||
return this->getActiveBar()->getColor( fVal );
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
*
|
||||
* This method must be implemented in subclasses.
|
||||
*/
|
||||
App::Color getColor(float fVal) const override = 0;
|
||||
Base::Color getColor(float fVal) const override = 0;
|
||||
/**
|
||||
* Returns always true if the color bar is in mode to show colors to arbitrary values of \a fVal,
|
||||
* otherwise true is returned if \a fVal is within the specified parameter range, if not false is
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
/**
|
||||
* Returns the associated color to the value \a fVal of the currently active color bar.
|
||||
*/
|
||||
App::Color getColor(float fVal) const override;
|
||||
Base::Color getColor(float fVal) const override;
|
||||
/**
|
||||
* Sets whether values outside the range should be in gray,
|
||||
*/
|
||||
|
||||
@@ -105,7 +105,7 @@ const char* SoFCColorGradient::getColorBarName() const
|
||||
|
||||
void SoFCColorGradient::applyFormat(const SoLabelTextFormat& fmt)
|
||||
{
|
||||
auto textColor = App::Color(fmt.textColor);
|
||||
auto textColor = Base::Color(fmt.textColor);
|
||||
|
||||
for (int j = 0; j < labels->getNumChildren(); j++) {
|
||||
if (labels->getChild(j)->getTypeId() == SoBaseColor::getClassTypeId()) {
|
||||
@@ -131,7 +131,7 @@ void SoFCColorGradient::setMarkerLabel(const SoMFString& label)
|
||||
auto trans = new SoTransform;
|
||||
|
||||
SoLabelTextFormat fmt = getFormat();
|
||||
auto textColor = App::Color(fmt.textColor);
|
||||
auto textColor = Base::Color(fmt.textColor);
|
||||
auto textFont = new SoFont;
|
||||
auto color = new SoBaseColor;
|
||||
textFont->name.setValue("Helvetica,Arial,Times New Roman");
|
||||
@@ -356,7 +356,7 @@ SoMaterial* SoFCColorGradient::createMaterial() const
|
||||
auto mat = new SoMaterial;
|
||||
mat->diffuseColor.setNum(2 * numColors);
|
||||
for (int k = 0; k < numColors; k++) {
|
||||
App::Color col = model.colors[numColors - k - 1];
|
||||
Base::Color col = model.colors[numColors - k - 1];
|
||||
mat->diffuseColor.set1Value(2 * k, col.r, col.g, col.b);
|
||||
mat->diffuseColor.set1Value(2 * k + 1, col.r, col.g, col.b);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
/**
|
||||
* Returns the associated color to the value \a fVal.
|
||||
*/
|
||||
App::Color getColor (float fVal) const override { return _cColGrad.getColor(fVal); }
|
||||
Base::Color getColor (float fVal) const override { return _cColGrad.getColor(fVal); }
|
||||
void setOutsideGrayed (bool bVal) override { _cColGrad.setOutsideGrayed(bVal); }
|
||||
/**
|
||||
* Returns always true if the gradient is in mode to show colors to arbitrary values of \a fVal,
|
||||
|
||||
@@ -339,7 +339,7 @@ void SoFCColorLegend::setColorLegend(const App::ColorLegend& legend)
|
||||
auto mat = new SoMaterial;
|
||||
mat->diffuseColor.setNum(intFields);
|
||||
for (std::size_t k = 0; k < numFields; k++) {
|
||||
App::Color col = legend.getColor(k);
|
||||
Base::Color col = legend.getColor(k);
|
||||
mat->diffuseColor.set1Value(k, col.r, col.g, col.b);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
void setColorLegend (const App::ColorLegend& legend);
|
||||
|
||||
unsigned short getColorIndex (float fVal) const { return _currentLegend.getColorIndex(fVal); }
|
||||
App::Color getColor (float fVal) const override { return _currentLegend.getColor(fVal); }
|
||||
Base::Color getColor (float fVal) const override { return _currentLegend.getColor(fVal); }
|
||||
void setOutsideGrayed (bool bVal) override { _currentLegend.setOutsideGrayed(bVal); }
|
||||
bool isVisible (float) const override { return false; }
|
||||
float getMinValue () const override { return _currentLegend.getMinValue(); }
|
||||
|
||||
@@ -79,6 +79,8 @@
|
||||
#include "propertyeditor/PropertyItem.h"
|
||||
#include "ArcEngine.h"
|
||||
|
||||
#include <Inventor/SoFCPlacementIndicatorKit.h>
|
||||
|
||||
|
||||
using namespace Gui;
|
||||
using namespace Gui::Inventor;
|
||||
@@ -148,6 +150,7 @@ void Gui::SoFCDB::init()
|
||||
SoMouseWheelEvent ::initClass();
|
||||
So3DAnnotation ::initClass();
|
||||
SoDelayedAnnotationsElement ::initClass();
|
||||
SoFCPlacementIndicatorKit ::initClass();
|
||||
|
||||
PropertyItem ::init();
|
||||
PropertySeparatorItem ::init();
|
||||
|
||||
@@ -86,14 +86,14 @@ void SoGLWidgetElement::init(SoState * state)
|
||||
|
||||
SoGLWidgetElement::~SoGLWidgetElement() = default;
|
||||
|
||||
void SoGLWidgetElement::set(SoState * state, QtGLWidget * window)
|
||||
void SoGLWidgetElement::set(SoState * state, QOpenGLWidget * window)
|
||||
{
|
||||
auto elem = static_cast<SoGLWidgetElement *>
|
||||
(SoElement::getElement(state, classStackIndex));
|
||||
elem->window = window;
|
||||
}
|
||||
|
||||
void SoGLWidgetElement::get(SoState * state, QtGLWidget *& window)
|
||||
void SoGLWidgetElement::get(SoState * state, QOpenGLWidget *& window)
|
||||
{
|
||||
const auto that = static_cast<const SoGLWidgetElement *>
|
||||
(SoElement::getConstElement(state, classStackIndex));
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <Inventor/nodes/SoNode.h>
|
||||
#include <Inventor/nodes/SoSubNode.h>
|
||||
|
||||
#include <QtOpenGL.h>
|
||||
#include <FCGlobal.h>
|
||||
|
||||
class QOpenGLWidget;
|
||||
|
||||
namespace Gui {
|
||||
/**
|
||||
@@ -73,14 +73,14 @@ public:
|
||||
SbBool matches(const SoElement * element) const override;
|
||||
SoElement * copyMatchInfo() const override;
|
||||
|
||||
static void set(SoState * state, QtGLWidget * window);
|
||||
static void get(SoState * state, QtGLWidget *& window);
|
||||
static void set(SoState * state, QOpenGLWidget * window);
|
||||
static void get(SoState * state, QOpenGLWidget *& window);
|
||||
|
||||
protected:
|
||||
~SoGLWidgetElement() override;
|
||||
|
||||
protected:
|
||||
QtGLWidget * window;
|
||||
QOpenGLWidget * window;
|
||||
};
|
||||
|
||||
class GuiExport SoGLRenderActionElement : public SoElement {
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
static void initClass();
|
||||
SoGLWidgetNode();
|
||||
|
||||
QtGLWidget * window{nullptr};
|
||||
QOpenGLWidget * window{nullptr};
|
||||
|
||||
void doAction(SoAction * action) override;
|
||||
void GLRender(SoGLRenderAction * action) override;
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
# include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOffscreenSurface>
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -563,9 +565,9 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples)
|
||||
|
||||
viewport.setWindowSize(width, height);
|
||||
|
||||
QtGLFramebufferObjectFormat fmt;
|
||||
QOpenGLFramebufferObjectFormat fmt;
|
||||
fmt.setSamples(samples);
|
||||
fmt.setAttachment(QtGLFramebufferObject::Depth);
|
||||
fmt.setAttachment(QOpenGLFramebufferObject::Depth);
|
||||
// With enabled alpha a transparent background is supported but
|
||||
// at the same time breaks semi-transparent models. A workaround
|
||||
// is to use a certain background color using GL_RGB as texture
|
||||
@@ -573,7 +575,7 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples)
|
||||
// replaces it with the color requested by the user.
|
||||
fmt.setInternalTextureFormat(this->texFormat);
|
||||
|
||||
framebuffer = new QtGLFramebufferObject(width, height, fmt);
|
||||
framebuffer = new QOpenGLFramebufferObject(width, height, fmt);
|
||||
cache_context = SoGLCacheContextElement::getUniqueCacheContext(); // unique per pixel buffer object, just to be sure
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,21 @@
|
||||
#include <Inventor/SbMatrix.h>
|
||||
#include <Inventor/SoOffscreenRenderer.h>
|
||||
|
||||
#ifdef FC_OS_MACOSX
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif // FC_OS_WIN32
|
||||
# include <GL/gl.h>
|
||||
#endif // FC_OS_MACOSX
|
||||
|
||||
#include <QImage>
|
||||
#include <QStringList>
|
||||
#include <QtOpenGL.h>
|
||||
|
||||
#include <FCGlobal.h>
|
||||
|
||||
class QOpenGLFramebufferObject;
|
||||
|
||||
namespace Gui {
|
||||
|
||||
@@ -136,7 +145,7 @@ private:
|
||||
SbBool renderFromBase(SoBase * base);
|
||||
void makeFrameBuffer(int width, int height, int samples);
|
||||
|
||||
QtGLFramebufferObject* framebuffer;
|
||||
QOpenGLFramebufferObject* framebuffer;
|
||||
uint32_t cache_context; // our unique context id
|
||||
|
||||
SbViewportRegion viewport;
|
||||
|
||||
+11
-3
@@ -58,8 +58,6 @@
|
||||
#include <Inventor/elements/SoGLTexture3EnabledElement.h>
|
||||
#endif
|
||||
|
||||
#include <QtOpenGL.h>
|
||||
|
||||
#include "SoTextLabel.h"
|
||||
#include "SoFCInteractiveElement.h"
|
||||
#include "Tools.h"
|
||||
@@ -307,7 +305,7 @@ SoStringLabel::SoStringLabel()
|
||||
*/
|
||||
void SoStringLabel::GLRender(SoGLRenderAction *action)
|
||||
{
|
||||
QtGLWidget* window;
|
||||
QOpenGLWidget* window;
|
||||
SoState * state = action->getState();
|
||||
state->push();
|
||||
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
|
||||
@@ -381,6 +379,7 @@ SoFrameLabel::SoFrameLabel()
|
||||
SO_NODE_ADD_FIELD(frame, (true));
|
||||
SO_NODE_ADD_FIELD(border, (true));
|
||||
SO_NODE_ADD_FIELD(backgroundUseBaseColor, (false));
|
||||
SO_NODE_ADD_FIELD(textUseBaseColor, (false));
|
||||
//SO_NODE_ADD_FIELD(image, (SbVec2s(0,0), 0, NULL));
|
||||
}
|
||||
|
||||
@@ -508,6 +507,15 @@ void SoFrameLabel::GLRender(SoGLRenderAction *action)
|
||||
}
|
||||
}
|
||||
|
||||
if (textUseBaseColor.getValue()) {
|
||||
SoState* state = action->getState();
|
||||
const SbColor& diffuse = SoLazyElement::getDiffuse(state, 0);
|
||||
|
||||
if (diffuse != this->textColor.getValue()) {
|
||||
this->textColor.setValue(diffuse);
|
||||
}
|
||||
}
|
||||
|
||||
inherited::GLRender(action);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user