Base: Move App::Color to Base
Every basic data type is stored in Base module, color is standing out as one that does not. Moving it to Base opens possibilities to integrate it better with the rest of FreeCAD.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "dxf.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Interpreter.h>
|
||||
@@ -3027,13 +3027,13 @@ inline static double level(int distance, double blackLevel)
|
||||
// 8 and beyond yield the black level
|
||||
return blackLevel;
|
||||
}
|
||||
inline static App::Color wheel(int hue, double blackLevel, double multiplier = 1.0)
|
||||
inline static Base::Color wheel(int hue, double blackLevel, double multiplier = 1.0)
|
||||
{
|
||||
return App::Color((float)(level(hue - 0, blackLevel) * multiplier),
|
||||
(float)(level(hue - 8, blackLevel) * multiplier),
|
||||
(float)(level(hue - 16, blackLevel) * multiplier));
|
||||
return Base::Color((float)(level(hue - 0, blackLevel) * multiplier),
|
||||
(float)(level(hue - 8, blackLevel) * multiplier),
|
||||
(float)(level(hue - 16, blackLevel) * multiplier));
|
||||
}
|
||||
App::Color CDxfRead::ObjectColor(ColorIndex_t index)
|
||||
Base::Color CDxfRead::ObjectColor(ColorIndex_t index)
|
||||
{
|
||||
// TODO: If it is ColorByBlock we need to use the color of the INSERT entity.
|
||||
// This is tricky because a block can itself contain INSERT entities and we don't currently
|
||||
@@ -3050,28 +3050,28 @@ App::Color CDxfRead::ObjectColor(ColorIndex_t index)
|
||||
// The AA fades as AA 7E 56 45 35 which is almost the exact same percentages.
|
||||
// For hue, (index-10)/10 : 0 is ff0000, and each step linearly adds green until 4 is pure
|
||||
// yellow ffff00, then red starts to fade... until but not including 24 which is back to ff0000.
|
||||
App::Color result = App::Color();
|
||||
Base::Color result = Base::Color();
|
||||
if (index == 0) {
|
||||
// Technically, 0 is BYBLOCK and not a real color, but all that means is that an object in a
|
||||
// block cannot specifically ask to be black. These colors are all contrasted to the
|
||||
// background so there is no objective black colour, through 255 is an objective white.
|
||||
result = App::Color();
|
||||
result = Base::Color();
|
||||
}
|
||||
else if (index < 7) {
|
||||
result = wheel((index - 1) * 4, 0x00);
|
||||
}
|
||||
else if (index == 7) {
|
||||
result = App::Color(1, 1, 1);
|
||||
result = Base::Color(1, 1, 1);
|
||||
}
|
||||
else if (index == 8) {
|
||||
result = App::Color(0.5, 0.5, 0.5);
|
||||
result = Base::Color(0.5, 0.5, 0.5);
|
||||
}
|
||||
else if (index == 9) {
|
||||
result = App::Color(0.75, 0.75, 0.75);
|
||||
result = Base::Color(0.75, 0.75, 0.75);
|
||||
}
|
||||
else if (index >= 250) {
|
||||
auto brightness = (float)((index - 250 + (255 - index) * 0.2) / 5);
|
||||
result = App::Color(brightness, brightness, brightness);
|
||||
result = Base::Color(brightness, brightness, brightness);
|
||||
}
|
||||
else {
|
||||
static const std::array<float, 5> fades = {1.00F, 0.74F, 0.50F, 0.40F, 0.30F};
|
||||
|
||||
Reference in New Issue
Block a user