diff --git a/3d-viewer/3d_draw_helper_functions.cpp b/3d-viewer/3d_draw_helper_functions.cpp index b2eaf87f18..71a1db6f6e 100644 --- a/3d-viewer/3d_draw_helper_functions.cpp +++ b/3d-viewer/3d_draw_helper_functions.cpp @@ -149,7 +149,7 @@ void EDA_3D_CANVAS::setGLTechLayersColor( LAYER_NUM aLayer ) { case B_Paste: case F_Paste: - SetGLColor( DARKGRAY, 0.7 ); + SetGLColor( GetPrm3DVisu().m_SolderPasteColor, 1 ); break; case B_SilkS: diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 7a243b34b4..9af2e3db1f 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -54,6 +54,10 @@ static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" ); static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" ); static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" ); +static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" ); +static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" ); +static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" ); + static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" ); static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" ); static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" ); @@ -248,17 +252,25 @@ void EDA_3D_FRAME::LoadSettings( wxConfigBase* aCfg ) aCfg->Read( keyBgColor_Green_Top, &GetPrm3DVisu().m_BgColor_Top.m_Green, 0.8 ); aCfg->Read( keyBgColor_Blue_Top, &GetPrm3DVisu().m_BgColor_Top.m_Blue, 0.9 ); - aCfg->Read( keySMaskColor_Red, &GetPrm3DVisu().m_SolderMaskColor.m_Red, 100.0*(0.2/255.0) ); - aCfg->Read( keySMaskColor_Green, &GetPrm3DVisu().m_SolderMaskColor.m_Green, 255.0*(0.2/255.0) ); - aCfg->Read( keySMaskColor_Blue, &GetPrm3DVisu().m_SolderMaskColor.m_Blue, 180.0*(0.2/255.0) ); + // m_SolderMaskColor default value = dark grey-green + aCfg->Read( keySMaskColor_Red, &GetPrm3DVisu().m_SolderMaskColor.m_Red, 100.0 * 0.2 / 255.0 ); + aCfg->Read( keySMaskColor_Green, &GetPrm3DVisu().m_SolderMaskColor.m_Green, 255.0 * 0.2 / 255.0 ); + aCfg->Read( keySMaskColor_Blue, &GetPrm3DVisu().m_SolderMaskColor.m_Blue, 180.0 * 0.2 / 255.0 ); + // m_SolderPasteColor default value = light grey + aCfg->Read( keySPasteColor_Red, &GetPrm3DVisu().m_SolderPasteColor.m_Red, 128.0 /255.0 ); + aCfg->Read( keySPasteColor_Green, &GetPrm3DVisu().m_SolderPasteColor.m_Green, 128.0 /255.0 ); + aCfg->Read( keySPasteColor_Blue, &GetPrm3DVisu().m_SolderPasteColor.m_Blue, 128.0 /255.0 ); + + // m_SilkScreenColor default value = white aCfg->Read( keySilkColor_Red, &GetPrm3DVisu().m_SilkScreenColor.m_Red, 0.9 ); aCfg->Read( keySilkColor_Green, &GetPrm3DVisu().m_SilkScreenColor.m_Green, 0.9 ); aCfg->Read( keySilkColor_Blue, &GetPrm3DVisu().m_SilkScreenColor.m_Blue, 0.9 ); - aCfg->Read( keyCopperColor_Red, &GetPrm3DVisu().m_CopperColor.m_Red, 255.0*(0.7/255.0) ); - aCfg->Read( keyCopperColor_Green, &GetPrm3DVisu().m_CopperColor.m_Green, 223.0*(0.7/255.0) ); - aCfg->Read( keyCopperColor_Blue, &GetPrm3DVisu().m_CopperColor.m_Blue, 0.0*(0.7/255.0) ); + // m_CopperColor default value = gold + aCfg->Read( keyCopperColor_Red, &GetPrm3DVisu().m_CopperColor.m_Red, 255.0 * 0.7 / 255.0 ); + aCfg->Read( keyCopperColor_Green, &GetPrm3DVisu().m_CopperColor.m_Green, 223.0 * 0.7 / 255.0 ); + aCfg->Read( keyCopperColor_Blue, &GetPrm3DVisu().m_CopperColor.m_Blue, 0.0 /255.0 ); bool tmp; aCfg->Read( keyShowRealisticMode, &tmp, false ); @@ -343,6 +355,10 @@ void EDA_3D_FRAME::SaveSettings( wxConfigBase* aCfg ) aCfg->Write( keySMaskColor_Green, GetPrm3DVisu().m_SolderMaskColor.m_Green ); aCfg->Write( keySMaskColor_Blue, GetPrm3DVisu().m_SolderMaskColor.m_Blue ); + aCfg->Write( keySPasteColor_Red, GetPrm3DVisu().m_SolderPasteColor.m_Red ); + aCfg->Write( keySPasteColor_Green, GetPrm3DVisu().m_SolderPasteColor.m_Green ); + aCfg->Write( keySPasteColor_Blue, GetPrm3DVisu().m_SolderPasteColor.m_Blue ); + aCfg->Write( keySilkColor_Red, GetPrm3DVisu().m_SilkScreenColor.m_Red ); aCfg->Write( keySilkColor_Green, GetPrm3DVisu().m_SilkScreenColor.m_Green ); aCfg->Write( keySilkColor_Blue, GetPrm3DVisu().m_SilkScreenColor.m_Blue ); @@ -506,12 +522,14 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->TakeScreenshot( event ); break; - case ID_MENU3D_BGCOLOR_SELECTION: - Get3DColorFromUser( GetPrm3DVisu().m_BgColor ); + case ID_MENU3D_BGCOLOR_BOTTOM_SELECTION: + if( Set3DColorFromUser( GetPrm3DVisu().m_BgColor ) ) + m_canvas->Refresh( true ); return; case ID_MENU3D_BGCOLOR_TOP_SELECTION: - Get3DColorFromUser( GetPrm3DVisu().m_BgColor_Top ); + if( Set3DColorFromUser( GetPrm3DVisu().m_BgColor_Top ) ) + m_canvas->Refresh( true ); return; case ID_MENU3D_SILKSCREEN_COLOR_SELECTION: @@ -519,7 +537,11 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) return; case ID_MENU3D_SOLDERMASK_COLOR_SELECTION: - Set3DSoldermaskColorFromUser(); + Set3DSolderMaskColorFromUser(); + return; + + case ID_MENU3D_SOLDERPASTE_COLOR_SELECTION: + Set3DSolderPasteColorFromUser(); return; case ID_MENU3D_COPPER_COLOR_SELECTION: @@ -708,26 +730,29 @@ void EDA_3D_FRAME::OnActivate( wxActivateEvent& event ) /* called to set the background color of the 3D scene */ -bool EDA_3D_FRAME::Get3DColorFromUser( S3D_COLOR &color ) +bool EDA_3D_FRAME::Set3DColorFromUser( S3D_COLOR &aColor, wxColourData* aPredefinedColors ) { - wxColour newcolor, oldcolor; + wxColour newcolor, oldcolor; - oldcolor.Set( KiROUND( color.m_Red * 255 ), - KiROUND( color.m_Green * 255 ), - KiROUND( color.m_Blue * 255 ) ); + oldcolor.Set( KiROUND( aColor.m_Red * 255 ), + KiROUND( aColor.m_Green * 255 ), + KiROUND( aColor.m_Blue * 255 ) ); - newcolor = wxGetColourFromUser( this, oldcolor ); + if( aPredefinedColors ) + newcolor = wxGetColourFromUser( this, oldcolor, wxEmptyString, aPredefinedColors ); + else + newcolor = wxGetColourFromUser( this, oldcolor ); if( !newcolor.IsOk() ) // Cancel command return false; if( newcolor != oldcolor ) { - color.m_Red = (double) newcolor.Red() / 255.0; - color.m_Green = (double) newcolor.Green() / 255.0; - color.m_Blue = (double) newcolor.Blue() / 255.0; - m_canvas->Redraw(); + aColor.m_Red = (double) newcolor.Red() / 255.0; + aColor.m_Green = (double) newcolor.Green() / 255.0; + aColor.m_Blue = (double) newcolor.Blue() / 255.0; } + return true; } @@ -735,67 +760,39 @@ bool EDA_3D_FRAME::Get3DColorFromUser( S3D_COLOR &color ) */ bool EDA_3D_FRAME::Set3DSilkScreenColorFromUser() { - S3D_COLOR& curr_3Dcolor = GetPrm3DVisu().m_SilkScreenColor; - wxColour oldcolor; - oldcolor.Set( KiROUND( curr_3Dcolor.m_Red * 255 ), - KiROUND( curr_3Dcolor.m_Green * 255 ), - KiROUND( curr_3Dcolor.m_Blue * 255 ) ); + wxColourData definedColors; - wxColourData colorData; + definedColors.SetCustomColour(0, wxColour(241, 241, 241)); // White + definedColors.SetCustomColour(1, wxColour(180, 180, 180 )); // Gray - colorData.SetCustomColour(0, wxColour(241, 241, 241)); // White - colorData.SetCustomColour(1, wxColour(180, 180, 180 )); // Gray + bool change = Set3DColorFromUser( GetPrm3DVisu().m_SilkScreenColor, &definedColors ); - wxColour newcolor = wxGetColourFromUser( this, oldcolor, wxEmptyString, &colorData); - - if( !newcolor.IsOk() ) // Cancel command - return false; - - if( newcolor != oldcolor ) - { - curr_3Dcolor.m_Red = (double) newcolor.Red() / 255.0; - curr_3Dcolor.m_Green = (double) newcolor.Green() / 255.0; - curr_3Dcolor.m_Blue = (double) newcolor.Blue() / 255.0; + if( change ) NewDisplay(GL_ID_TECH_LAYERS); - } - return true; + return change; } /* called to set the soldermask color. Sets up a number of default colors */ -bool EDA_3D_FRAME::Set3DSoldermaskColorFromUser() +bool EDA_3D_FRAME::Set3DSolderMaskColorFromUser() { - S3D_COLOR& curr_3Dcolor = GetPrm3DVisu().m_SolderMaskColor; - wxColour oldcolor; - oldcolor.Set( KiROUND( curr_3Dcolor.m_Red * 255 ), - KiROUND( curr_3Dcolor.m_Green * 255 ), - KiROUND( curr_3Dcolor.m_Blue * 255 ) ); + wxColourData definedColors; - wxColourData colorData; + definedColors.SetCustomColour(0, wxColour(20, 51, 36 )); // Green + definedColors.SetCustomColour(1, wxColour(43, 10, 65 )); // Purple + definedColors.SetCustomColour(2, wxColour(117, 19, 21 )); // Red + definedColors.SetCustomColour(3, wxColour(54, 79, 116)); // Light blue + definedColors.SetCustomColour(4, wxColour(11, 11, 11 )); // Black + definedColors.SetCustomColour(5, wxColour(241, 241,241)); // White - colorData.SetCustomColour(0, wxColour(20, 51, 36 )); // Green - colorData.SetCustomColour(1, wxColour(43, 10, 65 )); // Purple - colorData.SetCustomColour(2, wxColour(117, 19, 21 )); // Red - colorData.SetCustomColour(3, wxColour(54, 79, 116)); // Light blue - colorData.SetCustomColour(4, wxColour(11, 11, 11 )); // Black - colorData.SetCustomColour(5, wxColour(241, 241,241)); // White + bool change = Set3DColorFromUser( GetPrm3DVisu().m_SolderMaskColor, &definedColors ); - wxColour newcolor = wxGetColourFromUser( this, oldcolor, wxEmptyString, &colorData); - - if( !newcolor.IsOk() ) // Cancel command - return false; - - if( newcolor != oldcolor ) - { - curr_3Dcolor.m_Red = (double) newcolor.Red() / 255.0; - curr_3Dcolor.m_Green = (double) newcolor.Green() / 255.0; - curr_3Dcolor.m_Blue = (double) newcolor.Blue() / 255.0; + if( change ) NewDisplay(GL_ID_TECH_LAYERS); - } - return true; + return change; } @@ -803,32 +800,36 @@ bool EDA_3D_FRAME::Set3DSoldermaskColorFromUser() */ bool EDA_3D_FRAME::Set3DCopperColorFromUser() { - S3D_COLOR& curr_3Dcolor = GetPrm3DVisu().m_CopperColor; - wxColour oldcolor; - oldcolor.Set( KiROUND( curr_3Dcolor.m_Red * 255 ), - KiROUND( curr_3Dcolor.m_Green * 255 ), - KiROUND( curr_3Dcolor.m_Blue * 255 ) ); + wxColourData definedColors; - wxColourData colorData; + definedColors.SetCustomColour(0, wxColour(255, 223, 0 )); // Copper + definedColors.SetCustomColour(1, wxColour(233, 221, 82 )); // Gold + definedColors.SetCustomColour(2, wxColour(213, 213, 213)); // Silver - colorData.SetCustomColour(0, wxColour(255, 223, 0 )); // Copper - colorData.SetCustomColour(1, wxColour(233, 221, 82 )); // Gold - colorData.SetCustomColour(2, wxColour(213, 213, 213)); // Silver + bool change = Set3DColorFromUser( GetPrm3DVisu().m_CopperColor, &definedColors ); - wxColour newcolor = wxGetColourFromUser( this, oldcolor, wxEmptyString, &colorData); - - if( !newcolor.IsOk() ) // Cancel command - return false; - - if( newcolor != oldcolor ) - { - curr_3Dcolor.m_Red = (double) newcolor.Red() / 255.0; - curr_3Dcolor.m_Green = (double) newcolor.Green() / 255.0; - curr_3Dcolor.m_Blue = (double) newcolor.Blue() / 255.0; + if( change ) NewDisplay(GL_ID_TECH_LAYERS); - } - return true; + return change; +} + +/* called to set the solder paste layer color. Sets up a number of default colors + */ +bool EDA_3D_FRAME::Set3DSolderPasteColorFromUser() +{ + wxColourData definedColors; + + definedColors.SetCustomColour(0, wxColour(128, 128, 128 )); // grey + definedColors.SetCustomColour(1, wxColour(213, 213, 213)); // Silver + definedColors.SetCustomColour(2, wxColour(90, 90, 90)); // grey 2 + + bool change = Set3DColorFromUser( GetPrm3DVisu().m_SolderPasteColor, &definedColors ); + + if( change ) + NewDisplay(GL_ID_TECH_LAYERS); + + return change; } @@ -841,7 +842,7 @@ BOARD* EDA_3D_FRAME::GetBoard() INFO3D_VISU& EDA_3D_FRAME::GetPrm3DVisu() const { // return the INFO3D_VISU which contains the current parameters - // to draw the 3D view og the board + // to draw the 3D view of the board return g_Parm_3D_Visu; } diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp index 8224ceb42c..8765f48d65 100644 --- a/3d-viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_toolbar.cpp @@ -186,36 +186,33 @@ void EDA_3D_FRAME::CreateMenuBar() prefsMenu->AppendSeparator(); - wxMenu * backgrounColorMenu = new wxMenu; + // Add submenu set Colors + wxMenu * setColorMenu = new wxMenu; + AddMenuItem( prefsMenu, setColorMenu, ID_MENU3D_COLOR, + _( "Choose Colors" ), KiBitmap( palette_xpm ) ); - // Add submenu Choose Colors - AddMenuItem( prefsMenu, backgrounColorMenu, ID_MENU3D_COLOR, - _( "Choose Colors" ), KiBitmap( palette_xpm ) ); + wxMenu * setBgColorMenu = new wxMenu; + AddMenuItem( setColorMenu, setBgColorMenu, ID_MENU3D_BGCOLOR, + _( "Background Color" ), KiBitmap( palette_xpm ) ); - AddMenuItem( backgrounColorMenu, ID_MENU3D_BGCOLOR_TOP_SELECTION, + AddMenuItem( setBgColorMenu, ID_MENU3D_BGCOLOR_TOP_SELECTION, _( "Background Top Color" ), KiBitmap( setcolor_3d_bg_xpm ) ); - AddMenuItem( backgrounColorMenu, ID_MENU3D_BGCOLOR_SELECTION, + AddMenuItem( setBgColorMenu, ID_MENU3D_BGCOLOR_BOTTOM_SELECTION, _( "Background Bottom Color" ), KiBitmap( setcolor_3d_bg_xpm ) ); - AddMenuItem( backgrounColorMenu, ID_MENU3D_SILKSCREEN_COLOR_SELECTION, + AddMenuItem( setColorMenu, ID_MENU3D_SILKSCREEN_COLOR_SELECTION, _( "Silkscreen Color" ), KiBitmap( setcolor_silkscreen_xpm ) ); - AddMenuItem( backgrounColorMenu, ID_MENU3D_SOLDERMASK_COLOR_SELECTION, + AddMenuItem( setColorMenu, ID_MENU3D_SOLDERMASK_COLOR_SELECTION, _( "Solder Mask Color" ), KiBitmap( setcolor_soldermask_xpm ) ); - AddMenuItem( backgrounColorMenu, ID_MENU3D_COPPER_COLOR_SELECTION, + AddMenuItem( setColorMenu, ID_MENU3D_SOLDERPASTE_COLOR_SELECTION, + _( "Solder Paste Color" ), KiBitmap( setcolor_soldermask_xpm ) ); + + AddMenuItem( setColorMenu, ID_MENU3D_COPPER_COLOR_SELECTION, _( "Copper/Surface Finish Color" ), KiBitmap( setcolor_copper_xpm ) ); - AddMenuItem( backgrounColorMenu, ID_MENU3D_SILKSCREEN_COLOR_SELECTION, - _( "Silkscreen Color" ), KiBitmap( palette_xpm ) ); - - AddMenuItem( backgrounColorMenu, ID_MENU3D_SOLDERMASK_COLOR_SELECTION, - _( "Solder Mask Color" ), KiBitmap( palette_xpm ) ); - - AddMenuItem( backgrounColorMenu, ID_MENU3D_COPPER_COLOR_SELECTION, - _( "Copper/Surface Finish Color" ), KiBitmap( palette_xpm ) ); - AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF, _( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK ); diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index f0722fc974..7f131bd39f 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -50,6 +50,7 @@ class EDA_3D_CANVAS; class PCB_BASE_FRAME; +class wxColourData; #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS) @@ -146,20 +147,32 @@ private: void RedrawActiveWindow( wxDC* DC, bool EraseBg ); /** - * Function Get3DColorFromUser + * Function Set3DColorFromUser * Get a S3D_COLOR from a wx colour dialog + * @param aColor is the S3D_COLOR to change + * @param aPredefinedColors is a reference to a wxColourData + * which contains a few predefined colors + * if it is NULL, no predefined colors are used * @return true if a new color is chosen, false if * no change or aborted by user */ - bool Get3DColorFromUser( S3D_COLOR &color ); + bool Set3DColorFromUser( S3D_COLOR &aColor, wxColourData* aPredefinedColors = NULL ); /** - * Function Set3DSoldermaskColorFromUser + * Function Set3DSolderMaskColorFromUser * Set the solder mask color from a set of colors * @return true if a new color is chosen, false if * no change or aborted by user */ - bool Set3DSoldermaskColorFromUser(); + bool Set3DSolderMaskColorFromUser(); + + /** + * Function Set3DSolderPasteColorFromUser + * Set the solder mask color from a set of colors + * @return true if a new color is chosen, false if + * no change or aborted by user + */ + bool Set3DSolderPasteColorFromUser(); /** * Function Set3DCopperColorFromUser diff --git a/3d-viewer/3d_viewer_id.h b/3d-viewer/3d_viewer_id.h index 75c4c3f0f0..154053a6ca 100644 --- a/3d-viewer/3d_viewer_id.h +++ b/3d-viewer/3d_viewer_id.h @@ -31,10 +31,12 @@ enum id_3dview_frm ID_MOVE3D_DOWN, ID_ORTHO, ID_MENU3D_COLOR, - ID_MENU3D_BGCOLOR_SELECTION, + ID_MENU3D_BGCOLOR, + ID_MENU3D_BGCOLOR_BOTTOM_SELECTION, ID_MENU3D_BGCOLOR_TOP_SELECTION, ID_MENU3D_SILKSCREEN_COLOR_SELECTION, ID_MENU3D_SOLDERMASK_COLOR_SELECTION, + ID_MENU3D_SOLDERPASTE_COLOR_SELECTION, ID_MENU3D_COPPER_COLOR_SELECTION, ID_MENU3D_USE_COPPER_THICKNESS, ID_MENU3D_AXIS_ONOFF, diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h index e5f4d1c7fc..b1d8f4848c 100644 --- a/3d-viewer/info3d_visu.h +++ b/3d-viewer/info3d_visu.h @@ -96,6 +96,7 @@ public: S3D_COLOR m_BgColor_Top; S3D_COLOR m_BoardBodyColor; // in realistic mode: FR4 board color S3D_COLOR m_SolderMaskColor; // in realistic mode: solder mask color + S3D_COLOR m_SolderPasteColor; // in realistic mode: solder paste color S3D_COLOR m_SilkScreenColor; // in realistic mode: SilkScreen color S3D_COLOR m_CopperColor; // in realistic mode: copper color wxPoint m_BoardPos; // center board actual position in board units