From fce069e2c788d283cd2b4f7ae82a997d7c87b4c7 Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Wed, 29 Jul 2009 11:52:01 +0000 Subject: [PATCH] The antialias setting can be set for all meters. --- Library/Meter.cpp | 13 +++++++++++++ Library/Meter.h | 1 + Library/MeterLine.cpp | 13 ------------- Library/MeterLine.h | 1 - Library/MeterRoundLine.cpp | 16 ---------------- Library/MeterRoundLine.h | 1 - Library/MeterString.cpp | 2 -- Library/MeterString.h | 1 - 8 files changed, 14 insertions(+), 34 deletions(-) diff --git a/Library/Meter.cpp b/Library/Meter.cpp index a0a306c0..ab7dca3e 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -61,6 +61,7 @@ CMeter::CMeter(CMeterWindow* meterWindow) m_MeterWindow = NULL; m_SolidAngle = 0.0; m_MeterWindow = meterWindow; + m_AntiAlias = false; } /* @@ -257,6 +258,7 @@ void CMeter::ReadConfig(const WCHAR* section) m_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", 1); m_UpdateCounter = m_UpdateDivider; + m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); std::vector matrix = parser.ReadFloats(section, L"TransformationMatrix"); if (matrix.size() == 6) @@ -382,6 +384,17 @@ bool CMeter::Draw(Graphics& graphics) { if (IsHidden()) return false; + if (m_AntiAlias) + { + graphics.SetInterpolationMode(InterpolationModeBicubic); + graphics.SetSmoothingMode(SmoothingModeAntiAlias); + } + else + { + graphics.SetInterpolationMode(InterpolationModeDefault); + graphics.SetSmoothingMode(SmoothingModeNone); + } + if (m_SolidColor.GetA() != 0 || m_SolidColor2.GetA() != 0) { int x = GetX(); diff --git a/Library/Meter.h b/Library/Meter.h index 3f42fae1..533204cf 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -122,6 +122,7 @@ protected: Gdiplus::Color m_SolidColor; Gdiplus::Color m_SolidColor2; Gdiplus::REAL m_SolidAngle; + bool m_AntiAlias; // If true, the line is antialiased CMeterWindow* m_MeterWindow; }; diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index e2f98ebf..4a4b94b7 100644 --- a/Library/MeterLine.cpp +++ b/Library/MeterLine.cpp @@ -36,7 +36,6 @@ using namespace Gdiplus; CMeterLine::CMeterLine(CMeterWindow* meterWindow) : CMeter(meterWindow) { m_Autoscale = false; - m_AntiAlias = false; m_HorizontalLines = false; m_HorizontalColor = 0; m_CurrentPos = 0; @@ -122,7 +121,6 @@ void CMeterLine::ReadConfig(const WCHAR* section) m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); - m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0); m_HorizontalColor = parser.ReadColor(section, L"HorizontalColor", Color::Black); // This is left here for backwards compatibility @@ -235,12 +233,6 @@ bool CMeterLine::Draw(Graphics& graphics) { maxValue = 1.0; } - - SmoothingMode mode = graphics.GetSmoothingMode(); - if (m_AntiAlias) - { - graphics.SetSmoothingMode(SmoothingModeAntiAlias); - } int x = GetX(); int y = GetY(); @@ -322,11 +314,6 @@ bool CMeterLine::Draw(Graphics& graphics) counter++; } - if (m_AntiAlias) - { - graphics.SetSmoothingMode(mode); - } - return true; } diff --git a/Library/MeterLine.h b/Library/MeterLine.h index 6f175d7b..d592debe 100644 --- a/Library/MeterLine.h +++ b/Library/MeterLine.h @@ -42,7 +42,6 @@ private: std::vector m_ScaleValues; // The scale values for the measures bool m_Autoscale; // If true, the meter is automatically adjusted to show all values - bool m_AntiAlias; // If true, the line is antialiased bool m_HorizontalLines; // If true, horizontal lines will ba drawn on the meter bool m_Flip; double m_LineWidth; diff --git a/Library/MeterRoundLine.cpp b/Library/MeterRoundLine.cpp index ac5fb7c5..6e769b2f 100644 --- a/Library/MeterRoundLine.cpp +++ b/Library/MeterRoundLine.cpp @@ -36,7 +36,6 @@ using namespace Gdiplus; */ CMeterRoundLine::CMeterRoundLine(CMeterWindow* meterWindow) : CMeter(meterWindow) { - m_AntiAlias = false; m_LineWidth = 1.0; m_LineLength = 20; m_LineStart = -1.0; @@ -80,7 +79,6 @@ void CMeterRoundLine::ReadConfig(const WCHAR* section) m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0); m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0); m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832); - m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); m_LineColor = parser.ReadColor(section, L"LineColor", Color::Black); @@ -130,12 +128,6 @@ bool CMeterRoundLine::Draw(Graphics& graphics) { if(!CMeter::Draw(graphics)) return false; - SmoothingMode mode = graphics.GetSmoothingMode(); - if (m_AntiAlias) - { - graphics.SetSmoothingMode(SmoothingModeAntiAlias); - } - // Calculate the center of for the line int x = GetX(); int y = GetY(); @@ -166,9 +158,6 @@ bool CMeterRoundLine::Draw(Graphics& graphics) { lineLength = m_LineLengthShift * m_Value + m_LineLength; } - - - SolidBrush solidBrush(m_LineColor); @@ -213,10 +202,5 @@ bool CMeterRoundLine::Draw(Graphics& graphics) graphics.DrawLine(&pen, cx, cy, x, y); } - if (m_AntiAlias) - { - graphics.SetSmoothingMode(mode); - } - return true; } diff --git a/Library/MeterRoundLine.h b/Library/MeterRoundLine.h index e0708ee2..fa6a5fb9 100644 --- a/Library/MeterRoundLine.h +++ b/Library/MeterRoundLine.h @@ -33,7 +33,6 @@ public: virtual bool Draw(Gdiplus::Graphics& graphics); private: - bool m_AntiAlias; // If true, the line is antialiased bool m_Solid; double m_LineWidth; double m_LineLength; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index c8118311..f874f86e 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -44,7 +44,6 @@ CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow) m_Scale = 1.0; m_NoDecimals = true; m_Percentual = true; - m_AntiAlias = false; m_ClipString = false; m_NumOfDecimals = -1; m_DimensionsDefined = false; @@ -192,7 +191,6 @@ void CMeterString::ReadConfig(const WCHAR* section) m_Postfix = parser.ReadString(section, L"Postfix", L""); m_Text = parser.ReadString(section, L"Text", L""); - m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0); m_AutoScale = 0!=parser.ReadInt(section, L"AutoScale", 0); m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0); diff --git a/Library/MeterString.h b/Library/MeterString.h index a13fd75e..b906d1b2 100644 --- a/Library/MeterString.h +++ b/Library/MeterString.h @@ -63,7 +63,6 @@ private: double m_Scale; // Scaling if autoscale is not used bool m_NoDecimals; // Number of decimals to use bool m_Percentual; // True, if the value should be given as % - bool m_AntiAlias; // True, the text is antialiased bool m_ClipString; // True, the text is clipped in borders (adds ellipsis to the end of the string) Gdiplus::Font* m_Font; // The font Gdiplus::FontFamily* m_FontFamily; // The font family