2022-01-10 01:53:01 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CALLBACK_GAL_H
|
|
|
|
#define CALLBACK_GAL_H
|
|
|
|
|
2023-09-26 11:40:17 +00:00
|
|
|
#include <gal/gal.h>
|
2022-01-10 01:53:01 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
|
2023-09-26 11:40:17 +00:00
|
|
|
class GAL_API CALLBACK_GAL : public KIGFX::GAL
|
2022-01-10 01:53:01 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CALLBACK_GAL( KIGFX::GAL_DISPLAY_OPTIONS& aDisplayOptions,
|
|
|
|
std::function<void( const VECTOR2I& aPt1,
|
|
|
|
const VECTOR2I& aPt2 )> aStrokeCallback,
|
|
|
|
std::function<void( const VECTOR2I& aPt1,
|
2022-03-08 13:16:39 +00:00
|
|
|
const VECTOR2I& aPt2,
|
|
|
|
const VECTOR2I& aPt3 )> aTriangleCallback ) :
|
2022-01-10 01:53:01 +00:00
|
|
|
GAL( aDisplayOptions )
|
2022-02-25 12:44:59 +00:00
|
|
|
{
|
2022-01-10 01:53:01 +00:00
|
|
|
m_strokeCallback = aStrokeCallback;
|
|
|
|
m_triangleCallback = aTriangleCallback;
|
2022-02-25 12:44:59 +00:00
|
|
|
m_outlineCallback = []( const SHAPE_LINE_CHAIN& ) {};
|
2022-03-08 13:16:39 +00:00
|
|
|
m_stroke = true;
|
2022-01-14 01:04:14 +00:00
|
|
|
m_triangulate = true;
|
2022-02-25 12:44:59 +00:00
|
|
|
}
|
2022-01-14 01:04:14 +00:00
|
|
|
|
|
|
|
CALLBACK_GAL( KIGFX::GAL_DISPLAY_OPTIONS& aDisplayOptions,
|
|
|
|
std::function<void( const VECTOR2I& aPt1,
|
|
|
|
const VECTOR2I& aPt2 )> aStrokeCallback,
|
|
|
|
std::function<void( const SHAPE_LINE_CHAIN& aPoly )> aOutlineCallback ) :
|
|
|
|
GAL( aDisplayOptions )
|
2022-02-25 12:44:59 +00:00
|
|
|
{
|
2022-01-14 01:04:14 +00:00
|
|
|
m_strokeCallback = aStrokeCallback;
|
2022-02-25 12:44:59 +00:00
|
|
|
m_triangleCallback = []( const VECTOR2I&, const VECTOR2I&, const VECTOR2I& ) {};
|
2022-01-14 01:04:14 +00:00
|
|
|
m_outlineCallback = aOutlineCallback;
|
2022-03-08 13:16:39 +00:00
|
|
|
m_stroke = true;
|
2022-01-14 01:04:14 +00:00
|
|
|
m_triangulate = false;
|
2022-02-25 12:44:59 +00:00
|
|
|
}
|
|
|
|
|
2022-03-08 13:16:39 +00:00
|
|
|
CALLBACK_GAL( KIGFX::GAL_DISPLAY_OPTIONS& aDisplayOptions,
|
|
|
|
std::function<void( const SHAPE_LINE_CHAIN& aPoly )> aOutlineCallback ) :
|
|
|
|
GAL( aDisplayOptions )
|
2022-02-25 12:44:59 +00:00
|
|
|
{
|
2022-03-08 13:16:39 +00:00
|
|
|
m_strokeCallback = []( const VECTOR2I& aPt1, const VECTOR2I& aPt2 ) {};
|
|
|
|
m_triangleCallback = []( const VECTOR2I&, const VECTOR2I&, const VECTOR2I& ) {};
|
2022-02-25 12:44:59 +00:00
|
|
|
m_outlineCallback = aOutlineCallback;
|
2022-03-08 13:16:39 +00:00
|
|
|
m_stroke = false;
|
2022-02-25 12:44:59 +00:00
|
|
|
m_triangulate = false;
|
|
|
|
}
|
2022-01-10 01:53:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a polygon representing an outline font glyph.
|
|
|
|
*/
|
|
|
|
void DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth, int aTotal ) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::function<void( const VECTOR2I& aPt1,
|
|
|
|
const VECTOR2I& aPt2 )> m_strokeCallback;
|
|
|
|
|
|
|
|
std::function<void( const VECTOR2I& aPt1,
|
|
|
|
const VECTOR2I& aPt2,
|
|
|
|
const VECTOR2I& aPt3 )> m_triangleCallback;
|
2022-01-14 01:04:14 +00:00
|
|
|
|
|
|
|
std::function<void( const SHAPE_LINE_CHAIN& aPoly )> m_outlineCallback;
|
|
|
|
|
2022-03-08 13:16:39 +00:00
|
|
|
bool m_stroke;
|
2022-01-14 01:04:14 +00:00
|
|
|
bool m_triangulate;
|
2022-01-10 01:53:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-02-25 12:44:59 +00:00
|
|
|
#endif // define CALLBACK_GAL_H
|