Message 1 of 3
Applying color to CustomGraphicsGroup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
With the project I am working on, the end result could display anywhere from 4 to 400 graphics curves/lines. When this is on the smaller side, setting each curve's color is fine. As this gets larger, this method becomes much slower.
Alternatively, I've tried to apply the color to the Group (see the last line), but I can't seem to figure out why this returns false.
Edit: I should not that if I try to set the group color 'before" I add the curves, I will get a true. But the resulting display is still black (no color).
Has anyone had a similar issue or is there a more effecient way of changing the color of a large collection of entities?
Thanks!
Relevant code snippet of what I have been trying.
Ptr<CustomGraphicsGroup> pathGraphics = GetOrCreateGraphicsGroup(testGraphics, ToolpathId);
// Create color effects
Ptr<CustomGraphicsSolidColorEffect> orange = CustomGraphicsSolidColorEffect::create(FusionInter.ColorDefinitions[path]); //Ptr<Color> ColorDefinitions
Ptr<CustomGraphicsColorEffect> pathColor = orange->color();
// Function to add curves efficiently
auto addCurves = [](Ptr<CustomGraphicsGroup> group, const vector<Ptr<Curve3D>>& curves,
const Ptr<CustomGraphicsSolidColorEffect>& color, double weight) {
for (const auto& curve : curves) {
Ptr<CustomGraphicsCurve> graphicsCurve = group->addCurve(curve);
graphicsCurve->color(color);
graphicsCurve->weight(weight);
}
};
// Add main display curves
addCurves(pathGraphics, InLowerPath, orange, 1.1);
addCurves(pathGraphics, InUpperPath, orange, 1.1);
for (const auto& line : InSyncLines) {
Ptr<CustomGraphicsCurve> graphicsCurve = pathGraphics->addCurve(line);
graphicsCurve->color(orange);
graphicsCurve->weight(1.1);
}
bool result = pathGraphics->color(FusionInter.ColorDefinitions[path]);