The antialias setting can be set for all meters.

This commit is contained in:
Kimmo Pekkola 2009-07-29 11:52:01 +00:00
parent df9817a83c
commit fce069e2c7
8 changed files with 14 additions and 34 deletions

View File

@ -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<Gdiplus::REAL> 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();

View File

@ -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;
};

View File

@ -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
@ -236,12 +234,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;
}

View File

@ -42,7 +42,6 @@ private:
std::vector<double> 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;

View File

@ -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();
@ -167,9 +159,6 @@ bool CMeterRoundLine::Draw(Graphics& graphics)
lineLength = m_LineLengthShift * m_Value + m_LineLength;
}
SolidBrush solidBrush(m_LineColor);
//Create a path to surround the arc
@ -213,10 +202,5 @@ bool CMeterRoundLine::Draw(Graphics& graphics)
graphics.DrawLine(&pen, cx, cy, x, y);
}
if (m_AntiAlias)
{
graphics.SetSmoothingMode(mode);
}
return true;
}

View File

@ -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;

View File

@ -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);

View File

@ -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