MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / backgroundColor

Function backgroundColor

src/Mod/CAM/PathSimulator/AppGL/View3DSettings.cpp:58–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static QColor backgroundColor(const ParameterGrp& rGrp)
59{
60 // see View3DSettings::OnChange
61
62 unsigned long col1 = rGrp.GetUnsigned("BackgroundColor", 3940932863UL);
63 unsigned long col2 = rGrp.GetUnsigned("BackgroundColor2", 859006463UL); // default color (dark blue)
64 unsigned long col3 = rGrp.GetUnsigned("BackgroundColor3", 2880160255UL); // default color
65 // (blue/grey)
66 unsigned long col4 = rGrp.GetUnsigned("BackgroundColor4", 1869583359UL); // default color
67 // (blue/grey)
68 float r1, g1, b1, r2, g2, b2, r3, g3, b3, r4, g4, b4;
69 r1 = ((col1 >> 24) & 0xff) / 255.0;
70 g1 = ((col1 >> 16) & 0xff) / 255.0;
71 b1 = ((col1 >> 8) & 0xff) / 255.0;
72 r2 = ((col2 >> 24) & 0xff) / 255.0;
73 g2 = ((col2 >> 16) & 0xff) / 255.0;
74 b2 = ((col2 >> 8) & 0xff) / 255.0;
75 r3 = ((col3 >> 24) & 0xff) / 255.0;
76 g3 = ((col3 >> 16) & 0xff) / 255.0;
77 b3 = ((col3 >> 8) & 0xff) / 255.0;
78 r4 = ((col4 >> 24) & 0xff) / 255.0;
79 g4 = ((col4 >> 16) & 0xff) / 255.0;
80 b4 = ((col4 >> 8) & 0xff) / 255.0;
81
82 // TODO: The new cam simulator currently doesn't support gradient background colors. For now we
83 // pick the color in the middle of the screen.
84
85 (void)r4, (void)g4, (void)b4;
86
87 const View3DInventorViewer::Background type = backgroundType(rGrp);
88 const bool useMidColor = rGrp.GetBool("UseBackgroundColorMid", false);
89
90 if (type == View3DInventorViewer::Background::NoGradient) {
91 return QColor::fromRgbF(r1, g1, b1);
92 }
93 else if (useMidColor) {
94 return QColor::fromRgbF(r3, g3, b3);
95 }
96 else {
97 return QColor::fromRgbF((r2 + r3) / 2, (g2 + g3) / 2, (b2 + b3) / 2);
98 }
99}
100
101void View3DSettings::OnChange(ParameterGrp::SubjectType& rCaller, ParameterGrp::MessageType Reason)
102{

Callers 2

imageFromFramebufferMethod · 0.85
OnChangeMethod · 0.85

Calls 3

backgroundTypeFunction · 0.85
GetUnsignedMethod · 0.80
GetBoolMethod · 0.80

Tested by

no test coverage detected