stuff-from-scratch/src/graphics/DrawingContext.cpp
2022-11-16 15:06:08 +00:00

43 lines
1,021 B
C++

#include "DrawingContext.h"
#include "AbstractPainter.h"
#include "PainterFactory.h"
#include "Grid.h"
#include "TriMesh.h"
#include "DrawingSurface.h"
#include "Scene.h"
DrawingContext::DrawingContext(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode)
: mSurface(surface),
mDrawingMode(requestedDrawingMode),
mFontsManager(fontsManager)
{
mPainter = PainterFactory::Create(mDrawingMode);
}
std::unique_ptr<DrawingContext> DrawingContext::Create(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode)
{
return std::make_unique<DrawingContext>(surface, fontsManager, requestedDrawingMode);
}
DrawingSurface* DrawingContext::getSurface() const
{
return mSurface;
}
FontsManager* DrawingContext::getFontsManager() const
{
return mFontsManager;
}
void DrawingContext::paint()
{
if (mDrawingMode == DrawingMode::GRAPH)
{
mSurface->getScene()->update(mFontsManager);
}
mPainter->paint(this);
}