2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-07-29 18:06:45 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-12-19 16:00:52 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-01-18 01:40:03 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
2018-01-04 01:51:27 +00:00
|
|
|
* 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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
2018-01-04 01:51:27 +00:00
|
|
|
* 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.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
2018-01-04 01:51:27 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-10-17 20:01:27 +00:00
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifndef GR_BASIC
|
|
|
|
#define GR_BASIC
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
#include <gal/color4d.h>
|
2009-06-25 20:45:27 +00:00
|
|
|
#include <vector>
|
2019-05-27 09:06:34 +00:00
|
|
|
#include <eda_rect.h>
|
2020-10-18 11:31:07 +00:00
|
|
|
#include <wx/pen.h>
|
|
|
|
#include <wx/dc.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
using KIGFX::COLOR4D;
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
/// Drawmode. Compositing mode plus a flag or two
|
|
|
|
enum GR_DRAWMODE {
|
|
|
|
GR_OR = 0x01000000,
|
|
|
|
GR_XOR = 0x02000000,
|
|
|
|
GR_AND = 0x04000000,
|
|
|
|
GR_NXOR = 0x08000000,
|
|
|
|
GR_INVERT = 0x10000000,
|
|
|
|
GR_ALLOW_HIGHCONTRAST = 0x20000000,
|
2015-03-25 09:55:00 +00:00
|
|
|
GR_COPY = 0x40000000,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_HIGHLIGHT = 0x80000000,
|
|
|
|
UNSPECIFIED_DRAWMODE = -1
|
|
|
|
};
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
inline GR_DRAWMODE operator~( const GR_DRAWMODE& a )
|
2012-09-01 13:38:27 +00:00
|
|
|
{
|
|
|
|
return static_cast<GR_DRAWMODE>( ~int( a ) );
|
|
|
|
}
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
inline GR_DRAWMODE operator|( const GR_DRAWMODE& a, const GR_DRAWMODE& b )
|
2012-09-01 13:38:27 +00:00
|
|
|
{
|
|
|
|
return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
|
|
|
|
}
|
|
|
|
|
2020-12-19 16:00:52 +00:00
|
|
|
inline GR_DRAWMODE operator&( const GR_DRAWMODE& a, const GR_DRAWMODE& b )
|
2012-09-01 13:38:27 +00:00
|
|
|
{
|
|
|
|
return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
extern GR_DRAWMODE g_XorMode;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
typedef enum {
|
|
|
|
/* Line styles for Get/SetLineStyle. */
|
2007-10-12 03:24:46 +00:00
|
|
|
GR_SOLID_LINE = 0,
|
|
|
|
GR_DOTTED_LINE = 1,
|
|
|
|
GR_DASHED_LINE = 3
|
2007-06-05 12:10:51 +00:00
|
|
|
} GRLineStypeType;
|
|
|
|
|
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
void GRResetPenAndBrush( wxDC* DC );
|
2021-07-26 17:28:37 +00:00
|
|
|
void GRSetColorPen( wxDC* DC, const COLOR4D& Color, int width = 1,
|
|
|
|
wxPenStyle stype = wxPENSTYLE_SOLID );
|
|
|
|
void GRSetBrush( wxDC* DC, const COLOR4D& Color, bool fill = false );
|
2008-08-09 08:05:42 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
2020-12-19 16:00:52 +00:00
|
|
|
* @param flagforce True to force a black pen whenever the asked color.
|
2008-08-09 08:05:42 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void GRForceBlackPen( bool flagforce );
|
2008-08-09 08:05:42 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
2020-12-19 16:00:52 +00:00
|
|
|
* @return True if a black pen was forced or false if not forced.
|
2008-08-09 08:05:42 +00:00
|
|
|
*/
|
|
|
|
bool GetGRForceBlackPenState( void );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2022-01-28 22:51:34 +00:00
|
|
|
void GRLine( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
|
|
|
|
const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
|
|
|
|
void GRLine( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
|
|
|
|
wxPenStyle aStyle = wxPENSTYLE_SOLID );
|
2009-11-23 20:18:47 +00:00
|
|
|
void GRMoveTo( int x, int y );
|
2022-01-28 22:51:34 +00:00
|
|
|
void GRLineTo( wxDC* DC, int x, int y, int width, const COLOR4D& Color );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2022-01-28 22:51:34 +00:00
|
|
|
void GRPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width, const COLOR4D& Color,
|
|
|
|
const COLOR4D& BgColor );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
/**
|
2020-12-19 16:00:52 +00:00
|
|
|
* Draw a closed polygon onto the drawing context \a aDC and optionally fills and/or draws
|
|
|
|
* a border around it.
|
|
|
|
*
|
2008-12-29 18:02:54 +00:00
|
|
|
* @param aDC the device context into which drawing should occur.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aPointCount the number of points in the array \a aPoints.
|
|
|
|
* @param aPoints The points to draw.
|
|
|
|
* @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
|
2022-01-28 22:51:34 +00:00
|
|
|
* @param aColor the color of the border and the fill.
|
2008-12-29 18:02:54 +00:00
|
|
|
*/
|
2022-01-28 22:51:34 +00:00
|
|
|
void GRClosedPoly( wxDC* aDC, int aPointCount, const VECTOR2I* aPoints, bool doFill,
|
|
|
|
const COLOR4D& aColor );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-19 16:00:52 +00:00
|
|
|
* Draw a circle onto the drawing context \a aDC centered at the user coordinates (x,y).
|
2008-12-29 18:02:54 +00:00
|
|
|
*
|
|
|
|
* @param aDC the device context into which drawing should occur.
|
|
|
|
* @param x The x coordinate in user space of the center of the circle.
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param y The y coordinate in user space of the center of the circle.
|
2008-12-29 20:05:47 +00:00
|
|
|
* @param aRadius is the radius of the circle.
|
2020-12-19 16:00:52 +00:00
|
|
|
* @param aColor is the color to draw.
|
2017-02-20 16:57:41 +00:00
|
|
|
* @see COLOR4D
|
2008-12-29 18:02:54 +00:00
|
|
|
*/
|
2022-01-28 22:51:34 +00:00
|
|
|
void GRFilledCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
|
|
|
|
const COLOR4D& aStrokeColor, const COLOR4D& aFillColor );
|
|
|
|
void GRCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth, const COLOR4D& aColor );
|
|
|
|
|
|
|
|
void GRArc( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
|
|
|
|
int aWidth, const COLOR4D& aColor );
|
|
|
|
void GRFilledArc( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
|
|
|
|
int width, const COLOR4D& Color, const COLOR4D& BgColor );
|
|
|
|
|
|
|
|
void GRFilledSegment( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
|
|
|
|
const COLOR4D& aColor );
|
|
|
|
|
|
|
|
void GRCSegm( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
|
|
|
|
const COLOR4D& aColor );
|
|
|
|
|
|
|
|
void GRFilledRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
|
|
|
|
const COLOR4D& aColor, const COLOR4D& aBgColor );
|
|
|
|
void GRRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
|
|
|
|
const COLOR4D& aColor );
|
|
|
|
|
|
|
|
void GRSFilledRect( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
|
|
|
|
const COLOR4D& BgColor );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-12 03:24:46 +00:00
|
|
|
#endif /* define GR_BASIC */
|