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
|
2011-10-17 20:01:27 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2018-01-04 01:51:27 +00:00
|
|
|
* Copyright (C) 1992-2018 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
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file gr_basic.h
|
|
|
|
*/
|
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>
|
2011-03-29 19:33:07 +00:00
|
|
|
class EDA_RECT;
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
inline void DrawModeAddHighlight(GR_DRAWMODE *mode)
|
|
|
|
{
|
|
|
|
*mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void DrawModeAllowHighContrast(GR_DRAWMODE *mode)
|
|
|
|
{
|
|
|
|
*mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GR_DRAWMODE operator ~(const GR_DRAWMODE& a)
|
|
|
|
{
|
|
|
|
return static_cast<GR_DRAWMODE>( ~int( a ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GR_DRAWMODE operator |(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
|
|
|
|
{
|
|
|
|
return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GR_DRAWMODE operator &(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
|
|
|
|
{
|
|
|
|
return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
|
|
|
|
}
|
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
#define GR_M_LEFT_DOWN 0x10000000
|
|
|
|
#define GR_M_RIGHT_DOWN 0x20000000
|
|
|
|
#define GR_M_MIDDLE_DOWN 0x40000000
|
|
|
|
#define GR_M_DCLICK 0x80000000
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_PANEL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
void GRSetDrawMode( wxDC* DC, GR_DRAWMODE mode );
|
|
|
|
GR_DRAWMODE GRGetDrawMode( wxDC* DC );
|
2009-11-23 20:18:47 +00:00
|
|
|
void GRResetPenAndBrush( wxDC* DC );
|
2017-02-20 16:57:41 +00:00
|
|
|
void GRSetColorPen( wxDC* DC, COLOR4D Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
|
|
|
|
void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill = false );
|
2008-08-09 08:05:42 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function GRForceBlackPen
|
2008-08-09 08:05:42 +00:00
|
|
|
* @param flagforce True to force a black pen whenever the asked color
|
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* Function GetGRForceBlackPenState
|
2009-11-23 20:18:47 +00:00
|
|
|
* @return ForceBlackPen (True if a black pen was forced)
|
2008-08-09 08:05:42 +00:00
|
|
|
*/
|
|
|
|
bool GetGRForceBlackPenState( void );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2015-10-25 16:58:04 +00:00
|
|
|
void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
|
2017-10-31 16:33:37 +00:00
|
|
|
wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
|
2015-10-25 16:58:04 +00:00
|
|
|
void GRLine( EDA_RECT* ClipBox, wxDC* DC,
|
2017-10-31 16:33:37 +00:00
|
|
|
int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
2017-02-20 16:57:41 +00:00
|
|
|
int width, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
2017-02-20 16:57:41 +00:00
|
|
|
int width, COLOR4D Color );
|
2017-10-31 16:33:37 +00:00
|
|
|
void GRDottedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
|
|
|
int width, COLOR4D Color );
|
2009-11-23 20:18:47 +00:00
|
|
|
void GRMoveTo( int x, int y );
|
2015-10-25 16:58:04 +00:00
|
|
|
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
|
2017-02-20 16:57:41 +00:00
|
|
|
int x, int y, int width, COLOR4D Color );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
|
2017-02-20 16:57:41 +00:00
|
|
|
int width, COLOR4D Color, COLOR4D BgColor );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2019-11-09 10:14:20 +00:00
|
|
|
/** Draw cubic (4 points: start control1, control2, end) bezier curve
|
|
|
|
*/
|
|
|
|
void GRBezier( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aPoints,
|
|
|
|
int aWidth, COLOR4D aColor );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GRClosedPoly
|
2009-11-23 20:18:47 +00:00
|
|
|
* draws a closed polygon onto the drawing context \a aDC and optionally fills
|
|
|
|
* and/or draws a border around it.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
|
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.
|
2017-02-20 16:57:41 +00:00
|
|
|
* @param aPenColor the color of the border.
|
2008-12-29 18:02:54 +00:00
|
|
|
* @param aFillColor the fill color of the polygon's interior.
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRClosedPoly( EDA_RECT* ClipBox,
|
2009-11-23 20:18:47 +00:00
|
|
|
wxDC * aDC,
|
|
|
|
int aPointCount,
|
|
|
|
wxPoint aPoints[],
|
|
|
|
bool doFill,
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D aPenColor,
|
|
|
|
COLOR4D aFillColor );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
// @todo could make these 2 closed polygons calls a single function and default
|
|
|
|
// the aPenWidth argument
|
2008-12-29 18:02:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GRClosedPoly
|
2009-11-23 20:18:47 +00:00
|
|
|
* draws a closed polygon onto the drawing context \a aDC and optionally fills
|
|
|
|
* and/or draws a border around it.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
|
2008-12-29 18:02:54 +00:00
|
|
|
* @param aDC the device context into which drawing should occur.
|
|
|
|
* @param aPointCount the number of points in the array \a aPointArray.
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aPoints the points to draw.
|
|
|
|
* @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
|
|
|
|
* @param aPenWidth is the width of the pen to use on the perimeter, can be zero.
|
2017-02-20 16:57:41 +00:00
|
|
|
* @param aPenColor the color of the border.
|
2008-12-29 18:02:54 +00:00
|
|
|
* @param aFillColor the fill color of the polygon's interior.
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRClosedPoly( EDA_RECT* ClipBox,
|
2009-11-23 20:18:47 +00:00
|
|
|
wxDC* aDC,
|
|
|
|
int aPointCount,
|
|
|
|
wxPoint aPoints[],
|
|
|
|
bool doFill,
|
|
|
|
int aPenWidth,
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D aPenColor,
|
|
|
|
COLOR4D aFillColor );
|
2008-12-29 18:02:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GRCircle
|
2009-11-23 20:18:47 +00:00
|
|
|
* draws a circle onto the drawing context \a aDC centered at the user
|
|
|
|
* coordinates (x,y)
|
2008-12-29 18:02:54 +00:00
|
|
|
*
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
|
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.
|
2017-02-20 16:57:41 +00:00
|
|
|
* @param aColor is the color to draw
|
|
|
|
* @see COLOR4D
|
2008-12-29 18:02:54 +00:00
|
|
|
*/
|
2017-02-20 16:57:41 +00:00
|
|
|
void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
|
|
|
|
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D Color, COLOR4D BgColor );
|
|
|
|
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
|
|
|
|
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2013-05-05 07:17:48 +00:00
|
|
|
void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
|
2017-02-20 16:57:41 +00:00
|
|
|
double EndAngle, int r, COLOR4D Color );
|
2013-05-05 07:17:48 +00:00
|
|
|
void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
|
2017-02-20 16:57:41 +00:00
|
|
|
double EndAngle, int r, int width, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
2017-02-20 16:57:41 +00:00
|
|
|
int xc, int yc, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
2017-02-20 16:57:41 +00:00
|
|
|
int xc, int yc, int width, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
2017-02-20 16:57:41 +00:00
|
|
|
wxPoint aCenter, int aWidth, COLOR4D aColor );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
|
2017-02-20 16:57:41 +00:00
|
|
|
double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
|
2013-05-05 07:17:48 +00:00
|
|
|
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
|
2017-02-20 16:57:41 +00:00
|
|
|
double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
|
|
|
|
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
|
2010-10-09 20:05:03 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
2017-02-20 16:57:41 +00:00
|
|
|
int width, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
2017-02-20 16:57:41 +00:00
|
|
|
int aWidth, COLOR4D aColor );
|
2010-10-09 20:05:03 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
2017-02-20 16:57:41 +00:00
|
|
|
int width, int aPenSize, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
2017-02-20 16:57:41 +00:00
|
|
|
int aWidth, COLOR4D aColor );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void GRSetColor( COLOR4D Color );
|
2007-09-13 11:55:46 +00:00
|
|
|
void GRSetDefaultPalette();
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D GRGetColor();
|
|
|
|
void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
|
2017-02-20 16:57:41 +00:00
|
|
|
int x2, int y2, COLOR4D Color, COLOR4D BgColor );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
|
2017-02-20 16:57:41 +00:00
|
|
|
int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
|
|
|
|
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
|
|
|
|
void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
|
2017-02-20 16:57:41 +00:00
|
|
|
int x2, int y2, int width, COLOR4D Color );
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
|
2017-02-20 16:57:41 +00:00
|
|
|
int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
|
2017-02-20 16:57:41 +00:00
|
|
|
int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function GRLineArray
|
2010-10-13 19:50:23 +00:00
|
|
|
* draws an array of lines (not a polygon).
|
|
|
|
* @param aClipBox = the clip box
|
|
|
|
* @param aDC = the device context into which drawing should occur.
|
|
|
|
* @param aLines = a list of pair of coordinate in user space: a pair for each line.
|
|
|
|
* @param aWidth = the width of each line.
|
2017-02-20 16:57:41 +00:00
|
|
|
* @param aColor = the color of the lines
|
|
|
|
* @see COLOR4D
|
2010-10-13 19:50:23 +00:00
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
|
2017-02-20 16:57:41 +00:00
|
|
|
int aWidth, COLOR4D aColor );
|
2010-10-09 08:08:29 +00:00
|
|
|
|
2014-06-20 11:13:04 +00:00
|
|
|
void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D aColor );
|
2013-04-09 16:00:46 +00:00
|
|
|
|
2018-01-04 01:51:27 +00:00
|
|
|
/**
|
|
|
|
* Draw text centered on a wxDC with wrapping.
|
|
|
|
* @param aDC wxDC instance onto which the text will be drawn
|
|
|
|
* @param aText the text to draw
|
|
|
|
*/
|
|
|
|
void GRDrawWrappedText( wxDC& aDC, wxString const& aText );
|
|
|
|
|
2007-10-12 03:24:46 +00:00
|
|
|
#endif /* define GR_BASIC */
|