mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 15:20:10 +00:00
Change from EDA_COLOR_T to COLOR4D globally; arbitrary color support
eeschema now supports arbitrary colors for all object types, and pcbnew does in GAL canvas. When switching from GAL to legacy canvas, pcbnew will convert colors to the nearest legacy color.
This commit is contained in:
parent
4c83b0a94d
commit
a52250a91e
3d-viewer
bitmap2component
common
block_commande.cppclass_bitmap_base.cppclass_colors_design_settings.cppclass_layer_box_selector.cppcommon.cppcommon_plotDXF_functions.cppcommon_plotGERBER_functions.cppcommon_plotPDF_functions.cppcommon_plotPS_functions.cppcommon_plotSVG_functions.cppcommon_plot_functions.cppconfig_params.cppdraw_frame.cppdraw_panel.cppdrawtxt.cppeda_text.cpp
gal
gr_basic.cppmsgpanel.cpppage_layout
painter.cppselcolor.cppswig
worksheet.cppworksheet_viewitem.cppcvpcb
eeschema
CMakeLists.txtbus-wire-junction.cppclass_libentry.cppclass_libentry.hclass_sch_screen.h
dialogs
dialog_choose_component.cppdialog_lib_edit_pin.cppdialog_print_using_printer.cppdialog_rescue_each.cpp
eeredraw.cppeeschema.cppeeschema_config.cppgeneral.hlib_arc.cpplib_arc.hlib_bezier.cpplib_bezier.hlib_circle.cpplib_circle.hlib_draw_item.cpplib_draw_item.hlib_field.cpplib_field.hlib_pin.cpplib_pin.hlib_polyline.cpplib_polyline.hlib_rectangle.cpplib_rectangle.hlib_text.cpplib_text.hlibeditframe.cpppinedit.cppprotos.hsch_base_frame.cppsch_base_frame.hsch_bitmap.cppsch_bitmap.hsch_bus_entry.cppsch_bus_entry.hsch_component.cppsch_component.hsch_field.cppsch_field.hsch_item_struct.hsch_junction.cppsch_junction.hsch_line.cppsch_line.hsch_marker.cppsch_marker.hsch_no_connect.cppsch_no_connect.hsch_screen.cppsch_sheet.cppsch_sheet.hsch_sheet_pin.cppsch_text.cppsch_text.hschedit.cppsim
symbdraw.cppwidgets
gerbview
CMakeLists.txtblock.cppclass_aperture_macro.cppclass_aperture_macro.hclass_gbr_display_options.hclass_gbr_layer_box_selector.cppclass_gbr_layer_box_selector.hclass_gbr_layout.cppclass_gbr_layout.hclass_gerber_draw_item.cppclass_gerber_draw_item.hclass_gerber_file_image.hclass_gerbview_layer_widget.cppclass_gerbview_layer_widget.hdcode.cppdcode.hdraw_gerber_screen.cppgerbview_config.cppgerbview_frame.cppgerbview_frame.hprintout_control.cpp
include
basic_gal.hblock_commande.hclass_bitmap_base.hclass_colors_design_settings.hclass_drawpanel.hclass_layer_box_selector.hclass_marker_base.hclass_worksheet_dataitem.hcolors.hcommon.hconfig_params.hdraw_frame.hdrawtxt.heda_text.h
gal
gr_basic.hmsgpanel.hpainter.hplot_common.hworksheet.hworksheet_shape_builder.hwxPcbStruct.hwxstruct.hkicad
pagelayout_editor
pcb_calculator
pcbnew
CMakeLists.txt
autorouter
board_items_to_polygon_shape_transform.cppclass_board.cppclass_board.hclass_dimension.cppclass_drawsegment.cppclass_edge_mod.cppclass_mire.cppclass_netinfo_item.cppclass_pad.hclass_pad_draw_functions.cppclass_pcb_layer_box_selector.cppclass_pcb_layer_box_selector.hclass_pcb_layer_widget.cppclass_pcb_layer_widget.hclass_pcb_text.cppclass_text_mod.cppclass_track.cppclass_track.hclass_zone.cppdialogs
dialog_SVG_print.cppdialog_copper_zones.cppdialog_keepout_area_properties.cppdialog_non_copper_zones_properties.cppdialog_pad_properties.cpp
editrack.cppexporters
layer_widget.cpplayer_widget.hmodedit.cppmodule_editor_frame.hmodview_frame.cppmodview_frame.hpcb_painter.cpppcb_plot_params.hpcbframe.cpppcbplot.hplot_board_layers.cppplot_brditems_plotter.cppprint_board_functions.cppprintout_controler.cppratsnest.cpprouter
sel_layer.cppswig
tool_pcb.cpp@ -532,16 +532,9 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( LAYER_ID aLayerId ) const
|
||||
{
|
||||
wxASSERT( aLayerId < LAYER_ID_COUNT );
|
||||
|
||||
const EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayerId );
|
||||
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
|
||||
const COLOR4D color = g_ColorsSettings.GetLayerColor( aLayerId );
|
||||
|
||||
static const float inv_255 = 1.0f / 255.0f;
|
||||
|
||||
const float red = colordata.m_Red * inv_255;
|
||||
const float green = colordata.m_Green * inv_255;
|
||||
const float blue = colordata.m_Blue * inv_255;
|
||||
|
||||
return SFVEC3F( red, green, blue );
|
||||
return SFVEC3F( color.r, color.g, color.b );
|
||||
}
|
||||
|
||||
|
||||
@ -551,15 +544,7 @@ SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const
|
||||
}
|
||||
|
||||
|
||||
SFVEC3F CINFO3D_VISU::GetColor( EDA_COLOR_T aColor ) const
|
||||
SFVEC3F CINFO3D_VISU::GetColor( COLOR4D aColor ) const
|
||||
{
|
||||
const StructColors &colordata = g_ColorRefs[ColorGetBase( aColor )];
|
||||
|
||||
static const float inv_255 = 1.0f / 255.0f;
|
||||
|
||||
const float red = colordata.m_Red * inv_255;
|
||||
const float green = colordata.m_Green * inv_255;
|
||||
const float blue = colordata.m_Blue * inv_255;
|
||||
|
||||
return SFVEC3F( red, green, blue );
|
||||
return SFVEC3F( aColor.r, aColor.g, aColor.b );
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ class CINFO3D_VISU
|
||||
* @param aColor: the color mapped
|
||||
* @return the color in SFVEC3F format
|
||||
*/
|
||||
SFVEC3F GetColor( EDA_COLOR_T aColor ) const;
|
||||
SFVEC3F GetColor( COLOR4D aColor ) const;
|
||||
|
||||
/**
|
||||
* @brief GetLayerTopZpos3DU - Get the top z position
|
||||
|
@ -106,7 +106,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
|
||||
s_boardBBox3DU = &m_board2dBBox3DU;
|
||||
|
||||
// not actually used, but needed by DrawGraphicText
|
||||
const EDA_COLOR_T dummy_color = BLACK;
|
||||
const COLOR4D dummy_color = COLOR4D_BLACK;
|
||||
|
||||
if( aTextPCB->IsMultilineAllowed() )
|
||||
{
|
||||
|
@ -111,6 +111,11 @@ set(3D-VIEWER_SRCS
|
||||
add_library(3d-viewer STATIC ${3D-VIEWER_SRCS})
|
||||
add_dependencies( 3d-viewer pcbcommon )
|
||||
|
||||
target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} kicad_3dsg )
|
||||
target_link_libraries( 3d-viewer
|
||||
gal
|
||||
${Boost_}
|
||||
${wxWidgets_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
kicad_3dsg )
|
||||
|
||||
add_subdirectory( 3d_cache )
|
||||
|
@ -47,6 +47,7 @@ target_link_libraries( bitmap2component
|
||||
common
|
||||
polygon
|
||||
bitmaps
|
||||
gal
|
||||
${wxWidgets_LIBRARIES}
|
||||
potrace
|
||||
)
|
||||
|
@ -122,7 +122,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
|
||||
|
||||
|
||||
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
||||
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
|
||||
GR_DRAWMODE aDrawMode, COLOR4D aColor )
|
||||
{
|
||||
if( !aDC )
|
||||
return;
|
||||
|
@ -287,7 +287,7 @@ void BITMAP_BASE::Rotate( bool aRotateCCW )
|
||||
|
||||
void BITMAP_BASE::PlotImage( PLOTTER* aPlotter,
|
||||
const wxPoint& aPos,
|
||||
EDA_COLOR_T aDefaultColor,
|
||||
COLOR4D aDefaultColor,
|
||||
int aDefaultPensize )
|
||||
{
|
||||
if( m_image == NULL )
|
||||
|
@ -27,7 +27,6 @@
|
||||
* @brief Handle colors used to draw all items or layers.
|
||||
*/
|
||||
#include <fctsys.h>
|
||||
#include <colors.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <class_colors_design_settings.h>
|
||||
@ -91,7 +90,7 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
|
||||
{
|
||||
for( unsigned src = 0, dst = 0; dst < DIM(m_LayersColors); ++dst )
|
||||
{
|
||||
m_LayersColors[dst] = default_layer_color[src++];
|
||||
m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
|
||||
|
||||
if( src >= DIM( default_layer_color ) )
|
||||
src = 0; // wrap the source.
|
||||
@ -99,7 +98,7 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
|
||||
|
||||
for( unsigned src = 0, dst = 0; dst < DIM(m_ItemsColors); ++dst )
|
||||
{
|
||||
m_ItemsColors[dst] = default_items_color[src++];
|
||||
m_ItemsColors[dst] = COLOR4D( default_items_color[src++] );
|
||||
|
||||
if( src >= DIM( default_items_color ) )
|
||||
src = 0;
|
||||
@ -107,17 +106,17 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
|
||||
}
|
||||
|
||||
|
||||
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
|
||||
COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
|
||||
{
|
||||
if( (unsigned) aLayer < DIM(m_LayersColors) )
|
||||
{
|
||||
return m_LayersColors[aLayer];
|
||||
}
|
||||
return UNSPECIFIED_COLOR;
|
||||
return UNSPECIFIED_COLOR4D;
|
||||
}
|
||||
|
||||
|
||||
void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
|
||||
void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
|
||||
{
|
||||
if( (unsigned) aLayer < DIM(m_LayersColors) )
|
||||
{
|
||||
@ -126,18 +125,18 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor
|
||||
}
|
||||
|
||||
|
||||
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
|
||||
COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
|
||||
{
|
||||
if( (unsigned) aItemIdx < DIM( m_ItemsColors ) )
|
||||
{
|
||||
return m_ItemsColors[aItemIdx];
|
||||
}
|
||||
|
||||
return UNSPECIFIED_COLOR;
|
||||
return UNSPECIFIED_COLOR4D;
|
||||
}
|
||||
|
||||
|
||||
void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor )
|
||||
void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor )
|
||||
{
|
||||
if( (unsigned) aItemIdx < DIM(m_ItemsColors) )
|
||||
{
|
||||
@ -146,7 +145,7 @@ void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor )
|
||||
}
|
||||
|
||||
|
||||
void COLORS_DESIGN_SETTINGS::SetAllColorsAs( EDA_COLOR_T aColor )
|
||||
void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor )
|
||||
{
|
||||
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
|
||||
m_LayersColors[ii] = aColor;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <colors_selection.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <bitmaps.h>
|
||||
#include <colors.h>
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/ownerdrw.h>
|
||||
@ -56,7 +55,7 @@ void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
|
||||
|
||||
// Prepare Bitmap
|
||||
bmpDC.SelectObject( aLayerbmp );
|
||||
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
|
||||
brush.SetColour( GetLayerColor( aLayer ).ToColour() );
|
||||
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
||||
|
||||
bmpDC.SetBrush( brush );
|
||||
|
@ -42,6 +42,8 @@
|
||||
|
||||
#include <pgm_base.h>
|
||||
|
||||
using KIGFX::COLOR4D;
|
||||
|
||||
|
||||
/**
|
||||
* Global variables definitions.
|
||||
@ -53,7 +55,7 @@
|
||||
|
||||
bool g_ShowPageLimits = true;
|
||||
EDA_UNITS_T g_UserUnit;
|
||||
EDA_COLOR_T g_GhostColor;
|
||||
COLOR4D g_GhostColor;
|
||||
|
||||
|
||||
/* Class LOCALE_IO
|
||||
|
@ -25,6 +25,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <trigo.h>
|
||||
@ -68,7 +69,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
|
||||
SetDefaultLineWidth( 0 ); // No line width on DXF
|
||||
m_plotMirror = false; // No mirroring on DXF
|
||||
m_currentColor = BLACK;
|
||||
m_currentColor = COLOR4D_BLACK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,17 +276,17 @@ bool DXF_PLOTTER::EndPlot()
|
||||
/**
|
||||
* The DXF exporter handles 'colors' as layers...
|
||||
*/
|
||||
void DXF_PLOTTER::SetColor( EDA_COLOR_T color )
|
||||
void DXF_PLOTTER::SetColor( COLOR4D color )
|
||||
{
|
||||
wxASSERT( outputFile );
|
||||
if( ( color >= 0 && colorMode )
|
||||
|| ( color == BLACK )
|
||||
|| ( color == WHITE ) )
|
||||
if( ( colorMode )
|
||||
|| ( color == COLOR4D_BLACK )
|
||||
|| ( color == COLOR4D_WHITE ) )
|
||||
{
|
||||
m_currentColor = color;
|
||||
}
|
||||
else
|
||||
m_currentColor = BLACK;
|
||||
m_currentColor = COLOR4D_BLACK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,14 +316,16 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int
|
||||
DPOINT centre_dev = userToDeviceCoordinates( centre );
|
||||
if( radius > 0 )
|
||||
{
|
||||
wxString cname( ColorGetName( m_currentColor ) );
|
||||
if (!fill)
|
||||
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
|
||||
|
||||
if( !fill )
|
||||
{
|
||||
fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
|
||||
TO_UTF8( cname ),
|
||||
centre_dev.x, centre_dev.y, radius );
|
||||
}
|
||||
if (fill == FILLED_SHAPE)
|
||||
|
||||
if( fill == FILLED_SHAPE )
|
||||
{
|
||||
double r = radius*0.5;
|
||||
fprintf( outputFile, "0\nPOLYLINE\n");
|
||||
@ -462,7 +465,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
|
||||
if( penLastpos != pos && plume == 'D' )
|
||||
{
|
||||
// DXF LINE
|
||||
wxString cname( ColorGetName( m_currentColor ) );
|
||||
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
|
||||
fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
|
||||
TO_UTF8( cname ),
|
||||
pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
|
||||
@ -509,7 +512,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
|
||||
double radius_dev = userToDeviceSize( radius );
|
||||
|
||||
// Emit a DXF ARC entity
|
||||
wxString cname( ColorGetName( m_currentColor ) );
|
||||
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
|
||||
fprintf( outputFile,
|
||||
"0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
|
||||
TO_UTF8( cname ),
|
||||
@ -699,7 +702,7 @@ bool containsNonAsciiChars( const wxString& string )
|
||||
}
|
||||
|
||||
void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
enum EDA_COLOR_T aColor,
|
||||
COLOR4D aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
@ -729,7 +732,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos,
|
||||
more useful as a CAD object */
|
||||
DPOINT origin_dev = userToDeviceCoordinates( aPos );
|
||||
SetColor( aColor );
|
||||
wxString cname( ColorGetName( m_currentColor ) );
|
||||
wxString cname( m_currentColor.ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
|
||||
DPOINT size_dev = userToDeviceSize( aSize );
|
||||
int h_code = 0, v_code = 0;
|
||||
switch( aH_justify )
|
||||
|
@ -938,7 +938,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCo
|
||||
}
|
||||
|
||||
|
||||
void GERBER_PLOTTER::Text( const wxPoint& aPos, enum EDA_COLOR_T aColor,
|
||||
void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D aColor,
|
||||
const wxString& aText, double aOrient, const wxSize& aSize,
|
||||
enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
||||
int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed,
|
||||
|
@ -755,7 +755,7 @@ bool PDF_PLOTTER::EndPlot()
|
||||
}
|
||||
|
||||
void PDF_PLOTTER::Text( const wxPoint& aPos,
|
||||
enum EDA_COLOR_T aColor,
|
||||
const COLOR4D aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
|
@ -56,21 +56,14 @@ void PSLIKE_PLOTTER::SetDefaultLineWidth( int width )
|
||||
}
|
||||
|
||||
|
||||
void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
|
||||
void PSLIKE_PLOTTER::SetColor( COLOR4D color )
|
||||
{
|
||||
// Return at invalid color index
|
||||
if( color < 0 )
|
||||
return;
|
||||
|
||||
if( colorMode )
|
||||
{
|
||||
double r = g_ColorRefs[color].m_Red / 255.0;
|
||||
double g = g_ColorRefs[color].m_Green / 255.0;
|
||||
double b = g_ColorRefs[color].m_Blue / 255.0;
|
||||
if( negativeMode )
|
||||
emitSetRGBColor( 1 - r, 1 - g, 1 - b );
|
||||
emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b );
|
||||
else
|
||||
emitSetRGBColor( r, g, b );
|
||||
emitSetRGBColor( color.r, color.g, color.b );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -79,7 +72,7 @@ void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
|
||||
* holes in white on pads in black
|
||||
*/
|
||||
double k = 1; // White
|
||||
if( color != WHITE )
|
||||
if( color != COLOR4D_WHITE )
|
||||
k = 0;
|
||||
if( negativeMode )
|
||||
emitSetRGBColor( 1 - k, 1 - k, 1 - k );
|
||||
@ -927,7 +920,7 @@ bool PS_PLOTTER::EndPlot()
|
||||
|
||||
|
||||
void PS_PLOTTER::Text( const wxPoint& aPos,
|
||||
enum EDA_COLOR_T aColor,
|
||||
const COLOR4D aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
|
@ -187,7 +187,7 @@ void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
|
||||
}
|
||||
|
||||
|
||||
void SVG_PLOTTER::SetColor( EDA_COLOR_T color )
|
||||
void SVG_PLOTTER::SetColor( COLOR4D color )
|
||||
{
|
||||
PSLIKE_PLOTTER::SetColor( color );
|
||||
|
||||
@ -602,7 +602,7 @@ bool SVG_PLOTTER::EndPlot()
|
||||
|
||||
|
||||
void SVG_PLOTTER::Text( const wxPoint& aPos,
|
||||
enum EDA_COLOR_T aColor,
|
||||
const COLOR4D aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
|
@ -79,7 +79,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
|
||||
*/
|
||||
double iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
|
||||
|
||||
EDA_COLOR_T plotColor = plotter->GetColorMode() ? RED : BLACK;
|
||||
COLOR4D plotColor = plotter->GetColorMode() ? COLOR4D( RED ) : COLOR4D_BLACK;
|
||||
plotter->SetColor( plotColor );
|
||||
WS_DRAW_ITEM_LIST drawList;
|
||||
|
||||
|
@ -243,8 +243,8 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
|
||||
}
|
||||
|
||||
|
||||
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
|
||||
EDA_COLOR_T default_val,
|
||||
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam,
|
||||
COLOR4D default_val,
|
||||
const wxChar* group ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
|
||||
{
|
||||
@ -255,8 +255,8 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptpa
|
||||
|
||||
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
|
||||
const wxString& ident,
|
||||
EDA_COLOR_T* ptparam,
|
||||
EDA_COLOR_T default_val,
|
||||
COLOR4D* ptparam,
|
||||
COLOR4D default_val,
|
||||
const wxChar* group ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
|
||||
{
|
||||
@ -271,11 +271,22 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
|
||||
if( !m_Pt_param || !aConfig )
|
||||
return;
|
||||
|
||||
EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT("NONE") ) );
|
||||
// First try reading old format
|
||||
EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT( "NONE" ) ) );
|
||||
COLOR4D wtmp = UNSPECIFIED_COLOR4D;
|
||||
|
||||
if( itmp == UNSPECIFIED_COLOR )
|
||||
itmp = m_Default;
|
||||
*m_Pt_param = itmp;
|
||||
{
|
||||
// Next try reading new format
|
||||
if( !wtmp.SetFromWxString( aConfig->Read( m_Ident, wxT( "NONE" ) ) ) )
|
||||
wtmp = m_Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
wtmp = COLOR4D( itmp );
|
||||
}
|
||||
|
||||
*m_Pt_param = wtmp;
|
||||
}
|
||||
|
||||
|
||||
@ -284,7 +295,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
|
||||
if( !m_Pt_param || !aConfig )
|
||||
return;
|
||||
|
||||
aConfig->Write( m_Ident, ColorGetName( *m_Pt_param ) );
|
||||
aConfig->Write( m_Ident, m_Pt_param->ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,10 +157,10 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||
m_cursorShape = 0;
|
||||
m_LastGridSizeId = 0;
|
||||
m_drawGrid = true; // hide/Show grid. default = show
|
||||
m_gridColor = DARKGRAY; // Default grid color
|
||||
m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
|
||||
m_showPageLimits = false;
|
||||
m_drawBgColor = BLACK; // the background color of the draw canvas:
|
||||
// BLACK for Pcbnew, BLACK or WHITE for eeschema
|
||||
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
|
||||
// BLACK for Pcbnew, BLACK or WHITE for eeschema
|
||||
m_snapToGrid = true;
|
||||
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
|
||||
m_movingCursorWithKeyboard = false;
|
||||
@ -210,7 +210,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
||||
m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
|
||||
wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
|
||||
|
||||
m_messagePanel->SetBackgroundColour( MakeColour( LIGHTGRAY ) );
|
||||
m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
|
||||
}
|
||||
|
||||
|
||||
@ -728,7 +728,8 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||
|
||||
aCfg->Write( baseCfgName + CursorShapeEntryKeyword, m_cursorShape );
|
||||
aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
|
||||
aCfg->Write( baseCfgName + GridColorEntryKeyword, ( long ) GetGridColor() );
|
||||
aCfg->Write( baseCfgName + GridColorEntryKeyword,
|
||||
GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
|
||||
aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
|
||||
|
||||
if( GetScreen() )
|
||||
@ -740,7 +741,7 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||
|
||||
void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
|
||||
const wxString& textLower,
|
||||
EDA_COLOR_T color, int pad )
|
||||
COLOR4D color, int pad )
|
||||
{
|
||||
if( m_messagePanel == NULL )
|
||||
return;
|
||||
|
@ -109,7 +109,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
|
||||
|
||||
SetLayoutDirection( wxLayout_LeftToRight );
|
||||
|
||||
SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
|
||||
SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
|
||||
|
||||
#if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
|
||||
SetBackgroundStyle( wxBG_STYLE_CUSTOM );
|
||||
@ -212,7 +212,7 @@ wxPoint EDA_DRAW_PANEL::ToLogicalXY( const wxPoint& pos )
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
|
||||
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, COLOR4D aColor )
|
||||
{
|
||||
if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
|
||||
return;
|
||||
@ -554,7 +554,7 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
|
||||
{
|
||||
GRSetDrawMode( DC, GR_COPY );
|
||||
|
||||
EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
|
||||
COLOR4D bgColor = GetParent()->GetDrawBgColor();
|
||||
|
||||
GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
|
||||
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
|
||||
@ -611,12 +611,10 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
|
||||
if( Screen == NULL )
|
||||
return;
|
||||
|
||||
EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
|
||||
COLOR4D bgColor = GetParent()->GetDrawBgColor();
|
||||
|
||||
if( ( bgColor != WHITE ) && ( bgColor != BLACK ) )
|
||||
bgColor = BLACK;
|
||||
|
||||
if( bgColor == WHITE )
|
||||
// TODO(JE): Is this correct?
|
||||
if( bgColor.GetBrightness() > 0.5 )
|
||||
{
|
||||
g_XorMode = GR_NXOR;
|
||||
g_GhostColor = BLACK;
|
||||
@ -629,7 +627,7 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
|
||||
|
||||
GRResetPenAndBrush( DC );
|
||||
|
||||
DC->SetBackground( bgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
|
||||
DC->SetBackground( wxBrush( bgColor.ToColour() ) );
|
||||
DC->SetBackgroundMode( wxSOLID );
|
||||
|
||||
if( erasebg )
|
||||
@ -666,7 +664,7 @@ void EDA_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable )
|
||||
|
||||
void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC )
|
||||
{
|
||||
EDA_COLOR_T axis_color = BLUE;
|
||||
COLOR4D axis_color = COLOR4D( BLUE );
|
||||
|
||||
GRSetDrawMode( DC, GR_COPY );
|
||||
|
||||
@ -756,7 +754,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
|
||||
const double h = aDC->DeviceToLogicalYRel( gsz );
|
||||
|
||||
// Use our own pen
|
||||
wxPen pen( MakeColour( GetParent()->GetGridColor() ), h );
|
||||
wxPen pen( GetParent()->GetGridColor(), h );
|
||||
pen.SetCap( wxCAP_BUTT );
|
||||
gc->SetPen( pen );
|
||||
|
||||
@ -801,7 +799,7 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
|
||||
if( origin == wxPoint( 0, 0 ) )
|
||||
return;
|
||||
|
||||
EDA_COLOR_T color = RED;
|
||||
COLOR4D color = COLOR4D( RED );
|
||||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
@ -837,7 +835,7 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoi
|
||||
if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) )
|
||||
return;
|
||||
|
||||
EDA_COLOR_T color = GetParent()->GetGridColor();
|
||||
COLOR4D color = GetParent()->GetGridColor();
|
||||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
|
@ -103,7 +103,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
|
||||
* @param aClipBox = the clipping rect, or NULL if no clipping
|
||||
* @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas
|
||||
* @param aPos = text position (according to h_justify, v_justify)
|
||||
* @param aColor (enum EDA_COLOR_T) = text color
|
||||
* @param aColor (COLOR4D) = text color
|
||||
* @param aText = text to draw
|
||||
* @param aOrient = angle in 0.1 degree
|
||||
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
|
||||
@ -122,7 +122,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
|
||||
void DrawGraphicText( EDA_RECT* aClipBox,
|
||||
wxDC* aDC,
|
||||
const wxPoint& aPos,
|
||||
EDA_COLOR_T aColor,
|
||||
COLOR4D aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
@ -175,9 +175,9 @@ void DrawGraphicText( EDA_RECT* aClipBox,
|
||||
|
||||
void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
|
||||
const wxPoint &aPos,
|
||||
enum EDA_COLOR_T aBgColor,
|
||||
enum EDA_COLOR_T aColor1,
|
||||
enum EDA_COLOR_T aColor2,
|
||||
const COLOR4D aBgColor,
|
||||
COLOR4D aColor1,
|
||||
COLOR4D aColor2,
|
||||
const wxString &aText,
|
||||
double aOrient,
|
||||
const wxSize &aSize,
|
||||
@ -188,9 +188,10 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
|
||||
PLOTTER * aPlotter )
|
||||
{
|
||||
// Swap color if contrast would be better
|
||||
if( ColorIsLight( aBgColor ) )
|
||||
// TODO: Maybe calculate contrast some way other than brightness
|
||||
if( aBgColor.GetBrightness() > 0.5 )
|
||||
{
|
||||
EDA_COLOR_T c = aColor1;
|
||||
COLOR4D c = aColor1;
|
||||
aColor1 = aColor2;
|
||||
aColor2 = c;
|
||||
}
|
||||
@ -210,7 +211,7 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
|
||||
* Function PLOTTER::Text
|
||||
* same as DrawGraphicText, but plot graphic text insteed of draw it
|
||||
* @param aPos = text position (according to aH_justify, aV_justify)
|
||||
* @param aColor (enum EDA_COLOR_T) = text color
|
||||
* @param aColor (COLOR4D) = text color
|
||||
* @param aText = text to draw
|
||||
* @param aOrient = angle in 0.1 degree
|
||||
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
|
||||
@ -224,7 +225,7 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
|
||||
* @param aMultilineAllowed = true to plot text as multiline, otherwise single line
|
||||
*/
|
||||
void PLOTTER::Text( const wxPoint& aPos,
|
||||
enum EDA_COLOR_T aColor,
|
||||
const COLOR4D aColor,
|
||||
const wxString& aText,
|
||||
double aOrient,
|
||||
const wxSize& aSize,
|
||||
@ -248,8 +249,7 @@ void PLOTTER::Text( const wxPoint& aPos,
|
||||
|
||||
SetCurrentLineWidth( textPensize, aData );
|
||||
|
||||
if( aColor >= 0 )
|
||||
SetColor( aColor );
|
||||
SetColor( aColor );
|
||||
|
||||
DrawGraphicText( NULL, NULL, aPos, aColor, aText,
|
||||
aOrient, aSize,
|
||||
|
@ -289,8 +289,8 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
|
||||
|
||||
|
||||
void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
|
||||
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
|
||||
EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
|
||||
COLOR4D aColor, GR_DRAWMODE aDrawMode,
|
||||
EDA_DRAW_MODE_T aFillMode, COLOR4D aAnchor_color )
|
||||
{
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
@ -314,7 +314,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
|
||||
aDrawMode, aFillMode, GetShownText(), GetTextPos() );
|
||||
|
||||
// Draw text anchor, if requested
|
||||
if( aAnchor_color != UNSPECIFIED_COLOR )
|
||||
if( aAnchor_color != UNSPECIFIED_COLOR4D )
|
||||
{
|
||||
GRDrawAnchor( aClipBox, aDC,
|
||||
GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y,
|
||||
@ -366,7 +366,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
|
||||
}
|
||||
|
||||
void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
|
||||
const wxPoint& aOffset, EDA_COLOR_T aColor,
|
||||
const wxPoint& aOffset, COLOR4D aColor,
|
||||
GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
|
||||
const wxString& aText, const wxPoint &aPos )
|
||||
{
|
||||
@ -511,7 +511,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
|
||||
size.x = -size.x;
|
||||
|
||||
s_cornerBuffer = &aCornerBuffer;
|
||||
EDA_COLOR_T color = BLACK; // not actually used, but needed by DrawGraphicText
|
||||
COLOR4D color = COLOR4D_BLACK; // not actually used, but needed by DrawGraphicText
|
||||
|
||||
if( IsMultilineAllowed() )
|
||||
{
|
||||
|
@ -24,6 +24,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <gal/color4d.h>
|
||||
|
||||
using namespace KIGFX;
|
||||
@ -40,23 +42,251 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
|
||||
#ifdef WX_COMPATIBILITY
|
||||
COLOR4D::COLOR4D( const wxColour& aColor )
|
||||
{
|
||||
r = aColor.Red();
|
||||
g = aColor.Green();
|
||||
b = aColor.Blue();
|
||||
a = aColor.Alpha();
|
||||
r = aColor.Red() / 255.0;
|
||||
g = aColor.Green() / 255.0;
|
||||
b = aColor.Blue() / 255.0;
|
||||
a = aColor.Alpha() / 255.0;
|
||||
}
|
||||
|
||||
|
||||
bool COLOR4D::SetFromWxString( const wxString& aColorString )
|
||||
{
|
||||
wxColour c;
|
||||
|
||||
if( c.Set( aColorString ) )
|
||||
{
|
||||
r = c.Red() / 255.0;
|
||||
g = c.Green() / 255.0;
|
||||
b = c.Blue() / 255.0;
|
||||
a = c.Alpha() / 255.0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
wxString COLOR4D::ToWxString( long flags )
|
||||
{
|
||||
wxColour c = ToColour();
|
||||
return c.GetAsString( flags );
|
||||
}
|
||||
|
||||
|
||||
COLOR4D COLOR4D::LegacyMix( COLOR4D aColor ) const
|
||||
{
|
||||
/* Memoization storage. This could be potentially called for each
|
||||
* color merge so a cache is useful (there are few colours anyway) */
|
||||
static std::map< std::pair< uint32_t, uint32_t >, uint32_t > mix_cache;
|
||||
|
||||
// First easy thing: a black gives always the other colour
|
||||
if( *this == COLOR4D_BLACK )
|
||||
return aColor;
|
||||
|
||||
if( aColor == COLOR4D_BLACK )
|
||||
return *this;
|
||||
|
||||
uint32_t myPackedColor = ToU32();
|
||||
uint32_t aPackedColor = aColor.ToU32();
|
||||
|
||||
/* Now we are sure that black can't occur, so the rule is:
|
||||
* BLACK means not computed yet. If we're lucky we already have
|
||||
* an answer */
|
||||
auto search = mix_cache.find( std::pair< uint32_t, uint32_t >( myPackedColor,
|
||||
aPackedColor ) );
|
||||
COLOR4D candidate = COLOR4D_BLACK;
|
||||
if( search != mix_cache.end() )
|
||||
candidate.FromU32( search->second );
|
||||
|
||||
if( candidate != COLOR4D_BLACK )
|
||||
return candidate;
|
||||
|
||||
// Blend the two colors (i.e. OR the RGB values)
|
||||
COLOR4D mixed( ( (uint8_t)( 255.0 * this->r ) | (uint8_t)( 255.0 * aColor.r ) ) / 255.0,
|
||||
( (uint8_t)( 255.0 * this->g ) | (uint8_t)( 255.0 * aColor.g ) ) / 255.0,
|
||||
( (uint8_t)( 255.0 * this->b ) | (uint8_t)( 255.0 * aColor.b ) ) / 255.0,
|
||||
1.0 );
|
||||
candidate = mixed;
|
||||
|
||||
/* Here, BLACK is *not* a good answer, since it would recompute the next time.
|
||||
* Even theorically its not possible (with the current rules), but
|
||||
* maybe the metric will change in the future */
|
||||
if( candidate == COLOR4D_BLACK )
|
||||
candidate = COLOR4D( DARKDARKGRAY );
|
||||
|
||||
// Store the result in the cache. The operation is commutative, too
|
||||
mix_cache.insert( std::pair< std::pair< uint32_t, uint32_t >, uint32_t >
|
||||
( std::pair< uint32_t, uint32_t >( myPackedColor, aPackedColor ),
|
||||
candidate.ToU32() ) );
|
||||
mix_cache.insert( std::pair< std::pair< uint32_t, uint32_t >, uint32_t >
|
||||
( std::pair< uint32_t, uint32_t >( aPackedColor, myPackedColor ),
|
||||
candidate.ToU32() ) );
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
|
||||
COLOR4D& COLOR4D::SetToLegacyHighlightColor()
|
||||
{
|
||||
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
|
||||
EDA_COLOR_T highlightColor = g_ColorRefs[legacyColor].m_LightColor;
|
||||
|
||||
r = g_ColorRefs[highlightColor].m_Red / 255.0;
|
||||
g = g_ColorRefs[highlightColor].m_Green / 255.0;
|
||||
b = g_ColorRefs[highlightColor].m_Blue / 255.0;
|
||||
a = 1.0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
COLOR4D& COLOR4D::SetToNearestLegacyColor()
|
||||
{
|
||||
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
|
||||
|
||||
r = g_ColorRefs[legacyColor].m_Red / 255.0;
|
||||
g = g_ColorRefs[legacyColor].m_Green / 255.0;
|
||||
b = g_ColorRefs[legacyColor].m_Blue / 255.0;
|
||||
a = 1.0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
unsigned int COLOR4D::ToU32() const
|
||||
{
|
||||
return ToColour().GetRGB();
|
||||
}
|
||||
|
||||
|
||||
void COLOR4D::FromU32( unsigned int aPackedColor )
|
||||
{
|
||||
wxColour c;
|
||||
c.SetRGB( aPackedColor );
|
||||
r = c.Red();
|
||||
g = c.Green();
|
||||
b = c.Blue();
|
||||
a = c.Alpha();
|
||||
}
|
||||
|
||||
|
||||
EDA_COLOR_T COLOR4D::GetNearestLegacyColor( COLOR4D &aColor )
|
||||
{
|
||||
// Cache layer implemented here, because all callers are using wxColour
|
||||
static std::map< unsigned int, unsigned int > nearestCache;
|
||||
static double hues[NBCOLORS];
|
||||
static double values[NBCOLORS];
|
||||
|
||||
unsigned int colorInt = aColor.ToU32();
|
||||
|
||||
auto search = nearestCache.find( colorInt );
|
||||
|
||||
if( search != nearestCache.end() )
|
||||
return static_cast<EDA_COLOR_T>( search->second );
|
||||
|
||||
// First use ColorFindNearest to check for exact matches
|
||||
EDA_COLOR_T nearest = ColorFindNearest( aColor.r * 255.0, aColor.g * 255.0, aColor.b * 255.0 );
|
||||
|
||||
if( COLOR4D( nearest ) == aColor )
|
||||
{
|
||||
nearestCache.insert( std::pair< unsigned int, unsigned int >(
|
||||
colorInt, static_cast<unsigned int>( nearest ) ) );
|
||||
return nearest;
|
||||
}
|
||||
|
||||
// If not, use hue and value to match.
|
||||
// Hue will be NAN for grayscale colors.
|
||||
// The legacy color palette is a grid across hue and value.
|
||||
// We can exploit that to find a good match -- hue is most apparent to the user.
|
||||
// So, first we determine the closest hue match, and then the closest value from that
|
||||
// "grid row" in the legacy palette.
|
||||
|
||||
double h, s, v;
|
||||
aColor.ToHSV( h, s, v );
|
||||
|
||||
double minDist = 360.0;
|
||||
double legacyHue = 0.0;
|
||||
|
||||
if( std::isnan( h ) )
|
||||
{
|
||||
legacyHue = NAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( EDA_COLOR_T candidate = BLACK; candidate < NBCOLORS; candidate = NextColor(candidate) )
|
||||
{
|
||||
double ch, cs, cv;
|
||||
|
||||
if( hues[candidate] == 0.0 && values[candidate] == 0.0 )
|
||||
{
|
||||
COLOR4D candidate4d( candidate );
|
||||
|
||||
candidate4d.ToHSV( ch, cs, cv );
|
||||
|
||||
values[candidate] = cv;
|
||||
// Set the hue to non-zero for black so that we won't do this more than once
|
||||
hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = hues[candidate];
|
||||
cv = values[candidate];
|
||||
cv = 0.0;
|
||||
}
|
||||
|
||||
if( fabs( ch - h ) < minDist )
|
||||
{
|
||||
minDist = fabs( ch - h );
|
||||
legacyHue = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have the desired hue; let's find the nearest value
|
||||
minDist = 1.0;
|
||||
for( EDA_COLOR_T candidate = BLACK; candidate < NBCOLORS; candidate = NextColor(candidate) )
|
||||
{
|
||||
// If the target hue is NAN, we didn't extract the value for any colors above
|
||||
if( std::isnan( legacyHue ) )
|
||||
{
|
||||
double ch, cs, cv;
|
||||
COLOR4D candidate4d( candidate );
|
||||
candidate4d.ToHSV( ch, cs, cv );
|
||||
values[candidate] = cv;
|
||||
hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch;
|
||||
}
|
||||
|
||||
if( ( std::isnan( legacyHue ) != std::isnan( hues[candidate] ) ) || hues[candidate] != legacyHue )
|
||||
continue;
|
||||
|
||||
if( fabs( values[candidate] - v ) < minDist )
|
||||
{
|
||||
minDist = fabs( values[candidate] - v );
|
||||
nearest = candidate;
|
||||
}
|
||||
}
|
||||
|
||||
nearestCache.insert( std::pair< unsigned int, unsigned int >(
|
||||
colorInt, static_cast<unsigned int>( nearest ) ) );
|
||||
|
||||
return nearest;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace KIGFX {
|
||||
|
||||
const bool COLOR4D::operator==( const COLOR4D& aColor )
|
||||
const bool operator==( const COLOR4D& lhs, const COLOR4D& rhs )
|
||||
{
|
||||
return a == aColor.a && r == aColor.r && g == aColor.g && b == aColor.b;
|
||||
return lhs.a == rhs.a && lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b;
|
||||
}
|
||||
|
||||
|
||||
const bool COLOR4D::operator!=( const COLOR4D& aColor )
|
||||
const bool operator!=( const COLOR4D& lhs, const COLOR4D& rhs )
|
||||
{
|
||||
return a != aColor.a || r != aColor.r || g != aColor.g || b != aColor.b;
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ static void ClipAndDrawPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points[],
|
||||
* from user units to screen units(pixels coordinates)
|
||||
*/
|
||||
static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1,
|
||||
int x2, int y2, int aWidth, EDA_COLOR_T aColor,
|
||||
int x2, int y2, int aWidth, COLOR4D aColor,
|
||||
wxPenStyle aStyle = wxPENSTYLE_SOLID );
|
||||
|
||||
/**/
|
||||
@ -72,8 +72,8 @@ static int xcliplo = 0,
|
||||
xcliphi = 2000,
|
||||
ycliphi = 2000;
|
||||
|
||||
static EDA_COLOR_T s_DC_lastcolor = UNSPECIFIED_COLOR;
|
||||
static EDA_COLOR_T s_DC_lastbrushcolor = UNSPECIFIED_COLOR;
|
||||
static COLOR4D s_DC_lastcolor( 0, 0, 0, 0 );
|
||||
static COLOR4D s_DC_lastbrushcolor( 0, 0, 0, 0 );
|
||||
static bool s_DC_lastbrushfill = false;
|
||||
static wxDC* s_DC_lastDC = NULL;
|
||||
|
||||
@ -196,8 +196,8 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int
|
||||
void GRResetPenAndBrush( wxDC* DC )
|
||||
{
|
||||
GRSetBrush( DC, BLACK ); // Force no fill
|
||||
s_DC_lastbrushcolor = UNSPECIFIED_COLOR;
|
||||
s_DC_lastcolor = UNSPECIFIED_COLOR;
|
||||
s_DC_lastbrushcolor = UNSPECIFIED_COLOR4D;
|
||||
s_DC_lastcolor = UNSPECIFIED_COLOR4D;
|
||||
s_DC_lastDC = NULL;
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ void GRResetPenAndBrush( wxDC* DC )
|
||||
* Function GRSetColorPen
|
||||
* sets a pen style, width, color, and alpha into the given device context.
|
||||
*/
|
||||
void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
|
||||
void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
|
||||
{
|
||||
// Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
|
||||
// nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
|
||||
@ -214,17 +214,16 @@ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
|
||||
width = DC->DeviceToLogicalXRel( 1 );
|
||||
|
||||
if( s_ForceBlackPen )
|
||||
Color = BLACK;
|
||||
Color = COLOR4D_BLACK;
|
||||
|
||||
wxColour wx_color = MakeColour( Color );
|
||||
const wxPen& curr_pen = DC->GetPen();
|
||||
|
||||
if( !curr_pen.IsOk() || curr_pen.GetColour() != wx_color
|
||||
if( !curr_pen.IsOk() || curr_pen.GetColour() != Color.ToColour()
|
||||
|| curr_pen.GetWidth() != width
|
||||
|| curr_pen.GetStyle() != style )
|
||||
{
|
||||
wxPen pen;
|
||||
pen.SetColour( wx_color );
|
||||
pen.SetColour( Color.ToColour() );
|
||||
pen.SetWidth( width );
|
||||
pen.SetStyle( style );
|
||||
DC->SetPen( pen );
|
||||
@ -238,10 +237,10 @@ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
|
||||
}
|
||||
|
||||
|
||||
void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill )
|
||||
void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill )
|
||||
{
|
||||
if( s_ForceBlackPen )
|
||||
Color = BLACK;
|
||||
Color = COLOR4D_BLACK;
|
||||
|
||||
if( s_DC_lastbrushcolor != Color
|
||||
|| s_DC_lastbrushfill != fill
|
||||
@ -249,7 +248,7 @@ void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill )
|
||||
{
|
||||
wxBrush brush;
|
||||
|
||||
brush.SetColour( MakeColour( Color ) );
|
||||
brush.SetColour( Color.ToColour() );
|
||||
|
||||
if( fill )
|
||||
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
||||
@ -337,7 +336,7 @@ void GRSetDrawMode( wxDC* DC, GR_DRAWMODE draw_mode )
|
||||
}
|
||||
|
||||
|
||||
void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, EDA_COLOR_T Color )
|
||||
void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D Color )
|
||||
{
|
||||
if( ClipBox && !ClipBox->Contains( x, y ) )
|
||||
return;
|
||||
@ -357,7 +356,7 @@ void GRLine( EDA_RECT* ClipBox,
|
||||
int x2,
|
||||
int y2,
|
||||
int width,
|
||||
EDA_COLOR_T Color )
|
||||
COLOR4D Color )
|
||||
{
|
||||
GRSetColorPen( DC, Color, width );
|
||||
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
|
||||
@ -366,7 +365,7 @@ void GRLine( EDA_RECT* ClipBox,
|
||||
}
|
||||
|
||||
|
||||
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor )
|
||||
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor )
|
||||
{
|
||||
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
|
||||
}
|
||||
@ -374,14 +373,14 @@ void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aW
|
||||
|
||||
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC,
|
||||
int x1, int y1, int x2, int y2,
|
||||
int width, EDA_COLOR_T Color )
|
||||
int width, COLOR4D Color )
|
||||
{
|
||||
GRLastMoveToX = x2;
|
||||
GRLastMoveToY = y2;
|
||||
s_DC_lastcolor = UNSPECIFIED_COLOR;
|
||||
s_DC_lastcolor = UNSPECIFIED_COLOR4D;
|
||||
GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
|
||||
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
|
||||
s_DC_lastcolor = UNSPECIFIED_COLOR;
|
||||
s_DC_lastcolor = UNSPECIFIED_COLOR4D;
|
||||
GRSetColorPen( DC, Color, width );
|
||||
}
|
||||
|
||||
@ -399,14 +398,14 @@ void GRMoveTo( int x, int y )
|
||||
/*
|
||||
* Draw line to a new position, in object space.
|
||||
*/
|
||||
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color )
|
||||
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, COLOR4D Color )
|
||||
{
|
||||
GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
|
||||
}
|
||||
|
||||
|
||||
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, EDA_COLOR_T Color )
|
||||
int width, COLOR4D Color )
|
||||
{
|
||||
GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH );
|
||||
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
|
||||
@ -422,11 +421,11 @@ void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
* @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.
|
||||
* @param aColor = an index into our color table of RGB colors.
|
||||
* @see EDA_COLOR_T and colors.h
|
||||
* @param aColor = color to draw the lines
|
||||
* @see COLOR4D
|
||||
*/
|
||||
void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
|
||||
int aWidth, EDA_COLOR_T aColor )
|
||||
int aWidth, COLOR4D aColor )
|
||||
{
|
||||
if( aLines.empty() )
|
||||
return;
|
||||
@ -480,7 +479,7 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
|
||||
|
||||
// Draw the outline of a thick segment wih rounded ends
|
||||
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int aPenSize, EDA_COLOR_T Color )
|
||||
int width, int aPenSize, COLOR4D Color )
|
||||
{
|
||||
GRLastMoveToX = x2;
|
||||
GRLastMoveToY = y2;
|
||||
@ -566,14 +565,14 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
|
||||
|
||||
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, EDA_COLOR_T Color )
|
||||
int width, COLOR4D Color )
|
||||
{
|
||||
GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
|
||||
}
|
||||
|
||||
|
||||
void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
int aWidth, EDA_COLOR_T aColor )
|
||||
int aWidth, COLOR4D aColor )
|
||||
{
|
||||
GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
|
||||
}
|
||||
@ -583,7 +582,7 @@ void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
* Draw segment (full) with rounded ends in object space (real coords.).
|
||||
*/
|
||||
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, EDA_COLOR_T Color )
|
||||
int width, COLOR4D Color )
|
||||
{
|
||||
GRSetColorPen( DC, Color, width );
|
||||
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
|
||||
@ -591,7 +590,7 @@ void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
|
||||
|
||||
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
int aWidth, EDA_COLOR_T aColor )
|
||||
int aWidth, COLOR4D aColor )
|
||||
{
|
||||
GRSetColorPen( aDC, aColor, aWidth );
|
||||
WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
|
||||
@ -642,7 +641,7 @@ static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, wxPoint Points[] )
|
||||
*/
|
||||
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||
bool Fill, int width,
|
||||
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
|
||||
return;
|
||||
@ -701,8 +700,8 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
|
||||
int aPointCount, wxPoint aPoints[],
|
||||
bool aFill, int aWidth,
|
||||
EDA_COLOR_T aColor,
|
||||
EDA_COLOR_T aBgColor )
|
||||
COLOR4D aColor,
|
||||
COLOR4D aBgColor )
|
||||
{
|
||||
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
|
||||
return;
|
||||
@ -766,7 +765,7 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
|
||||
* Draw a new polyline and fill it if Fill, in drawing space.
|
||||
*/
|
||||
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||
bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
|
||||
}
|
||||
@ -776,20 +775,20 @@ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||
* Draw a closed polyline and fill it if Fill, in object space.
|
||||
*/
|
||||
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||
bool Fill, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
bool Fill, COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
|
||||
}
|
||||
|
||||
|
||||
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
|
||||
bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
|
||||
}
|
||||
|
||||
|
||||
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, EDA_COLOR_T Color )
|
||||
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, COLOR4D Color )
|
||||
{
|
||||
/* Clip circles off screen. */
|
||||
if( ClipBox )
|
||||
@ -819,20 +818,20 @@ void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, ED
|
||||
}
|
||||
|
||||
|
||||
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, EDA_COLOR_T Color )
|
||||
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, COLOR4D Color )
|
||||
{
|
||||
GRCircle( ClipBox, DC, x, y, r, 0, Color );
|
||||
}
|
||||
|
||||
|
||||
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, EDA_COLOR_T aColor )
|
||||
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor )
|
||||
{
|
||||
GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
|
||||
}
|
||||
|
||||
|
||||
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
|
||||
int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
int width, COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
/* Clip circles off screen. */
|
||||
if( ClipBox )
|
||||
@ -862,7 +861,7 @@ void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
|
||||
}
|
||||
|
||||
|
||||
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, EDA_COLOR_T aColor )
|
||||
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor )
|
||||
{
|
||||
GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
|
||||
}
|
||||
@ -872,7 +871,7 @@ void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, E
|
||||
* Draw an arc in user space.
|
||||
*/
|
||||
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int xc, int yc, EDA_COLOR_T Color )
|
||||
int xc, int yc, COLOR4D Color )
|
||||
{
|
||||
GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
|
||||
}
|
||||
@ -882,7 +881,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
* Draw an arc, width = width in user space.
|
||||
*/
|
||||
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int xc, int yc, int width, EDA_COLOR_T Color )
|
||||
int xc, int yc, int width, COLOR4D Color )
|
||||
{
|
||||
/* Clip arcs off screen. */
|
||||
if( ClipBox )
|
||||
@ -910,7 +909,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
|
||||
|
||||
void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
wxPoint aCenter, int aWidth, EDA_COLOR_T aColor )
|
||||
wxPoint aCenter, int aWidth, COLOR4D aColor )
|
||||
{
|
||||
GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
|
||||
aWidth, aColor );
|
||||
@ -928,8 +927,8 @@ void GRFilledArc( EDA_RECT* ClipBox,
|
||||
double EndAngle,
|
||||
int r,
|
||||
int width,
|
||||
EDA_COLOR_T Color,
|
||||
EDA_COLOR_T BgColor )
|
||||
COLOR4D Color,
|
||||
COLOR4D BgColor )
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
@ -971,7 +970,7 @@ void GRFilledArc( EDA_RECT* ClipBox,
|
||||
|
||||
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
|
||||
double StAngle, double EndAngle, int r,
|
||||
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
|
||||
}
|
||||
@ -981,7 +980,7 @@ void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
|
||||
* Draw an arc in drawing space.
|
||||
*/
|
||||
void GRArc( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, double StAngle,
|
||||
double EndAngle, int r, EDA_COLOR_T Color )
|
||||
double EndAngle, int r, COLOR4D Color )
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
@ -1032,7 +1031,7 @@ void GRArc( EDA_RECT* ClipBox,
|
||||
double EndAngle,
|
||||
int r,
|
||||
int width,
|
||||
EDA_COLOR_T Color )
|
||||
COLOR4D Color )
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
@ -1075,13 +1074,13 @@ void GRArc( EDA_RECT* ClipBox,
|
||||
/*
|
||||
* Draw a rectangle in drawing space.
|
||||
*/
|
||||
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, EDA_COLOR_T aColor )
|
||||
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, COLOR4D aColor )
|
||||
{
|
||||
GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
|
||||
}
|
||||
|
||||
|
||||
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T aColor, wxPenStyle aStyle )
|
||||
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, COLOR4D aColor, wxPenStyle aStyle )
|
||||
{
|
||||
int x1 = aRect.GetX();
|
||||
int y1 = aRect.GetY();
|
||||
@ -1095,13 +1094,13 @@ void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T
|
||||
/*
|
||||
* Draw a rectangle (thick lines) in drawing space.
|
||||
*/
|
||||
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color )
|
||||
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color )
|
||||
{
|
||||
GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
|
||||
}
|
||||
|
||||
|
||||
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, EDA_COLOR_T aColor )
|
||||
void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, COLOR4D aColor )
|
||||
{
|
||||
int x1 = aRect.GetX();
|
||||
int y1 = aRect.GetY();
|
||||
@ -1116,7 +1115,7 @@ void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, E
|
||||
* Draw a rectangle (filled with AreaColor) in drawing space.
|
||||
*/
|
||||
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
|
||||
}
|
||||
@ -1126,7 +1125,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
* Draw a rectangle (filled with AreaColor) in drawing space.
|
||||
*/
|
||||
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
|
||||
int width, COLOR4D Color, COLOR4D BgColor )
|
||||
{
|
||||
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
|
||||
}
|
||||
@ -1137,7 +1136,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
*/
|
||||
|
||||
void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
|
||||
int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle )
|
||||
int aWidth, COLOR4D aColor, wxPenStyle aStyle )
|
||||
{
|
||||
wxPoint points[5];
|
||||
points[0] = wxPoint(x1, y1);
|
||||
@ -1151,7 +1150,7 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
|
||||
|
||||
|
||||
void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
|
||||
int aWidth, EDA_COLOR_T aColor, EDA_COLOR_T aBgColor )
|
||||
int aWidth, COLOR4D aColor, COLOR4D aBgColor )
|
||||
{
|
||||
wxPoint points[5];
|
||||
points[0] = wxPoint(x1, y1);
|
||||
@ -1232,7 +1231,7 @@ void GRBezier( EDA_RECT* ClipBox,
|
||||
int x3,
|
||||
int y3,
|
||||
int width,
|
||||
EDA_COLOR_T Color )
|
||||
COLOR4D Color )
|
||||
{
|
||||
std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3 );
|
||||
GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
|
||||
@ -1250,7 +1249,7 @@ void GRBezier( EDA_RECT* ClipBox,
|
||||
int x4,
|
||||
int y4,
|
||||
int width,
|
||||
EDA_COLOR_T Color )
|
||||
COLOR4D Color )
|
||||
{
|
||||
std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 );
|
||||
GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
|
||||
@ -1258,7 +1257,7 @@ void GRBezier( EDA_RECT* ClipBox,
|
||||
|
||||
|
||||
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
|
||||
int aSize, EDA_COLOR_T aColor )
|
||||
int aSize, COLOR4D aColor )
|
||||
{
|
||||
int anchor_size = aDC->DeviceToLogicalXRel( aSize );
|
||||
|
||||
|
@ -109,7 +109,7 @@ void EDA_MSG_PANEL::OnPaint( wxPaintEvent& aEvent )
|
||||
|
||||
void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
|
||||
const wxString& aLowerText,
|
||||
EDA_COLOR_T aColor, int aPad )
|
||||
COLOR4D aColor, int aPad )
|
||||
{
|
||||
wxString text;
|
||||
wxSize drawSize = GetClientSize();
|
||||
@ -143,7 +143,7 @@ void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
|
||||
|
||||
|
||||
void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
|
||||
const wxString& aLowerText, EDA_COLOR_T aColor )
|
||||
const wxString& aLowerText, COLOR4D aColor )
|
||||
{
|
||||
wxPoint pos;
|
||||
wxSize drawSize = GetClientSize();
|
||||
@ -196,13 +196,9 @@ void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
|
||||
|
||||
void EDA_MSG_PANEL::showItem( wxDC& aDC, const MSG_PANEL_ITEM& aItem )
|
||||
{
|
||||
EDA_COLOR_T color = aItem.m_Color;
|
||||
COLOR4D color = aItem.m_Color;
|
||||
|
||||
if( color >= 0 )
|
||||
{
|
||||
color = ColorGetBase( color );
|
||||
aDC.SetTextForeground( MakeColour( color ) );
|
||||
}
|
||||
aDC.SetTextForeground( color.ToColour() );
|
||||
|
||||
if( !aItem.m_UpperText.IsEmpty() )
|
||||
{
|
||||
@ -230,7 +226,7 @@ void EDA_MSG_PANEL::erase( wxDC* aDC )
|
||||
wxBrush brush;
|
||||
|
||||
wxSize size = GetClientSize();
|
||||
wxColor color = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
|
||||
wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
|
||||
|
||||
pen.SetColour( color );
|
||||
|
||||
|
@ -61,6 +61,8 @@
|
||||
#include <worksheet_shape_builder.h>
|
||||
#include <class_worksheet_dataitem.h>
|
||||
|
||||
using KIGFX::COLOR4D;
|
||||
|
||||
|
||||
// Static members of class WORKSHEET_DATAITEM:
|
||||
double WORKSHEET_DATAITEM::m_WSunits2Iu = 1.0;
|
||||
@ -70,9 +72,9 @@ double WORKSHEET_DATAITEM::m_DefaultLineWidth = 0.0;
|
||||
DSIZE WORKSHEET_DATAITEM::m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
|
||||
double WORKSHEET_DATAITEM::m_DefaultTextThickness = 0.0;
|
||||
bool WORKSHEET_DATAITEM::m_SpecialMode = false;
|
||||
EDA_COLOR_T WORKSHEET_DATAITEM::m_Color = RED; // the default color to draw items
|
||||
EDA_COLOR_T WORKSHEET_DATAITEM::m_AltColor = RED; // an alternate color to draw items
|
||||
EDA_COLOR_T WORKSHEET_DATAITEM::m_SelectedColor = BROWN; // the color to draw selected items
|
||||
COLOR4D WORKSHEET_DATAITEM::m_Color = COLOR4D( RED ); // the default color to draw items
|
||||
COLOR4D WORKSHEET_DATAITEM::m_AltColor = COLOR4D( RED ); // an alternate color to draw items
|
||||
COLOR4D WORKSHEET_DATAITEM::m_SelectedColor = COLOR4D( BROWN ); // the color to draw selected items
|
||||
|
||||
|
||||
// The constructor:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user