Change active tracing to use correct glyph instead of dot (#890)
* Change active tracing to use correct glyph instead of dot * make the pointer on the glyph line up correctly
This commit is contained in:
@@ -844,6 +844,7 @@ void Grapher::HandleTracingMovementTick(Object ^ sender, Object ^ e)
|
||||
else
|
||||
{
|
||||
ActiveTraceCursorPosition = curPos;
|
||||
PointerValueChangedEvent(curPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ public
|
||||
|
||||
public
|
||||
delegate void TracingValueChangedEventHandler(Windows::Foundation::Point value);
|
||||
public
|
||||
delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value);
|
||||
|
||||
[Windows::UI::Xaml::Markup::ContentPropertyAttribute(Name = L"Equations")] public ref class Grapher sealed
|
||||
: public Windows::UI::Xaml::Controls::Control,
|
||||
@@ -27,6 +29,7 @@ public
|
||||
{
|
||||
public:
|
||||
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
|
||||
event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
|
||||
event TracingChangedEventHandler ^ TracingChangedEvent;
|
||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "ActiveTracingPointRenderer.h"
|
||||
#include "DirectXHelper.h"
|
||||
|
||||
using namespace D2D1;
|
||||
using namespace GraphControl::DX;
|
||||
using namespace std;
|
||||
using namespace Windows::Foundation;
|
||||
|
||||
namespace
|
||||
{
|
||||
const ColorF c_DefaultPointColor = ColorF::Red;
|
||||
constexpr float c_ActiveTracingPointRadius = 2;
|
||||
}
|
||||
|
||||
ActiveTracingPointRenderer::ActiveTracingPointRenderer(DeviceResources* deviceResources)
|
||||
: m_deviceResources{ deviceResources }
|
||||
, m_color{ c_DefaultPointColor }
|
||||
|
||||
{
|
||||
m_RoundedRect.rect.bottom = 0;
|
||||
m_RoundedRect.rect.left = 0;
|
||||
m_RoundedRect.rect.right = 10;
|
||||
m_RoundedRect.rect.top = 10;
|
||||
m_width = (int)(m_RoundedRect.rect.right - m_RoundedRect.rect.left);
|
||||
m_height = (int)(m_RoundedRect.rect.top - m_RoundedRect.rect.bottom);
|
||||
m_RoundedRect.radiusX = c_ActiveTracingPointRadius;
|
||||
m_RoundedRect.radiusY = c_ActiveTracingPointRadius;
|
||||
|
||||
CreateDeviceDependentResources();
|
||||
}
|
||||
|
||||
void ActiveTracingPointRenderer::CreateDeviceDependentResources()
|
||||
{
|
||||
CreateBrush();
|
||||
}
|
||||
|
||||
void ActiveTracingPointRenderer::ReleaseDeviceDependentResources()
|
||||
{
|
||||
m_brush.Reset();
|
||||
}
|
||||
|
||||
void ActiveTracingPointRenderer::Render(const Point& location)
|
||||
{
|
||||
// We want to center this around the location
|
||||
if (ID2D1DeviceContext* context = m_deviceResources->GetD2DDeviceContext())
|
||||
{
|
||||
m_RoundedRect.rect.bottom = location.Y - m_height / 2;
|
||||
m_RoundedRect.rect.left = location.X - m_width / 2;
|
||||
m_RoundedRect.rect.top = m_RoundedRect.rect.bottom + m_height;
|
||||
m_RoundedRect.rect.right = m_RoundedRect.rect.left + m_width;
|
||||
|
||||
context->BeginDraw();
|
||||
context->FillRoundedRectangle(m_RoundedRect, m_brush.Get());
|
||||
|
||||
// Ignore D2DERR_RECREATE_TARGET here. This error indicates that the device
|
||||
// is lost. It will be handled during the next call to Present.
|
||||
HRESULT hr = context->EndDraw();
|
||||
if (hr != D2DERR_RECREATE_TARGET)
|
||||
{
|
||||
ThrowIfFailed(hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActiveTracingPointRenderer::SetColor(const ColorF& color)
|
||||
{
|
||||
m_color = color;
|
||||
CreateBrush();
|
||||
}
|
||||
|
||||
void ActiveTracingPointRenderer::CreateBrush()
|
||||
{
|
||||
m_brush.Reset();
|
||||
ThrowIfFailed(
|
||||
m_deviceResources->GetD2DDeviceContext()->CreateSolidColorBrush(m_color, &m_brush)
|
||||
);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace GraphControl::DX
|
||||
{
|
||||
class DeviceResources;
|
||||
|
||||
class ActiveTracingPointRenderer
|
||||
{
|
||||
public:
|
||||
ActiveTracingPointRenderer(DeviceResources* deviceResources);
|
||||
|
||||
void CreateDeviceDependentResources();
|
||||
void ReleaseDeviceDependentResources();
|
||||
void Render(const Windows::Foundation::Point& location);
|
||||
|
||||
void SetColor(const D2D1::ColorF& color);
|
||||
|
||||
private:
|
||||
void CreateBrush();
|
||||
|
||||
private:
|
||||
DeviceResources* const m_deviceResources;
|
||||
|
||||
D2D1::ColorF m_color;
|
||||
D2D1_ROUNDED_RECT m_RoundedRect;
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
// Resources related to rendering.
|
||||
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_brush;
|
||||
};
|
||||
}
|
||||
@@ -37,7 +37,6 @@ namespace GraphControl::DX
|
||||
, m_TraceValue(Point(0, 0))
|
||||
, m_TraceLocation(Point(0, 0))
|
||||
, m_Tracing(false)
|
||||
, m_ActiveTracingPointRenderer{ &m_deviceResources }
|
||||
{
|
||||
// Register to be notified if the Device is lost or recreated
|
||||
m_deviceResources.RegisterDeviceNotify(this);
|
||||
@@ -177,8 +176,6 @@ namespace GraphControl::DX
|
||||
{
|
||||
// Active tracing takes over for draw nearest point input from the mouse pointer.
|
||||
trackPoint = m_activeTracingPointerLocation;
|
||||
|
||||
m_ActiveTracingPointRenderer.Render(m_activeTracingPointerLocation);
|
||||
}
|
||||
|
||||
int formulaId;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "DeviceResources.h"
|
||||
#include "NearestPointRenderer.h"
|
||||
#include "ActiveTracingPointRenderer.h"
|
||||
#include "IGraph.h"
|
||||
|
||||
// Renders Direct2D and 3D content on the screen.
|
||||
@@ -67,7 +66,6 @@ namespace GraphControl::DX
|
||||
if (m_activeTracingPointerLocation != newValue)
|
||||
{
|
||||
m_activeTracingPointerLocation = newValue;
|
||||
m_ActiveTracingPointRenderer.Render(m_activeTracingPointerLocation);
|
||||
RunRenderPass();
|
||||
}
|
||||
}
|
||||
@@ -123,7 +121,6 @@ namespace GraphControl::DX
|
||||
private:
|
||||
DX::DeviceResources m_deviceResources;
|
||||
NearestPointRenderer m_nearestPointRenderer;
|
||||
ActiveTracingPointRenderer m_ActiveTracingPointRenderer;
|
||||
|
||||
// Cached Graph object with Renderer property.
|
||||
std::shared_ptr<Graphing::IGraph> m_graph = nullptr;
|
||||
|
||||
@@ -285,7 +285,6 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Control\Grapher.h" />
|
||||
<ClInclude Include="DirectX\ActiveTracingPointRenderer.h" />
|
||||
<ClInclude Include="DirectX\DeviceResources.h" />
|
||||
<ClInclude Include="DirectX\DirectXHelper.h" />
|
||||
<ClInclude Include="DirectX\NearestPointRenderer.h" />
|
||||
@@ -299,7 +298,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Control\Grapher.cpp" />
|
||||
<ClCompile Include="DirectX\ActiveTracingPointRenderer.cpp" />
|
||||
<ClCompile Include="DirectX\DeviceResources.cpp" />
|
||||
<ClCompile Include="DirectX\NearestPointRenderer.cpp" />
|
||||
<ClCompile Include="DirectX\RenderMain.cpp" />
|
||||
@@ -326,4 +324,4 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -28,9 +28,6 @@
|
||||
<ClCompile Include="DirectX\NearestPointRenderer.cpp">
|
||||
<Filter>DirectX</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectX\ActiveTracingPointRenderer.cpp">
|
||||
<Filter>DirectX</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Models\KeyGraphFeaturesInfo.cpp" />
|
||||
<ClCompile Include="Models\Equation.cpp">
|
||||
<Filter>Models</Filter>
|
||||
@@ -54,9 +51,6 @@
|
||||
<ClInclude Include="DirectX\NearestPointRenderer.h">
|
||||
<Filter>DirectX</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DirectX\ActiveTracingPointRenderer.h">
|
||||
<Filter>DirectX</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils.h" />
|
||||
<ClInclude Include="Models\KeyGraphFeaturesInfo.h" />
|
||||
<ClInclude Include="Models\Equation.h">
|
||||
@@ -77,7 +71,5 @@
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
||||
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
||||
<CopyFileToFolders Include="$(GraphingImplDll)" />
|
||||
<CopyFileToFolders Include="$(GraphingEngineDll)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user