52 lines
1.2 KiB
C++
52 lines
1.2 KiB
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(this, 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();
|
|
}
|
|
|
|
AbstractPainter* DrawingContext::getPainter() const
|
|
{
|
|
return mPainter.get();
|
|
}
|
|
|
|
bool DrawingContext::painterSupportsGeometryPrimitives() const
|
|
{
|
|
return mPainter->supportsGeometryPrimitives();
|
|
}
|