Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Make ViewConfig usable with designated initializers #3613

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Core/include/Acts/Visualization/EventDataView3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
namespace Acts {
class IVisualization3D;

static ViewConfig s_viewParameter = ViewConfig({0, 0, 255});
static ViewConfig s_viewMeasurement = ViewConfig({255, 102, 0});
static ViewConfig s_viewPredicted = ViewConfig({51, 204, 51});
static ViewConfig s_viewFiltered = ViewConfig({255, 255, 0});
static ViewConfig s_viewSmoothed = ViewConfig({0, 102, 255});
static ViewConfig s_viewParameter = {.color = {0, 0, 255}};
static ViewConfig s_viewMeasurement = {.color = {255, 102, 0}};
static ViewConfig s_viewPredicted = {.color = {51, 204, 51}};
static ViewConfig s_viewFiltered = {.color = {255, 255, 0}};
static ViewConfig s_viewSmoothed = {.color = {0, 102, 25}};

struct EventDataView3D {
/// Helper to find the eigen values and corr angle
Expand Down Expand Up @@ -277,7 +277,7 @@ struct EventDataView3D {
state.predicted(), state.predictedCovariance(),
particleHypothesis),
gctx, momentumScale, locErrorScale, angularErrorScale,
predictedConfig, predictedConfig, ViewConfig(false));
predictedConfig, predictedConfig, {.visible = false});
}
// (b) filtered track parameters
if (filteredConfig.visible && state.hasFiltered()) {
Expand All @@ -287,7 +287,7 @@ struct EventDataView3D {
state.filtered(), state.filteredCovariance(),
particleHypothesis),
gctx, momentumScale, locErrorScale, angularErrorScale,
filteredConfig, filteredConfig, ViewConfig(false));
filteredConfig, filteredConfig, {.visible = false});
}
// (c) smoothed track parameters
if (smoothedConfig.visible && state.hasSmoothed()) {
Expand All @@ -297,7 +297,7 @@ struct EventDataView3D {
state.smoothed(), state.smoothedCovariance(),
particleHypothesis),
gctx, momentumScale, locErrorScale, angularErrorScale,
smoothedConfig, smoothedConfig, ViewConfig(false));
smoothedConfig, smoothedConfig, {.visible = false});
}
return true;
});
Expand Down
10 changes: 5 additions & 5 deletions Core/include/Acts/Visualization/GeometryView3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ struct GeometryView3D {
const Experimental::Portal& portal,
const GeometryContext& gctx,
const Transform3& transform = Transform3::Identity(),
const ViewConfig& connected = ViewConfig({0, 255, 0}),
const ViewConfig& disconnected = ViewConfig({255, 0,
0}));
const ViewConfig& connected = {.color = {0, 255, 0}},
const ViewConfig& disconnected = {
.color = {255, 0, 0}});

/// Helper method to draw DetectorVolume objects
///
Expand All @@ -120,8 +120,8 @@ struct GeometryView3D {
const Acts::Experimental::DetectorVolume& volume,
const GeometryContext& gctx,
const Transform3& transform = Transform3::Identity(),
const ViewConfig& connected = ViewConfig({0, 255, 0}),
const ViewConfig& unconnected = ViewConfig({255, 0, 0}),
const ViewConfig& connected = {.color = {0, 255, 0}},
const ViewConfig& unconnected = {.color = {255, 0, 0}},
const ViewConfig& viewConfig = s_viewSensitive);

/// Helper method to draw Layer objects
Expand Down
6 changes: 0 additions & 6 deletions Core/include/Acts/Visualization/ViewConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ using ColorRGB = std::array<int, 3>;
/// @brief Struct to concentrate all visualization configurations
/// in order to harmonize visualization interfaces
struct ViewConfig {
/// Constructor to switch visibility off
ViewConfig(bool vis = true) : visible(vis) {}

/// Constructor for color settings only
ViewConfig(const ColorRGB& rgb) : color(rgb) {}

/// Visible flag
bool visible = true;
/// The RGB color for this object
Expand Down
10 changes: 5 additions & 5 deletions Core/src/Visualization/GeometryView3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
#include <vector>

namespace Acts::Experimental {
ViewConfig s_viewSensitive = ViewConfig({0, 180, 240});
ViewConfig s_viewPassive = ViewConfig({240, 280, 0});
ViewConfig s_viewVolume = ViewConfig({220, 220, 0});
ViewConfig s_viewGrid = ViewConfig({220, 0, 0});
ViewConfig s_viewLine = ViewConfig({0, 0, 220});
ViewConfig s_viewSensitive = {.color = {0, 180, 240}};
ViewConfig s_viewPassive = {.color = {240, 280, 0}};
ViewConfig s_viewVolume = {.color = {220, 220, 0}};
ViewConfig s_viewGrid = {.color = {220, 0, 0}};
ViewConfig s_viewLine = {.color = {0, 0, 220}};
} // namespace Acts::Experimental

void Acts::GeometryView3D::drawPolyhedron(IVisualization3D& helper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class ObjTrackingGeometryWriter {
std::size_t outputPrecision = 6; ///< floating point precision
std::string outputDir = ".";

Acts::ViewConfig containerView = Acts::ViewConfig({220, 220, 220});
Acts::ViewConfig volumeView = Acts::ViewConfig({220, 220, 0});
Acts::ViewConfig sensitiveView = Acts::ViewConfig({0, 180, 240});
Acts::ViewConfig passiveView = Acts::ViewConfig({240, 280, 0});
Acts::ViewConfig gridView = Acts::ViewConfig({220, 0, 0});
Acts::ViewConfig containerView = {.color = {220, 220, 220}};
Acts::ViewConfig volumeView = {.color = {220, 220, 0}};
Acts::ViewConfig sensitiveView = {.color = {0, 180, 240}};
Acts::ViewConfig passiveView = {.color = {240, 280, 0}};
Acts::ViewConfig gridView = {.color = {220, 0, 0}};
};

/// Constructor
Expand Down
6 changes: 3 additions & 3 deletions Examples/Python/src/Obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void addObj(Context& ctx) {
const GeometryContext& viewContext,
const std::array<int, 3>& viewRgb, unsigned int viewSegements,
const std::string& fileName) {
Acts::ViewConfig sConfig = Acts::ViewConfig{viewRgb};
Acts::ViewConfig sConfig = Acts::ViewConfig{.color = viewRgb};
sConfig.nSegments = viewSegements;
Acts::GeometryView3D view3D;
Acts::ObjVisualization3D obj;
Expand All @@ -60,7 +60,7 @@ void addObj(Context& ctx) {
const GeometryContext& viewContext,
const std::array<int, 3>& viewRgb, unsigned int viewSegements,
const std::string& fileName) {
Acts::ViewConfig sConfig = Acts::ViewConfig{viewRgb};
Acts::ViewConfig sConfig = Acts::ViewConfig{.color = viewRgb};
sConfig.nSegments = viewSegements;
Acts::GeometryView3D view3D;
Acts::ObjVisualization3D obj;
Expand All @@ -79,7 +79,7 @@ void addObj(Context& ctx) {
const GeometryContext& viewContext,
const std::array<int, 3>& viewRgb, unsigned int viewSegements,
const std::string& fileName) {
Acts::ViewConfig sConfig = Acts::ViewConfig{viewRgb};
Acts::ViewConfig sConfig = Acts::ViewConfig{.color = viewRgb};
sConfig.nSegments = viewSegements;
Acts::GeometryView3D view3D;
Acts::ObjVisualization3D obj;
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) {
layerSurfaces.end());
}

ViewConfig unsorted({252, 160, 0});
ViewConfig unsorted{.color = {252, 160, 0}};
for (auto& sf : cylinderSurfaces) {
GeometryView3D::drawSurface(objVis, *sf, tgContext, Transform3::Identity(),
unsorted);
Expand All @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) {
std::size_t il = 0;
for (auto& layer : radialLayers) {
for (auto& sf : layer.surfaces()) {
ViewConfig sorted(sortedColors[il]);
ViewConfig sorted{.color = sortedColors[il]};
GeometryView3D::drawSurface(objVis, *sf, tgContext,
Transform3::Identity(), sorted);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) {
il = 0;
for (auto& layer : discLayersZ) {
for (auto& sf : layer.surfaces()) {
ViewConfig ViewConfig(sortedColors[il]);
ViewConfig ViewConfig{.color = sortedColors[il]};
GeometryView3D::drawSurface(objVis, *sf, tgContext,
Transform3::Identity(), ViewConfig);
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,15 +1158,15 @@ BOOST_AUTO_TEST_CASE(Material) {
ObjVisualization3D obj;

bool triangulate = true;
ViewConfig viewSensitive = ViewConfig({0, 180, 240});
ViewConfig viewSensitive = {.color = {0, 180, 240}};
viewSensitive.triangulate = triangulate;
ViewConfig viewPassive = ViewConfig({240, 280, 0});
ViewConfig viewPassive = {.color = {240, 280, 0}};
viewPassive.triangulate = triangulate;
ViewConfig viewVolume = ViewConfig({220, 220, 0});
ViewConfig viewVolume = {.color = {220, 220, 0}};
viewVolume.triangulate = triangulate;
ViewConfig viewContainer = ViewConfig({220, 220, 0});
ViewConfig viewContainer = {.color = {220, 220, 0}};
viewContainer.triangulate = triangulate;
ViewConfig viewGrid = ViewConfig({220, 0, 0});
ViewConfig viewGrid = {.color = {220, 0, 0}};
viewGrid.nSegments = 8;
viewGrid.offset = 3.;
viewGrid.triangulate = triangulate;
Expand All @@ -1186,7 +1186,7 @@ BOOST_AUTO_TEST_CASE(Material) {
ObjVisualization3D obj;

double localErrorScale = 10000000.;
ViewConfig mcolor({255, 145, 48});
ViewConfig mcolor{.color = {255, 145, 48}};
mcolor.offset = 2;
// mcolor.visible = true;

Expand Down
16 changes: 8 additions & 8 deletions Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void createDetector(GeometryContext& tgContext,
static inline std::string testBoundTrackParameters(IVisualization3D& helper) {
std::stringstream ss;

ViewConfig pcolor({20, 120, 20});
ViewConfig scolor({235, 198, 52});
ViewConfig pcolor{.color = {20, 120, 20}};
ViewConfig scolor{.color = {235, 198, 52}};

auto gctx = GeometryContext();
auto identity = Transform3::Identity();
Expand Down Expand Up @@ -245,7 +245,7 @@ static inline std::string testMeasurement(IVisualization3D& helper,
eBoundLoc0, eBoundLoc1, loc, cov2D, surface->geometryId()});
}

ViewConfig mcolor({255, 145, 48});
ViewConfig mcolor{.color = {255, 145, 48}};
mcolor.offset = 0.01;

// Draw the measurements
Expand Down Expand Up @@ -378,14 +378,14 @@ static inline std::string testMultiTrajectory(IVisualization3D& helper) {
double localErrorScale = 100.;
double directionErrorScale = 100000;

ViewConfig scolor({214, 214, 214});
ViewConfig mcolor({255, 145, 48});
ViewConfig scolor{.color = {214, 214, 214}};
ViewConfig mcolor{.color = {255, 145, 48}};
mcolor.offset = -0.01;
ViewConfig ppcolor({51, 204, 51});
ViewConfig ppcolor{.color = {51, 204, 51}};
ppcolor.offset = -0.02;
ViewConfig fpcolor({255, 255, 0});
ViewConfig fpcolor{.color = {255, 255, 0}};
fpcolor.offset = -0.03;
ViewConfig spcolor({0, 125, 255});
ViewConfig spcolor{.color = {0, 125, 255}};
spcolor.offset = -0.04;

EventDataView3D::drawMultiTrajectory(
Expand Down
4 changes: 2 additions & 2 deletions Tests/UnitTests/Core/Visualization/PrimitivesView3DBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ GeometryContext gctx = GeometryContext();
static inline std::string run(IVisualization3D& helper) {
std::stringstream ss;

ViewConfig lineView({0, 0, 255});
ViewConfig lineView{.color = {0, 0, 255}};
lineView.lineThickness = 0.1;

// Line visualization ------------------------------------------------
Expand Down Expand Up @@ -71,7 +71,7 @@ static inline std::string run(IVisualization3D& helper) {
// Error visualization: local ---------------------------------------------
Acts::GeometryView3D::drawSurface(helper, *plane, gctx);

ViewConfig errorVis({250, 0, 0});
ViewConfig errorVis{.color = {250, 0, 0}};
errorVis.lineThickness = 0.025;

SquareMatrix2 cov = SquareMatrix2::Identity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ static inline std::string run(IVisualization3D& helper, bool triangulate,
const std::string& tag) {
std::stringstream cStream;

ViewConfig viewSensitive = ViewConfig({0, 180, 240});
ViewConfig viewSensitive = {.color = {0, 180, 240}};
viewSensitive.triangulate = triangulate;
ViewConfig viewPassive = ViewConfig({240, 280, 0});
ViewConfig viewPassive = {.color = {240, 280, 0}};
viewPassive.triangulate = triangulate;
ViewConfig viewVolume = ViewConfig({220, 220, 0});
ViewConfig viewVolume = {.color = {220, 220, 0}};
viewVolume.triangulate = triangulate;
ViewConfig viewContainer = ViewConfig({220, 220, 0});
ViewConfig viewContainer = {.color = {220, 220, 0}};
viewContainer.triangulate = triangulate;
ViewConfig viewGrid = ViewConfig({220, 0, 0});
ViewConfig viewGrid = {.color = {220, 0, 0}};
viewGrid.nSegments = 8;
viewGrid.offset = 3.;
viewGrid.triangulate = triangulate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,14 @@ BOOST_AUTO_TEST_CASE(Geant4DetecturSurfaceFactory_Transforms) {
Acts::ObjVisualization3D obj;
Acts::Vector3 origin(0, 0, 0);
Acts::GeometryView3D::drawArrowForward(obj, origin, Acts::Vector3(100, 0, 0),
1000, 10,
Acts::ViewConfig({255, 0, 0}));
1000, 10, {.color = {255, 0, 0}});
Acts::GeometryView3D::drawArrowForward(obj, origin, Acts::Vector3(0, 100, 0),
1000, 10,
Acts::ViewConfig({0, 255, 0}));
1000, 10, {.color = {0, 255, 0}});
Acts::GeometryView3D::drawArrowForward(obj, origin, Acts::Vector3(0, 0, 100),
1000, 10,
Acts::ViewConfig({0, 0, 255}));
Acts::GeometryView3D::drawArrowForward(
obj, surface->center(gctx), surface->center(gctx) + 100 * normal, 1000,
10, Acts::ViewConfig({0, 255, 0}));
1000, 10, {.color = {0, 0, 255}});
Acts::GeometryView3D::drawArrowForward(obj, surface->center(gctx),
surface->center(gctx) + 100 * normal,
1000, 10, {.color = {0, 255, 0}});
auto surfaces = cache.sensitiveSurfaces;
for (const auto& [k, val] : Acts::enumerate(cache.sensitiveSurfaces)) {
const auto& [el, surf] = val;
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Plugins/TGeo/TGeoArb8ConversionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ namespace Acts::Test {

GeometryContext tgContext = GeometryContext();

ViewConfig red({200, 0, 0});
ViewConfig green({0, 200, 0});
ViewConfig blue({0, 0, 200});
ViewConfig red{.color = {200, 0, 0}};
ViewConfig green{.color = {0, 200, 0}};
ViewConfig blue{.color = {0, 0, 200}};

/// @brief Unit test to convert a TGeoTrd2 into a Plane
///
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Plugins/TGeo/TGeoBBoxConversionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ namespace Acts::Test {

GeometryContext tgContext = GeometryContext();

ViewConfig red({200, 0, 0});
ViewConfig green({0, 200, 0});
ViewConfig blue({0, 0, 200});
ViewConfig red{.color = {200, 0, 0}};
ViewConfig green{.color = {0, 200, 0}};
ViewConfig blue{.color = {0, 0, 200}};

/// @brief Unit test to convert a Bbox into a Plane
///
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Plugins/TGeo/TGeoTrd1ConversionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ namespace Acts::Test {

GeometryContext tgContext = GeometryContext();

ViewConfig red({200, 0, 0});
ViewConfig green({0, 200, 0});
ViewConfig blue({0, 0, 200});
ViewConfig red{.color = {200, 0, 0}};
ViewConfig green{.color = {0, 200, 0}};
ViewConfig blue{.color = {0, 0, 200}};

/// @brief Unit test to convert a TGeoTrd1 into a Plane
///
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Plugins/TGeo/TGeoTrd2ConversionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ namespace Acts::Test {

GeometryContext tgContext = GeometryContext();

ViewConfig red({200, 0, 0});
ViewConfig green({0, 200, 0});
ViewConfig blue({0, 0, 200});
ViewConfig red{.color = {200, 0, 0}};
ViewConfig green{.color = {0, 200, 0}};
ViewConfig blue{.color = {0, 0, 200}};

/// @brief Unit test to convert a TGeoTrd2 into a Plane
///
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Plugins/TGeo/TGeoTubeConversionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ namespace Acts::Test {

GeometryContext tgContext = GeometryContext();

ViewConfig red({200, 0, 0});
ViewConfig green({0, 200, 0});
ViewConfig blue({0, 0, 200});
ViewConfig red{.color = {200, 0, 0}};
ViewConfig green{.color = {0, 200, 0}};
ViewConfig blue{.color = {0, 0, 200}};

std::vector<std::string> allowedAxes = {"XY*", "Xy*", "xy*", "xY*",
"YX*", "yx*", "yX*", "Yx*"};
Expand Down
Loading