Compare commits
6 Commits
a6a1539663
...
7d72f825ae
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d72f825ae | ||
|
|
148c046a02 | ||
|
|
bb24f13fba | ||
|
|
9d6301319b | ||
|
|
ea1aec04bd | ||
|
|
7f558f4f30 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
build/
|
build*/
|
||||||
.cache/
|
.cache/
|
||||||
|
CMakeUserPresets.json
|
||||||
build_warnings*.log
|
build_warnings*.log
|
||||||
final_build.log
|
final_build.log
|
||||||
cmake_configure.log
|
cmake_configure.log
|
||||||
|
|||||||
16
CLAUDE.md
16
CLAUDE.md
@@ -10,9 +10,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
export MAMBA_EXE="/home/share/micromamba/bin/micromamba"
|
export MAMBA_EXE="/home/share/micromamba/bin/micromamba"
|
||||||
export MAMBA_ROOT_PREFIX="/home/share/micromamba"
|
export MAMBA_ROOT_PREFIX="/home/share/micromamba"
|
||||||
eval "$(/home/share/micromamba/bin/micromamba shell hook --shell bash)"
|
eval "$(/home/share/micromamba/bin/micromamba shell hook --shell bash)"
|
||||||
micromamba activate mutom
|
micromamba activate uLib
|
||||||
|
|
||||||
# Configure (from repo root, using Conan preset)
|
# Configure (from repo root, using Conan preset — uses Ninja + ccache)
|
||||||
cmake --preset conan-release
|
cmake --preset conan-release
|
||||||
|
|
||||||
# Build everything
|
# Build everything
|
||||||
@@ -40,6 +40,18 @@ conan install . --output-folder=build --build=missing
|
|||||||
cmake --preset conan-release
|
cmake --preset conan-release
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Build acceleration (already configured)
|
||||||
|
- **Ninja** generator — used automatically via the conan default profile (`~/.conan2/profiles/default`)
|
||||||
|
- **ccache** — enabled via `CMAKE_CXX_COMPILER_LAUNCHER=ccache`; cached rebuilds are nearly instant (~0.3s vs ~25s cold)
|
||||||
|
- **Clang 22 + lld** profile available (`~/.conan2/profiles/fast`) but blocked by template overload ambiguities in `src/Core/Archives.h` that need fixing for full compatibility
|
||||||
|
|
||||||
|
To reconfigure with the fast profile once Archives.h is fixed:
|
||||||
|
```bash
|
||||||
|
conan install . --output-folder=build --build=missing --profile=fast
|
||||||
|
cmake -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build -j$(nproc)
|
||||||
|
```
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
**uLib** is a C++ framework for Cosmic Muon Tomography (CMT), structured as layered shared libraries:
|
**uLib** is a C++ framework for Cosmic Muon Tomography (CMT), structured as layered shared libraries:
|
||||||
|
|||||||
@@ -15,11 +15,20 @@ if(POLICY CMP0167)
|
|||||||
cmake_policy(SET CMP0167 NEW)
|
cmake_policy(SET CMP0167 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
## -------------------------------------------------------------------------- ##
|
## -------------------------------------------------------------------------- ##
|
||||||
|
|
||||||
project(uLib)
|
project(uLib)
|
||||||
|
|
||||||
|
# Remove GCC-only flag injected by conda's CFLAGS/CXXFLAGS that clang doesn't support.
|
||||||
|
# Must run after project() since that's when CMake initialises CMAKE_<LANG>_FLAGS from env.
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
foreach(_lang C CXX)
|
||||||
|
foreach(_var CMAKE_${_lang}_FLAGS CMAKE_${_lang}_FLAGS_RELEASE CMAKE_${_lang}_FLAGS_RELWITHDEBINFO CMAKE_${_lang}_FLAGS_DEBUG)
|
||||||
|
string(REPLACE "-fno-merge-constants" "" ${_var} "${${_var}}")
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
# CUDA Toolkit seems to be missing locally. Toggle ON if nvcc is made available.
|
# CUDA Toolkit seems to be missing locally. Toggle ON if nvcc is made available.
|
||||||
option(USE_CUDA "Enable CUDA support" OFF)
|
option(USE_CUDA "Enable CUDA support" OFF)
|
||||||
if(USE_CUDA)
|
if(USE_CUDA)
|
||||||
@@ -124,6 +133,8 @@ find_package(Eigen3 CONFIG REQUIRED)
|
|||||||
get_target_property(EIGEN3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
|
get_target_property(EIGEN3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
include_directories(${EIGEN3_INCLUDE_DIRS})
|
include_directories(${EIGEN3_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
find_package(OpenMP)
|
||||||
|
|
||||||
find_package(ROOT CONFIG REQUIRED)
|
find_package(ROOT CONFIG REQUIRED)
|
||||||
include(${ROOT_USE_FILE})
|
include(${ROOT_USE_FILE})
|
||||||
|
|
||||||
@@ -145,6 +156,8 @@ else()
|
|||||||
IOXML
|
IOXML
|
||||||
IOXMLParser
|
IOXMLParser
|
||||||
ImagingCore
|
ImagingCore
|
||||||
|
ImagingHybrid
|
||||||
|
ImagingSources
|
||||||
InteractionStyle
|
InteractionStyle
|
||||||
InteractionWidgets
|
InteractionWidgets
|
||||||
RenderingAnnotation
|
RenderingAnnotation
|
||||||
@@ -169,6 +182,26 @@ if(Geant4_FOUND)
|
|||||||
add_compile_definitions(HAVE_GEANT4)
|
add_compile_definitions(HAVE_GEANT4)
|
||||||
set(HAVE_GEANT4 1)
|
set(HAVE_GEANT4 1)
|
||||||
|
|
||||||
|
# Workaround: Geant4's G4EXPATShim creates EXPAT::EXPAT (uppercase) with
|
||||||
|
# IMPORTED_LOCATION "${EXPAT_LIBRARY}", but EXPAT_LIBRARY is empty when using
|
||||||
|
# conda's config-mode expat package (which installs as expat::expat lowercase).
|
||||||
|
# Resolve the actual library path from expat::expat or via find_library.
|
||||||
|
if(TARGET EXPAT::EXPAT)
|
||||||
|
get_target_property(_expat_loc EXPAT::EXPAT IMPORTED_LOCATION)
|
||||||
|
if(NOT _expat_loc OR _expat_loc MATCHES "NOTFOUND|^$")
|
||||||
|
if(TARGET expat::expat)
|
||||||
|
get_target_property(_expat_loc expat::expat IMPORTED_LOCATION_NOCONFIG)
|
||||||
|
endif()
|
||||||
|
if(NOT _expat_loc OR _expat_loc MATCHES "NOTFOUND|^$")
|
||||||
|
find_library(_expat_loc NAMES expat)
|
||||||
|
endif()
|
||||||
|
if(_expat_loc)
|
||||||
|
set_target_properties(EXPAT::EXPAT PROPERTIES IMPORTED_LOCATION "${_expat_loc}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
unset(_expat_loc)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Sanitize Geant4 targets to remove Qt5 dependencies that conflict with VTK/Qt6
|
# Sanitize Geant4 targets to remove Qt5 dependencies that conflict with VTK/Qt6
|
||||||
if(TARGET Geant4::G4interfaces)
|
if(TARGET Geant4::G4interfaces)
|
||||||
set_target_properties(Geant4::G4interfaces PROPERTIES
|
set_target_properties(Geant4::G4interfaces PROPERTIES
|
||||||
|
|||||||
@@ -12,6 +12,22 @@
|
|||||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "fast",
|
||||||
|
"displayName": "Fast build: Ninja + clang + ccache",
|
||||||
|
"description": "Uses Ninja generator, clang/lld compiler, and ccache",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release",
|
||||||
|
"CMAKE_C_COMPILER": "clang",
|
||||||
|
"CMAKE_CXX_COMPILER": "clang++",
|
||||||
|
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
|
||||||
|
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld",
|
||||||
|
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
|
||||||
|
"CMAKE_C_COMPILER_LAUNCHER": "ccache"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "mutom",
|
"name": "mutom",
|
||||||
"description": "",
|
"description": "",
|
||||||
@@ -19,4 +35,4 @@
|
|||||||
"inherits": []
|
"inherits": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"version": 4,
|
|
||||||
"vendor": {
|
|
||||||
"conan": {}
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"build/CMakePresets.json"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
54
README.md
54
README.md
@@ -30,18 +30,22 @@ You can create and activate the environment using either `micromamba` or `conda`
|
|||||||
**Using Micromamba:**
|
**Using Micromamba:**
|
||||||
```bash
|
```bash
|
||||||
micromamba env create -f condaenv.yml
|
micromamba env create -f condaenv.yml
|
||||||
micromamba activate mutom
|
micromamba activate uLib
|
||||||
```
|
```
|
||||||
|
|
||||||
**Using Conda:**
|
**Using Conda:**
|
||||||
```bash
|
```bash
|
||||||
conda env create -f condaenv.yml
|
conda env create -f condaenv.yml
|
||||||
conda activate mutom
|
conda activate uLib
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure and Build
|
### Configure and Build
|
||||||
|
|
||||||
1. **Configure Conan profile (if you haven't yet on your machine):**
|
#### Standard build (GCC + Ninja + ccache)
|
||||||
|
|
||||||
|
The default conan profile uses **Ninja** as the generator and **ccache** for compiler caching, dramatically speeding up incremental rebuilds.
|
||||||
|
|
||||||
|
1. **Configure Conan profile (first time only):**
|
||||||
```bash
|
```bash
|
||||||
conan profile detect
|
conan profile detect
|
||||||
```
|
```
|
||||||
@@ -51,20 +55,54 @@ conan profile detect
|
|||||||
conan install . --output-folder=build --build=missing
|
conan install . --output-folder=build --build=missing
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Configure the project with CMake:**
|
3. **Configure with CMake:**
|
||||||
```bash
|
```bash
|
||||||
cmake --preset conan-release
|
cmake --preset conan-release
|
||||||
```
|
```
|
||||||
*(Alternatively: `cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release`)*
|
|
||||||
|
|
||||||
4. **Build the project:**
|
4. **Build:**
|
||||||
```bash
|
```bash
|
||||||
cmake --build build -j10
|
cmake --build build -j$(nproc)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
5. **Clean build (wipe and rebuild everything):**
|
||||||
|
```bash
|
||||||
|
cmake --build build --clean-first -j$(nproc)
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Run tests:**
|
||||||
|
```bash
|
||||||
|
cmake --build build --target test -j$(nproc)
|
||||||
|
# or equivalently:
|
||||||
|
ctest --test-dir build --output-on-failure -j$(nproc)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### LLVM/Clang build (clang + lld + ccache — fastest)
|
||||||
|
|
||||||
|
A `fast` conan profile is provided that uses **clang**, **lld** (LLVM linker), and **ccache**. Install them into your environment first:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
micromamba install -n uLib -y clang clangxx lld -c conda-forge
|
||||||
|
```
|
||||||
|
|
||||||
|
Then build using the `fast` profile:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conan install . --output-folder=build --build=missing --profile=fast
|
||||||
|
cmake -B build -G Ninja \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build -j$(nproc)
|
||||||
|
```
|
||||||
|
|
||||||
|
The `fast` profile is defined at `~/.conan2/profiles/fast` and sets:
|
||||||
|
- `CMAKE_C_COMPILER=clang` / `CMAKE_CXX_COMPILER=clang++`
|
||||||
|
- `CMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld`
|
||||||
|
- `CMAKE_CXX_COMPILER_LAUNCHER=ccache`
|
||||||
|
|
||||||
### Make python package
|
### Make python package
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
micromamba run -n mutom env USE_CUDA=ON poetry install
|
micromamba run -n uLib env USE_CUDA=ON poetry install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[requires]
|
[requires]
|
||||||
eigen/3.4.0
|
eigen/3.4.0
|
||||||
boost/1.83.0
|
boost/1.86.0
|
||||||
# pybind11/3.0.2
|
# pybind11/3.0.2
|
||||||
hdf5/1.14.3
|
hdf5/1.14.3
|
||||||
|
|
||||||
|
|||||||
13
condaenv.yml
13
condaenv.yml
@@ -1,4 +1,4 @@
|
|||||||
name: mutom
|
name: uLib
|
||||||
channels:
|
channels:
|
||||||
- conda-forge
|
- conda-forge
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -7,4 +7,13 @@ dependencies:
|
|||||||
- cmake
|
- cmake
|
||||||
- conan
|
- conan
|
||||||
- root
|
- root
|
||||||
- vtk
|
- vtk=9.4 # VTK 9.4
|
||||||
|
- pybind11
|
||||||
|
# - boost=1.86.0 # requested by VTK 9.4
|
||||||
|
- ninja
|
||||||
|
- clang
|
||||||
|
- clangxx
|
||||||
|
- lld
|
||||||
|
- ccache
|
||||||
|
- OpenMP
|
||||||
|
- Geant4
|
||||||
|
|||||||
@@ -424,8 +424,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using basic_xml_iarchive::load_override;
|
|
||||||
|
|
||||||
// Anything not an attribute should be a name value pair as nvp or hrp
|
// Anything not an attribute should be a name value pair as nvp or hrp
|
||||||
typedef boost::archive::detail::common_iarchive<Archive>
|
typedef boost::archive::detail::common_iarchive<Archive>
|
||||||
detail_common_iarchive;
|
detail_common_iarchive;
|
||||||
@@ -443,6 +441,9 @@ public:
|
|||||||
// class_name_type can't be handled here as it depends upon the
|
// class_name_type can't be handled here as it depends upon the
|
||||||
// char type used by the stream. So require the derived implementation.
|
// char type used by the stream. So require the derived implementation.
|
||||||
// derived in this case is xml_iarchive_impl or base ..
|
// derived in this case is xml_iarchive_impl or base ..
|
||||||
|
// Note: using base::load_override covers all basic_xml_iarchive overloads
|
||||||
|
// transitively, so a separate 'using basic_xml_iarchive::load_override'
|
||||||
|
// is redundant and creates ambiguity with clang.
|
||||||
using base::load_override;
|
using base::load_override;
|
||||||
|
|
||||||
void load_override(const char *str) {
|
void load_override(const char *str) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ namespace uLib {
|
|||||||
|
|
||||||
namespace Archive {
|
namespace Archive {
|
||||||
class property_register_archive;
|
class property_register_archive;
|
||||||
class display_properties_archive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +67,6 @@ public:
|
|||||||
virtual void serialize(Archive::log_archive & ar, const unsigned int version) override = 0;
|
virtual void serialize(Archive::log_archive & ar, const unsigned int version) override = 0;
|
||||||
|
|
||||||
virtual void serialize(Archive::property_register_archive & ar, const unsigned int v) = 0;
|
virtual void serialize(Archive::property_register_archive & ar, const unsigned int v) = 0;
|
||||||
virtual void serialize(Archive::display_properties_archive & ar, const unsigned int v) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,7 +107,9 @@ public:
|
|||||||
const T& Get() const { return *m_value; }
|
const T& Get() const { return *m_value; }
|
||||||
void Set(const T& value) {
|
void Set(const T& value) {
|
||||||
T val = value;
|
T val = value;
|
||||||
if (m_HasRange) { if (val < m_Min) val = m_Min; if (val > m_Max) val = m_Max; }
|
if constexpr (std::is_arithmetic<T>::value) {
|
||||||
|
if (m_HasRange) { if (val < m_Min) val = m_Min; if (val > m_Max) val = m_Max; }
|
||||||
|
}
|
||||||
if (*m_value != val) {
|
if (*m_value != val) {
|
||||||
*m_value = val;
|
*m_value = val;
|
||||||
ULIB_SIGNAL_EMIT(Property<T>::PropertyChanged);
|
ULIB_SIGNAL_EMIT(Property<T>::PropertyChanged);
|
||||||
@@ -168,7 +168,6 @@ public:
|
|||||||
virtual void serialize(Archive::log_archive & ar, const unsigned int v) override { serialize_helper(ar, v); }
|
virtual void serialize(Archive::log_archive & ar, const unsigned int v) override { serialize_helper(ar, v); }
|
||||||
|
|
||||||
virtual void serialize(Archive::property_register_archive & ar, const unsigned int v) override;
|
virtual void serialize(Archive::property_register_archive & ar, const unsigned int v) override;
|
||||||
virtual void serialize(Archive::display_properties_archive & ar, const unsigned int v) override;
|
|
||||||
|
|
||||||
virtual void Updated() override { PropertyBase::Updated(); this->PropertyChanged(); }
|
virtual void Updated() override { PropertyBase::Updated(); this->PropertyChanged(); }
|
||||||
|
|
||||||
@@ -213,7 +212,6 @@ public:
|
|||||||
virtual void serialize(Archive::log_archive & ar, const unsigned int v) override { serialize_enum_helper(ar, v); }
|
virtual void serialize(Archive::log_archive & ar, const unsigned int v) override { serialize_enum_helper(ar, v); }
|
||||||
|
|
||||||
virtual void serialize(Archive::property_register_archive & ar, const unsigned int v) override;
|
virtual void serialize(Archive::property_register_archive & ar, const unsigned int v) override;
|
||||||
virtual void serialize(Archive::display_properties_archive & ar, const unsigned int v) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_Labels;
|
std::vector<std::string> m_Labels;
|
||||||
@@ -352,12 +350,6 @@ protected:
|
|||||||
std::set<const void*> m_Visited;
|
std::set<const void*> m_Visited;
|
||||||
};
|
};
|
||||||
|
|
||||||
class display_properties_archive : public property_register_archive {
|
|
||||||
public:
|
|
||||||
friend class boost::archive::detail::interface_oarchive<display_properties_archive>;
|
|
||||||
display_properties_archive(Object* obj) : property_register_archive(obj, true) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Archive
|
} // namespace Archive
|
||||||
} // namespace uLib
|
} // namespace uLib
|
||||||
|
|
||||||
@@ -368,19 +360,10 @@ inline void Property<T>::serialize(Archive::property_register_archive & ar, cons
|
|||||||
ar.register_property(*this);
|
ar.register_property(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline void Property<T>::serialize(Archive::display_properties_archive & ar, const unsigned int v) {
|
|
||||||
ar.register_property(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void EnumProperty::serialize(Archive::property_register_archive & ar, const unsigned int v) {
|
inline void EnumProperty::serialize(Archive::property_register_archive & ar, const unsigned int v) {
|
||||||
ar.register_enum_property(*this);
|
ar.register_enum_property(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void EnumProperty::serialize(Archive::display_properties_archive & ar, const unsigned int v) {
|
|
||||||
ar.register_enum_property(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Archive {
|
namespace Archive {
|
||||||
|
|
||||||
#define ULIB_ACTIVATE_PROPERTIES(obj) \
|
#define ULIB_ACTIVATE_PROPERTIES(obj) \
|
||||||
@@ -397,6 +380,19 @@ private: \
|
|||||||
|
|
||||||
} // namespace Archive
|
} // namespace Archive
|
||||||
|
|
||||||
|
// Convenience macro: declares a named Property<T> member with a default value.
|
||||||
|
// Usage inside a class body (requires 'this' to be available, so use in-class initializer):
|
||||||
|
// ULIB_PROPERTY(int, MyProp, 42)
|
||||||
|
#define ULIB_PROPERTY(type, name, defaultVal) \
|
||||||
|
::uLib::Property<type> name{this, #name, (type)(defaultVal)};
|
||||||
|
|
||||||
|
// Common property type aliases
|
||||||
|
typedef Property<bool> BoolProperty;
|
||||||
|
typedef Property<int> IntProperty;
|
||||||
|
typedef Property<float> FloatProperty;
|
||||||
|
typedef Property<double> DoubleProperty;
|
||||||
|
typedef Property<std::string> StringProperty;
|
||||||
|
|
||||||
template <class ArchiveT>
|
template <class ArchiveT>
|
||||||
void serialize_properties_helper(ArchiveT &ar, const std::vector<PropertyBase*> &props, unsigned int version) {
|
void serialize_properties_helper(ArchiveT &ar, const std::vector<PropertyBase*> &props, unsigned int version) {
|
||||||
for (auto* prop : props) prop->serialize(ar, version);
|
for (auto* prop : props) prop->serialize(ar, version);
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ typedef bool Bool_t; // Boolean (0=false, 1=true) (bool)
|
|||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
typedef type_info::BaseClass BaseClass; \
|
typedef type_info::BaseClass BaseClass; \
|
||||||
virtual const char *type_name() const { return type_info::name; } \
|
virtual const char *type_name() const override { return type_info::name; } \
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ inline const unsigned long VectorSplice(const _Tp &_it, const _Tp &_end,
|
|||||||
|
|
||||||
_Tp it = _it;
|
_Tp it = _it;
|
||||||
_Tp end = _end - 1;
|
_Tp end = _end - 1;
|
||||||
for (it; it != end;) {
|
for (; it != end;) {
|
||||||
if (_comp(*it, value))
|
if (_comp(*it, value))
|
||||||
it++;
|
it++;
|
||||||
else if (_comp(*end, value)) {
|
else if (_comp(*end, value)) {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class EmitterPrimary : public G4VUserPrimaryGeneratorAction, public AffineTransf
|
|||||||
virtual ~EmitterPrimary();
|
virtual ~EmitterPrimary();
|
||||||
|
|
||||||
// Metodo principale chiamato all'inizio di ogni evento
|
// Metodo principale chiamato all'inizio di ogni evento
|
||||||
virtual void GeneratePrimaries(G4Event*);
|
virtual void GeneratePrimaries(G4Event*) override;
|
||||||
|
|
||||||
virtual void Updated() override { ULIB_SIGNAL_EMIT(EmitterPrimary::Updated); }
|
virtual void Updated() override { ULIB_SIGNAL_EMIT(EmitterPrimary::Updated); }
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class SkyPlaneEmitterPrimary : public EmitterPrimary
|
|||||||
SkyPlaneEmitterPrimary();
|
SkyPlaneEmitterPrimary();
|
||||||
virtual ~SkyPlaneEmitterPrimary();
|
virtual ~SkyPlaneEmitterPrimary();
|
||||||
|
|
||||||
virtual void GeneratePrimaries(G4Event*);
|
virtual void GeneratePrimaries(G4Event*) override;
|
||||||
|
|
||||||
void SetPlane(const uLib::Vector3f& p0, const uLib::Vector3f& normal);
|
void SetPlane(const uLib::Vector3f& p0, const uLib::Vector3f& normal);
|
||||||
void SetSkySize(const uLib::Vector2f& size);
|
void SetSkySize(const uLib::Vector2f& size);
|
||||||
@@ -72,7 +72,7 @@ class CylinderEmitterPrimary : public EmitterPrimary
|
|||||||
CylinderEmitterPrimary();
|
CylinderEmitterPrimary();
|
||||||
virtual ~CylinderEmitterPrimary();
|
virtual ~CylinderEmitterPrimary();
|
||||||
|
|
||||||
virtual void GeneratePrimaries(G4Event*);
|
virtual void GeneratePrimaries(G4Event*) override;
|
||||||
|
|
||||||
void SetRadius(float r);
|
void SetRadius(float r);
|
||||||
float GetRadius() const { return m_Radius; }
|
float GetRadius() const { return m_Radius; }
|
||||||
@@ -101,7 +101,7 @@ class QuadMeshEmitterPrimary : public EmitterPrimary
|
|||||||
virtual ~QuadMeshEmitterPrimary();
|
virtual ~QuadMeshEmitterPrimary();
|
||||||
|
|
||||||
// Metodo principale chiamato all'inizio di ogni evento
|
// Metodo principale chiamato all'inizio di ogni evento
|
||||||
virtual void GeneratePrimaries(G4Event*);
|
virtual void GeneratePrimaries(G4Event*) override;
|
||||||
|
|
||||||
void SetMesh(uLib::QuadMesh* mesh);
|
void SetMesh(uLib::QuadMesh* mesh);
|
||||||
|
|
||||||
|
|||||||
@@ -13,41 +13,41 @@ namespace uLib {
|
|||||||
using namespace CLHEP;
|
using namespace CLHEP;
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
constexpr double operator"" _m(long double v) { return static_cast<double>(v) * CLHEP::meter; }
|
constexpr double operator""_m(long double v) { return static_cast<double>(v) * CLHEP::meter; }
|
||||||
constexpr double operator"" _cm(long double v) { return static_cast<double>(v) * CLHEP::centimeter; }
|
constexpr double operator""_cm(long double v) { return static_cast<double>(v) * CLHEP::centimeter; }
|
||||||
constexpr double operator"" _mm(long double v) { return static_cast<double>(v) * CLHEP::millimeter; }
|
constexpr double operator""_mm(long double v) { return static_cast<double>(v) * CLHEP::millimeter; }
|
||||||
constexpr double operator"" _um(long double v) { return static_cast<double>(v) * CLHEP::micrometer; }
|
constexpr double operator""_um(long double v) { return static_cast<double>(v) * CLHEP::micrometer; }
|
||||||
constexpr double operator"" _nm(long double v) { return static_cast<double>(v) * CLHEP::nanometer; }
|
constexpr double operator""_nm(long double v) { return static_cast<double>(v) * CLHEP::nanometer; }
|
||||||
constexpr double operator"" _km(long double v) { return static_cast<double>(v) * CLHEP::kilometer; }
|
constexpr double operator""_km(long double v) { return static_cast<double>(v) * CLHEP::kilometer; }
|
||||||
|
|
||||||
constexpr double operator"" _m(unsigned long long v) { return static_cast<double>(v) * CLHEP::meter; }
|
constexpr double operator""_m(unsigned long long v) { return static_cast<double>(v) * CLHEP::meter; }
|
||||||
constexpr double operator"" _cm(unsigned long long v) { return static_cast<double>(v) * CLHEP::centimeter; }
|
constexpr double operator""_cm(unsigned long long v) { return static_cast<double>(v) * CLHEP::centimeter; }
|
||||||
constexpr double operator"" _mm(unsigned long long v) { return static_cast<double>(v) * CLHEP::millimeter; }
|
constexpr double operator""_mm(unsigned long long v) { return static_cast<double>(v) * CLHEP::millimeter; }
|
||||||
constexpr double operator"" _um(unsigned long long v) { return static_cast<double>(v) * CLHEP::micrometer; }
|
constexpr double operator""_um(unsigned long long v) { return static_cast<double>(v) * CLHEP::micrometer; }
|
||||||
constexpr double operator"" _nm(unsigned long long v) { return static_cast<double>(v) * CLHEP::nanometer; }
|
constexpr double operator""_nm(unsigned long long v) { return static_cast<double>(v) * CLHEP::nanometer; }
|
||||||
constexpr double operator"" _km(unsigned long long v) { return static_cast<double>(v) * CLHEP::kilometer; }
|
constexpr double operator""_km(unsigned long long v) { return static_cast<double>(v) * CLHEP::kilometer; }
|
||||||
|
|
||||||
constexpr double operator"" _deg(long double v) { return static_cast<double>(v) * CLHEP::degree; }
|
constexpr double operator""_deg(long double v) { return static_cast<double>(v) * CLHEP::degree; }
|
||||||
constexpr double operator"" _rad(long double v) { return static_cast<double>(v) * CLHEP::radian; }
|
constexpr double operator""_rad(long double v) { return static_cast<double>(v) * CLHEP::radian; }
|
||||||
constexpr double operator"" _deg(unsigned long long v) { return static_cast<double>(v) * CLHEP::degree; }
|
constexpr double operator""_deg(unsigned long long v) { return static_cast<double>(v) * CLHEP::degree; }
|
||||||
constexpr double operator"" _rad(unsigned long long v) { return static_cast<double>(v) * CLHEP::radian; }
|
constexpr double operator""_rad(unsigned long long v) { return static_cast<double>(v) * CLHEP::radian; }
|
||||||
|
|
||||||
constexpr double operator"" _ns(long double v) { return static_cast<double>(v) * CLHEP::nanosecond; }
|
constexpr double operator""_ns(long double v) { return static_cast<double>(v) * CLHEP::nanosecond; }
|
||||||
constexpr double operator"" _s(long double v) { return static_cast<double>(v) * CLHEP::second; }
|
constexpr double operator""_s(long double v) { return static_cast<double>(v) * CLHEP::second; }
|
||||||
constexpr double operator"" _ms(long double v) { return static_cast<double>(v) * CLHEP::millisecond; }
|
constexpr double operator""_ms(long double v) { return static_cast<double>(v) * CLHEP::millisecond; }
|
||||||
constexpr double operator"" _ns(unsigned long long v) { return static_cast<double>(v) * CLHEP::nanosecond; }
|
constexpr double operator""_ns(unsigned long long v) { return static_cast<double>(v) * CLHEP::nanosecond; }
|
||||||
constexpr double operator"" _s(unsigned long long v) { return static_cast<double>(v) * CLHEP::second; }
|
constexpr double operator""_s(unsigned long long v) { return static_cast<double>(v) * CLHEP::second; }
|
||||||
constexpr double operator"" _ms(unsigned long long v) { return static_cast<double>(v) * CLHEP::millisecond; }
|
constexpr double operator""_ms(unsigned long long v) { return static_cast<double>(v) * CLHEP::millisecond; }
|
||||||
|
|
||||||
constexpr double operator"" _MeV(long double v) { return static_cast<double>(v) * CLHEP::megaelectronvolt; }
|
constexpr double operator""_MeV(long double v) { return static_cast<double>(v) * CLHEP::megaelectronvolt; }
|
||||||
constexpr double operator"" _eV(long double v) { return static_cast<double>(v) * CLHEP::electronvolt; }
|
constexpr double operator""_eV(long double v) { return static_cast<double>(v) * CLHEP::electronvolt; }
|
||||||
constexpr double operator"" _keV(long double v) { return static_cast<double>(v) * CLHEP::kiloelectronvolt; }
|
constexpr double operator""_keV(long double v) { return static_cast<double>(v) * CLHEP::kiloelectronvolt; }
|
||||||
constexpr double operator"" _GeV(long double v) { return static_cast<double>(v) * CLHEP::gigaelectronvolt; }
|
constexpr double operator""_GeV(long double v) { return static_cast<double>(v) * CLHEP::gigaelectronvolt; }
|
||||||
constexpr double operator"" _TeV(long double v) { return static_cast<double>(v) * CLHEP::teraelectronvolt; }
|
constexpr double operator""_TeV(long double v) { return static_cast<double>(v) * CLHEP::teraelectronvolt; }
|
||||||
constexpr double operator"" _MeV(unsigned long long v) { return static_cast<double>(v) * CLHEP::megaelectronvolt; }
|
constexpr double operator""_MeV(unsigned long long v) { return static_cast<double>(v) * CLHEP::megaelectronvolt; }
|
||||||
constexpr double operator"" _eV(unsigned long long v) { return static_cast<double>(v) * CLHEP::electronvolt; }
|
constexpr double operator""_eV(unsigned long long v) { return static_cast<double>(v) * CLHEP::electronvolt; }
|
||||||
constexpr double operator"" _keV(unsigned long long v) { return static_cast<double>(v) * CLHEP::kiloelectronvolt; }
|
constexpr double operator""_keV(unsigned long long v) { return static_cast<double>(v) * CLHEP::kiloelectronvolt; }
|
||||||
constexpr double operator"" _GeV(unsigned long long v) { return static_cast<double>(v) * CLHEP::gigaelectronvolt; }
|
constexpr double operator""_GeV(unsigned long long v) { return static_cast<double>(v) * CLHEP::gigaelectronvolt; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ list(APPEND HEADERS ${HEP_GEANT_HEADERS})
|
|||||||
set(LIBRARIES Eigen3::Eigen
|
set(LIBRARIES Eigen3::Eigen
|
||||||
${ROOT_LIBRARIES}
|
${ROOT_LIBRARIES}
|
||||||
${VTK_LIBRARIES}
|
${VTK_LIBRARIES}
|
||||||
|
VTK::ImagingHybrid
|
||||||
|
VTK::ImagingSources
|
||||||
${PACKAGE_LIBPREFIX}Math
|
${PACKAGE_LIBPREFIX}Math
|
||||||
${PACKAGE_LIBPREFIX}Detectors
|
${PACKAGE_LIBPREFIX}Detectors
|
||||||
${PACKAGE_LIBPREFIX}Geant)
|
${PACKAGE_LIBPREFIX}Geant)
|
||||||
@@ -56,7 +58,7 @@ set_target_properties(${libname} PROPERTIES
|
|||||||
AUTOMOC ON
|
AUTOMOC ON
|
||||||
AUTOUIC ON
|
AUTOUIC ON
|
||||||
AUTORCC ON)
|
AUTORCC ON)
|
||||||
target_link_libraries(${libname} ${LIBRARIES} Qt6::Widgets)
|
target_link_libraries(${libname} PUBLIC ${LIBRARIES} Qt6::Widgets)
|
||||||
|
|
||||||
install(TARGETS ${libname}
|
install(TARGETS ${libname}
|
||||||
EXPORT "uLibTargets"
|
EXPORT "uLibTargets"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
virtual class vtkPolyData *GetPolyData() const override;
|
virtual class vtkPolyData *GetPolyData() const override;
|
||||||
|
|
||||||
virtual void Update();
|
virtual void Update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void InstallPipe();
|
virtual void InstallPipe();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
vtkContainerBox(Content *content);
|
vtkContainerBox(Content *content);
|
||||||
~vtkContainerBox();
|
~vtkContainerBox();
|
||||||
|
|
||||||
virtual class vtkPolyData *GetPolyData() const;
|
virtual class vtkPolyData *GetPolyData() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Updates the VTK representation from the internal state.
|
* @brief Updates the VTK representation from the internal state.
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public:
|
|||||||
vtkPolyData* polydata = nullptr;
|
vtkPolyData* polydata = nullptr;
|
||||||
if (vtkActor *actor = vtkActor::SafeDownCast(m_Prop)) {
|
if (vtkActor *actor = vtkActor::SafeDownCast(m_Prop)) {
|
||||||
if (actor->GetMapper()) {
|
if (actor->GetMapper()) {
|
||||||
polydata = vtkPolyData::SafeDownCast(actor->GetMapper()->GetDataSetInput());
|
polydata = vtkPolyData::SafeDownCast(actor->GetMapper()->GetInput());
|
||||||
}
|
}
|
||||||
} else if (vtkAssembly *asm_p = vtkAssembly::SafeDownCast(m_Prop)) {
|
} else if (vtkAssembly *asm_p = vtkAssembly::SafeDownCast(m_Prop)) {
|
||||||
vtkPropCollection *parts = asm_p->GetParts();
|
vtkPropCollection *parts = asm_p->GetParts();
|
||||||
@@ -192,7 +192,7 @@ public:
|
|||||||
for (int i = 0; i < parts->GetNumberOfItems(); ++i) {
|
for (int i = 0; i < parts->GetNumberOfItems(); ++i) {
|
||||||
vtkActor *a = vtkActor::SafeDownCast(parts->GetNextProp());
|
vtkActor *a = vtkActor::SafeDownCast(parts->GetNextProp());
|
||||||
if (a && a->GetMapper()) {
|
if (a && a->GetMapper()) {
|
||||||
polydata = vtkPolyData::SafeDownCast(a->GetMapper()->GetDataSetInput());
|
polydata = vtkPolyData::SafeDownCast(a->GetMapper()->GetInput());
|
||||||
if (polydata) break;
|
if (polydata) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,10 +129,10 @@ uLibTypeMacro(Puppet, uLib::Object)
|
|||||||
|
|
||||||
vtkRendererCollection *GetRenderers() const;
|
vtkRendererCollection *GetRenderers() const;
|
||||||
|
|
||||||
const std::vector<uLib::PropertyBase *> &GetDisplayProperties() const {
|
const std::vector<uLib::PropertyBase *> &GetDisplayProperties() const override {
|
||||||
return m_DisplayProperties;
|
return m_DisplayProperties;
|
||||||
}
|
}
|
||||||
void RegisterDisplayProperty(uLib::PropertyBase *prop) {
|
void RegisterDisplayProperty(uLib::PropertyBase *prop) override {
|
||||||
m_DisplayProperties.push_back(prop);
|
m_DisplayProperties.push_back(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +284,21 @@ public:
|
|||||||
void save_override(const boost::archive::class_name_type &t) {}
|
void save_override(const boost::archive::class_name_type &t) {}
|
||||||
void save_override(const boost::archive::tracking_type &t) {}
|
void save_override(const boost::archive::tracking_type &t) {}
|
||||||
|
|
||||||
|
// Called by Property<T>::serialize() and EnumProperty::serialize() to
|
||||||
|
// directly register an existing property object as a display property.
|
||||||
|
void register_property(uLib::PropertyBase &p) {
|
||||||
|
if (m_Puppet) {
|
||||||
|
m_Puppet->RegisterDisplayProperty(&p);
|
||||||
|
Vtk::Puppet *puppet = m_Puppet;
|
||||||
|
uLib::Object::connect(&p, &uLib::PropertyBase::Updated,
|
||||||
|
[puppet]() { puppet->Update(); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void register_enum_property(uLib::EnumProperty &p) {
|
||||||
|
register_property(p);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vtk::Puppet *m_Puppet;
|
Vtk::Puppet *m_Puppet;
|
||||||
std::vector<std::string> m_GroupStack;
|
std::vector<std::string> m_GroupStack;
|
||||||
|
|||||||
Reference in New Issue
Block a user