From e62969d0079e6e86c71fd6349d5df673e49c26fa Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 26 Jul 2021 18:56:11 +0100 Subject: [PATCH] Move zone fracture display mode to AdvancedCfg, and add triangulation. Fixes https://gitlab.com/kicad/code/kicad/issues/8762 --- bitmaps_png/CMakeLists.txt | 1 + bitmaps_png/png/show_zone_outline_only_24.png | Bin 299 -> 318 bytes .../png/show_zone_outline_only_dark_24.png | Bin 309 -> 329 bytes .../png/show_zone_triangulation_24.png | Bin 0 -> 596 bytes .../png/show_zone_triangulation_dark_24.png | Bin 0 -> 607 bytes .../sources/dark/show_zone_outline_only.svg | 18 ++- .../sources/dark/show_zone_triangulation.svg | 141 ++++++++++++++++++ .../sources/light/show_zone_outline_only.svg | 25 +++- .../sources/light/show_zone_triangulation.svg | 139 +++++++++++++++++ common/advanced_config.cpp | 10 ++ common/gal/cairo/cairo_gal.cpp | 2 +- common/gal/opengl/opengl_gal.cpp | 14 +- common/hotkey_store.cpp | 11 +- common/project/project_local_settings.cpp | 2 +- include/advanced_config.h | 6 + include/bitmaps/bitmap_info.h | 2 + include/bitmaps/bitmaps_list.h | 1 + include/gal/cairo/cairo_gal.h | 2 +- include/gal/graphics_abstraction_layer.h | 2 +- include/gal/opengl/opengl_gal.h | 7 +- include/project/board_project_settings.h | 10 +- pcbnew/menubar_pcb_editor.cpp | 11 +- pcbnew/pcb_edit_frame.cpp | 10 +- pcbnew/pcb_painter.cpp | 7 +- pcbnew/pcbnew_settings.cpp | 2 +- pcbnew/toolbars_pcb_editor.cpp | 12 +- pcbnew/tools/pcb_actions.cpp | 19 ++- pcbnew/tools/pcb_actions.h | 7 +- pcbnew/tools/pcb_control.cpp | 25 ++-- 29 files changed, 426 insertions(+), 60 deletions(-) create mode 100644 bitmaps_png/png/show_zone_triangulation_24.png create mode 100644 bitmaps_png/png/show_zone_triangulation_dark_24.png create mode 100644 bitmaps_png/sources/dark/show_zone_triangulation.svg create mode 100644 bitmaps_png/sources/light/show_zone_triangulation.svg diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 7ba3680589..770c846979 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -435,6 +435,7 @@ set( BMAPS_MID show_zone show_zone_disable show_zone_outline_only + show_zone_triangulation show_all_layers show_no_layers show_no_copper_layers diff --git a/bitmaps_png/png/show_zone_outline_only_24.png b/bitmaps_png/png/show_zone_outline_only_24.png index 03e1a0f2178b8dae2d02324e27ff1e7a80150333..6853a0fbffc57cf57b7e9bdf7cbb8cdb45bc9d50 100644 GIT binary patch delta 184 zcmV;p07w6;0=@!}BLV>hktJ_`B+CN%=A-|mn~wZ}VY%j`KS99)l7kxj9~&mg2Qq!f zIAIvb|3sDr#O6vMe;+7vp%!?8EC~({egq6I52~bHU~2INs=XoCeprxZnM1nqNE=Z7 zP07Zi!Ac!x_{AHJib*vci2{l}z?n=*&9TxAhkbyC?gi@m49;jxN485VG##?XX%;y} m0!g7UYQf;JfSP#tG#UVJZYgUPzoGa50000X$BLV>OktJ_`q>2SV{%26IfY?xj|6{|HSn!D~3y95?K>j{ZL?`kRuCM}w6*&hU#j92JvlIuZpG zdw?^UlA2?s8xH#b4c!ZhbZ|y%I5x56v&bnDND7Tn3kHV;)WpLWr_lfaj+-6S Ts)oa=00000NkvXXu0mjf+SEq& diff --git a/bitmaps_png/png/show_zone_outline_only_dark_24.png b/bitmaps_png/png/show_zone_outline_only_dark_24.png index 7dadf889f0bf2539be3e05270b9686b1fbdf63ef..d29b082c725435bd11b6b5b1fa46b253e86595c0 100644 GIT binary patch delta 213 zcmV;`04o2r0?7i9BLV>sktJP!soTyM+%W98^VLD;oo@m_a(6G^^##jGyVAy}}yFZ{{0m*?32IBwNFxf!_|xw`Kk@5{-)!Om%%Q(-|+(@UksQ?C!&C24{#<^ zQgf{H&euM`w7(aq?=vW)0WH|>xb3w)PP51<5=aV-Q40o#1=PgDr_lfak&cPQn*5&Y P00000NkvXXu0mjfcXDa9 delta 193 zcmV;y06zc80<{8=BLV>YktJP!DT)QaU~%60CIG~~d-<+65I?zh`R?Nfm+p8{#R4Gz zGbmU>e~{2v>p#DY&`SwL*A1oHQRA{WF41q;-YNB6JZ@t{iDb=vvb7pV4z&6W>> zG|L>$J72W{)!%g7@iN$D_d9;KoiD_Iksk#Vdw?^UlA2?kcfR%krv1G%phyR0G@u3B v9k;!<$7vQhMFL5oF>1l!uz;F)_%s>-v3Yw8b`yNo00000NkvXXu0mjfG-FzA diff --git a/bitmaps_png/png/show_zone_triangulation_24.png b/bitmaps_png/png/show_zone_triangulation_24.png new file mode 100644 index 0000000000000000000000000000000000000000..d3ac81b1c3023a2acb737a37eb3c1ca89f94f9a5 GIT binary patch literal 596 zcmV-a0;~OrP)F-0-#tE5MPpPJbC~~e}M$k;T=F+ z4rD)}$O0hWRkHEOC!h~*OEw-36lyrZC((9D6cju_x%-loM6zVdQF-a6qwhfBt^PBo-PP>Kzgi@&t$<1FGc+XsqVs0E%NOM-)g9|42QgXH8W z*M3+KD1HZ+V?z+?4*P<91Ck>vtdTR5WYdwYK=Ce&BBJp~8&LcvFdqafb)4ZBZ#XI@ z*>WTrm_%RTEQ>JGd()9RplgpB&pgA5y&O9115~qDs`2Popx&?2VEX8Npq>VT7DzW9 zat7r{*@h!h*bE1W1LGkdsOAXJz{kMUH4&I}jqnyP@Z{KXP!`C31`Hlsl)|m=7^igO z;ZR^c*bJ0^19b5sP<$|~TE$FM`2`YGnY4`^7`~@~h8KVZftrD?bAcFkV6hx0 z)o_N3xC6x3K^2HZ!*K;l iaz9n7MvAM>Xp!QsrO?Wa;6}ve|M!%# zMQy}IC}HJHGc=;(yYG)>&H8ulpiwyH%=}r1A1?R3^X|L%{qyd2f#EGd+$p zsZf{f#J4ZPNe+LIwidR}RxM2n8MBZ&h4B(7_#%|K!&q`9c^k6+btRceFDIg*0)X$A zpkWg8pG*s5>=+UhlX45~G33+r8ERnuD++K(Wo||0&E;LYH+;D~W?FWGd`o>y+$uXA zZ@l{61Uw;>zW>KgQ6K*euT{kLKgFadE)7Q^ARn8YF{JcdZV3 z5i-aaZ;nV4DL9klvvXUTM}4y!^<{Tp28BoC(9@R6UBM|wxjS<8G9BD+LbZ4X`SGwl tN?^Ro4~XS$UJ6tFRe2giKbc4V`wf8zJ + inkscape:version="1.0.2 (e86c8708, 2021-01-15)"> + inkscape:document-rotation="0" + inkscape:snap-global="false"> + diff --git a/bitmaps_png/sources/dark/show_zone_triangulation.svg b/bitmaps_png/sources/dark/show_zone_triangulation.svg new file mode 100644 index 0000000000..f278d0a698 --- /dev/null +++ b/bitmaps_png/sources/dark/show_zone_triangulation.svg @@ -0,0 +1,141 @@ + + + + + + + + + + image/svg+xml + + show_zone_disable копия + + + + + + + + + + + + + + + + + + + + show_zone_disable копия + + + + + + + diff --git a/bitmaps_png/sources/light/show_zone_outline_only.svg b/bitmaps_png/sources/light/show_zone_outline_only.svg index 14ac746f00..cc18e3269f 100755 --- a/bitmaps_png/sources/light/show_zone_outline_only.svg +++ b/bitmaps_png/sources/light/show_zone_outline_only.svg @@ -13,7 +13,7 @@ viewBox="0 0 24 24" version="1.1" sodipodi:docname="show_zone_outline_only.svg" - inkscape:version="1.0.1 (c497b03c, 2020-09-10)"> + inkscape:version="1.0.2 (e86c8708, 2021-01-15)"> + inkscape:document-rotation="0" + inkscape:snap-global="false"> image/svg+xml - add_arc + show_zone_disable копия @@ -122,4 +123,12 @@ id="polygon838" style="display:inline;fill:none;stroke:#1a81c4;stroke-opacity:1" d="M 8.5 2.5 L 8.5 12.5 L 2.5 12.5 L 2.5 21.5 L 21.5 21.5 L 21.5 14.5 L 19.828125 14.5 A 4.5 4.5 0 0 1 17 15.5 A 4.5 4.5 0 0 1 12.5 11 A 4.5 4.5 0 0 1 17 6.5 A 4.5 4.5 0 0 1 19.828125 7.5 L 21.5 7.5 L 21.5 2.5 L 8.5 2.5 z " /> + diff --git a/bitmaps_png/sources/light/show_zone_triangulation.svg b/bitmaps_png/sources/light/show_zone_triangulation.svg new file mode 100644 index 0000000000..3332257ab0 --- /dev/null +++ b/bitmaps_png/sources/light/show_zone_triangulation.svg @@ -0,0 +1,139 @@ + + + + + + + + + + image/svg+xml + + show_zone_disable копия + + + + + + + + + + + + + + + + + + + + show_zone_disable копия + + + + + + + diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index fe446f701f..eaeb87d041 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -140,6 +140,12 @@ static const wxChar MaxTrackLengthToKeep[] = wxT( "MaxTrackLengthToKeep" ); */ static const wxChar StrokeTriangulation[] = wxT( "StrokeTriangulation" ); +/** + * When true, a third zone-display-mode is included which strokes the filled areas and fracture + * boundaries. + */ +static const wxChar ExtraZoneDisplayModes[] = wxT( "ExtraZoneDisplayModes" ); + /** * Absolute minimum pen width to send to the plotter. PDF seems happy enough with 0.0212mm * (which equates to 1px @ 1200dpi). @@ -252,6 +258,7 @@ ADVANCED_CFG::ADVANCED_CFG() m_DrawArcCenterMaxAngle = 50.0; m_MaxTangentAngleDeviation = 1.0; m_MaxTrackLengthToKeep = 0.0001; + m_ExtraZoneDisplayModes = false; m_DrawTriangulationOutlines = false; m_ExtraClearance = 0.0001; @@ -349,6 +356,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::MaxTrackLengthToKeep, &m_MaxTrackLengthToKeep, 0.0005, 0.0, 1.0 ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::ExtraZoneDisplayModes, + &m_ExtraZoneDisplayModes, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::StrokeTriangulation, &m_DrawTriangulationOutlines, false ) ); diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index 95bc7dd110..f1bfe8ecaa 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -425,7 +425,7 @@ void CAIRO_GAL_BASE::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& } -void CAIRO_GAL_BASE::DrawPolygon( const SHAPE_POLY_SET& aPolySet ) +void CAIRO_GAL_BASE::DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation ) { for( int i = 0; i < aPolySet.OutlineCount(); ++i ) drawPoly( aPolySet.COutline( i ) ); diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 0309a9e9b2..d9aaee9451 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1068,7 +1068,8 @@ void OPENGL_GAL::DrawPolygon( const VECTOR2D aPointList[], int aListSize ) } -void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet ) +void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet, + bool aStrokeTriangulation ) { m_currentManager->Shader( SHADER_NONE ); m_currentManager->Color( m_fillColor.r, m_fillColor.g, m_fillColor.b, m_fillColor.a ); @@ -1104,12 +1105,17 @@ void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet ) } if( ADVANCED_CFG::GetCfg().m_DrawTriangulationOutlines ) + { + aStrokeTriangulation = true; + SetStrokeColor( COLOR4D( 0.0, 1.0, 0.2, 1.0 ) ); + } + + if( aStrokeTriangulation ) { COLOR4D oldStrokeColor = m_strokeColor; double oldLayerDepth = m_layerDepth; SetLayerDepth( m_layerDepth - 1 ); - SetStrokeColor( COLOR4D( 0.0, 1.0, 0.2, 1.0 ) ); for( unsigned int j = 0; j < aPolySet.TriangulatedPolyCount(); ++j ) { @@ -1131,11 +1137,11 @@ void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet ) } -void OPENGL_GAL::DrawPolygon( const SHAPE_POLY_SET& aPolySet ) +void OPENGL_GAL::DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation ) { if( aPolySet.IsTriangulationUpToDate() ) { - drawTriangulatedPolyset( aPolySet ); + drawTriangulatedPolyset( aPolySet, aStrokeTriangulation ); return; } diff --git a/common/hotkey_store.cpp b/common/hotkey_store.cpp index 9427776e91..46f1aa083a 100644 --- a/common/hotkey_store.cpp +++ b/common/hotkey_store.cpp @@ -27,7 +27,7 @@ #include #include #include - +#include class PSEUDO_ACTION : public TOOL_ACTION { @@ -115,6 +115,15 @@ void HOTKEY_STORE::Init( std::vector aToolManagerList, bool aIncl if( entry.second->GetLabel().IsEmpty() ) continue; + if( !ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) + { + if( entry.second->GetName() == "pcbnew.Control.zoneDisplayOutlines" + || entry.second->GetName() == "pcbnew.Control.zoneDisplayTesselation" ) + { + continue; + } + } + HOTKEY& hotkey = masterMap[ entry.first ]; hotkey.m_Actions.push_back( entry.second ); hotkey.m_EditKeycode = entry.second->GetHotKey(); diff --git a/common/project/project_local_settings.cpp b/common/project/project_local_settings.cpp index e43cbcc4d7..7c738b7a35 100644 --- a/common/project/project_local_settings.cpp +++ b/common/project/project_local_settings.cpp @@ -172,7 +172,7 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin m_params.emplace_back( new PARAM_ENUM( "board.zone_display_mode", &m_ZoneDisplayMode, ZONE_DISPLAY_MODE::SHOW_FILLED, ZONE_DISPLAY_MODE::SHOW_FILLED, - ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE ) ); + ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ); m_params.emplace_back( new PARAM_LAMBDA( "project.files", [&]() -> nlohmann::json diff --git a/include/advanced_config.h b/include/advanced_config.h index 3242d30394..d02b1d1631 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -133,6 +133,12 @@ public: */ bool m_DrawTriangulationOutlines; + /** + * When true, adds zone-diaplay-modes for stroking the zone fracture boundaries and the zone + * triangulation. + */ + bool m_ExtraZoneDisplayModes; + /** * Sets an absolute minimum pen width for plotting. Some formats (PDF, for example) don't * like ultra-thin lines. Units are mm. diff --git a/include/bitmaps/bitmap_info.h b/include/bitmaps/bitmap_info.h index e8e590fde7..e7ca3bbddb 100644 --- a/include/bitmaps/bitmap_info.h +++ b/include/bitmaps/bitmap_info.h @@ -452,6 +452,7 @@ const std::vector g_BitmapInfo = { { BITMAPS::show_zone, wxT( "show_zone_24.png" ), 24, wxT( "light" ) }, { BITMAPS::show_zone_disable, wxT( "show_zone_disable_24.png" ), 24, wxT( "light" ) }, { BITMAPS::show_zone_outline_only, wxT( "show_zone_outline_only_24.png" ), 24, wxT( "light" ) }, + { BITMAPS::show_zone_triangulation, wxT( "show_zone_triangulation_24.png" ), 24, wxT( "light" ) }, { BITMAPS::show_all_layers, wxT( "show_all_layers_24.png" ), 24, wxT( "light" ) }, { BITMAPS::show_no_layers, wxT( "show_no_layers_24.png" ), 24, wxT( "light" ) }, { BITMAPS::show_no_copper_layers, wxT( "show_no_copper_layers_24.png" ), 24, wxT( "light" ) }, @@ -813,6 +814,7 @@ const std::vector g_BitmapInfo = { { BITMAPS::show_zone, wxT( "show_zone_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::show_zone_disable, wxT( "show_zone_disable_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::show_zone_outline_only, wxT( "show_zone_outline_only_dark_24.png" ), 24, wxT( "dark" ) }, + { BITMAPS::show_zone_triangulation, wxT( "show_zone_triangulation_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::show_all_layers, wxT( "show_all_layers_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::show_no_layers, wxT( "show_no_layers_dark_24.png" ), 24, wxT( "dark" ) }, { BITMAPS::show_no_copper_layers, wxT( "show_no_copper_layers_dark_24.png" ), 24, wxT( "dark" ) }, diff --git a/include/bitmaps/bitmaps_list.h b/include/bitmaps/bitmaps_list.h index 3adf6e80d7..3462f772ca 100644 --- a/include/bitmaps/bitmaps_list.h +++ b/include/bitmaps/bitmaps_list.h @@ -491,6 +491,7 @@ enum class BITMAPS : unsigned int show_zone, show_zone_disable, show_zone_outline_only, + show_zone_triangulation, showtrack, sim_add_signal, sim_probe, diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index e85a22c6d5..a30b06a6a5 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -104,7 +104,7 @@ public: drawPoly( aPointList, aListSize ); } - void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) override; + void DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation = false ) override; void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) override; /// @copydoc GAL::DrawCurve() diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 3bb6a67a7c..e13cf4f306 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -170,7 +170,7 @@ public: */ virtual void DrawPolygon( const std::deque& aPointList ) {}; virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {}; - virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) {}; + virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation = false ) {}; virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {}; /** diff --git a/include/gal/opengl/opengl_gal.h b/include/gal/opengl/opengl_gal.h index 17d335d0bd..56867959db 100644 --- a/include/gal/opengl/opengl_gal.h +++ b/include/gal/opengl/opengl_gal.h @@ -141,7 +141,7 @@ public: /// @copydoc GAL::DrawPolygon() void DrawPolygon( const std::deque& aPointList ) override; void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) override; - void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) override; + void DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation = false ) override; void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) override; /// @copydoc GAL::DrawCurve() @@ -425,8 +425,11 @@ private: /** * Draw a set of polygons with a cached triangulation. Way faster than drawPolygon. + * + * @param aStrokeTriangulation indicates the triangulation should be stroked rather than + * filled. Used for debugging. */ - void drawTriangulatedPolyset( const SHAPE_POLY_SET& aPoly ); + void drawTriangulatedPolyset( const SHAPE_POLY_SET& aPoly, bool aStrokeTriangulation ); /** diff --git a/include/project/board_project_settings.h b/include/project/board_project_settings.h index 09835dcfa8..425027f22b 100644 --- a/include/project/board_project_settings.h +++ b/include/project/board_project_settings.h @@ -98,9 +98,13 @@ enum class HIGH_CONTRAST_MODE ///< Determine how zones should be displayed. enum class ZONE_DISPLAY_MODE { - SHOW_FILLED, ///< Filled polygons are shown - SHOW_ZONE_OUTLINE, ///< Only the zone outline is shown - SHOW_FILLED_OUTLINE ///< Outlines of filled polygons are shown + SHOW_FILLED, + SHOW_ZONE_OUTLINE, + + // Debug modes + + SHOW_FRACTURE_BORDERS, + SHOW_TRIANGULATION }; ///< Determine how net color overrides should be applied. diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 582c8ec42b..661cca719b 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -260,9 +260,14 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) ); drawingModeSubMenu->SetIcon( BITMAPS::add_zone ); - drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayEnable, ACTION_MENU::CHECK ); - drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayDisable, ACTION_MENU::CHECK ); - drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayOutlines, ACTION_MENU::CHECK ); + drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayFilled, ACTION_MENU::CHECK ); + drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayOutline, ACTION_MENU::CHECK ); + + if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) + { + drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayFractured, ACTION_MENU::CHECK ); + drawingModeSubMenu->Add( PCB_ACTIONS::zoneDisplayTriangulated, ACTION_MENU::CHECK ); + } drawingModeSubMenu->AppendSeparator(); drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index fe1ef2e355..f986eb6fdf 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -561,12 +561,14 @@ void PCB_EDIT_FRAME::setupUIConditions() && GetDisplayOptions().m_ZoneOpacity > 0.0; }; - mgr->SetConditions( PCB_ACTIONS::zoneDisplayEnable, + mgr->SetConditions( PCB_ACTIONS::zoneDisplayFilled, ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ) ) ); - mgr->SetConditions( PCB_ACTIONS::zoneDisplayDisable, + mgr->SetConditions( PCB_ACTIONS::zoneDisplayOutline, ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE ) ) ); - mgr->SetConditions( PCB_ACTIONS::zoneDisplayOutlines, - ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE ) ) ); + mgr->SetConditions( PCB_ACTIONS::zoneDisplayFractured, + ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS ) ) ); + mgr->SetConditions( PCB_ACTIONS::zoneDisplayTriangulated, + ENABLE( enableZoneControlConition ).Check( cond.ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) ); auto enableBoardSetupCondition = [this] ( const SELECTION& ) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 714fb26b23..4e96628c0f 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1737,7 +1737,8 @@ void PCB_PAINTER::draw( const ZONE* aZone, int aLayer ) // Draw the filling if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED - || displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE ) + || displayMode == ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS + || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) { const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer ); @@ -1759,13 +1760,13 @@ void PCB_PAINTER::draw( const ZONE* aZone, int aLayer ) m_gal->SetIsFill( true ); m_gal->SetIsStroke( outline_thickness > 0 ); } - else if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE ) + else { m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); } - m_gal->DrawPolygon( polySet ); + m_gal->DrawPolygon( polySet, displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ); } } diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index c27cd25678..6eb52a8efb 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -181,7 +181,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM_ENUM( "pcb_display.zone_mode", &m_Display.m_ZoneDisplayMode, ZONE_DISPLAY_MODE::SHOW_FILLED, - ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE, ZONE_DISPLAY_MODE::SHOW_FILLED ) ); + ZONE_DISPLAY_MODE::SHOW_TRIANGULATION, ZONE_DISPLAY_MODE::SHOW_FILLED ) ); m_params.emplace_back( new PARAM( "pcb_display.origin_mode", reinterpret_cast( &m_Display.m_DisplayOrigin ), diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 2aa30de6cf..ca51b94ff2 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -353,9 +354,14 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( PCB_ACTIONS::toggleNetHighlight, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->AddScaledSeparator( this ); - m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayEnable, ACTION_TOOLBAR::TOGGLE ); - m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayDisable, ACTION_TOOLBAR::TOGGLE ); - m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayOutlines, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayFilled, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayOutline, ACTION_TOOLBAR::TOGGLE ); + + if( ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) + { + m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayFractured, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( PCB_ACTIONS::zoneDisplayTriangulated, ACTION_TOOLBAR::TOGGLE ); + } m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( PCB_ACTIONS::padDisplayMode, ACTION_TOOLBAR::TOGGLE ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index deee1937f4..6b1e9999f7 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -829,26 +829,31 @@ TOOL_ACTION PCB_ACTIONS::zoomFootprintAutomatically( "pcbnew.Control.zoomFootpri _( "Automatically zoom to fit" ), _( "Zoom to fit when changing footprint" ), BITMAPS::zoom_auto_fit_in_page ); -TOOL_ACTION PCB_ACTIONS::zoneDisplayEnable( "pcbnew.Control.zoneDisplayEnable", +TOOL_ACTION PCB_ACTIONS::zoneDisplayFilled( "pcbnew.Control.zoneDisplayEnable", AS_GLOBAL, 0, "", - _( "Fill Zones" ), _( "Show filled areas of zones" ), + _( "Draw Zone Fills" ), _( "Show filled areas of zones" ), BITMAPS::show_zone ); -TOOL_ACTION PCB_ACTIONS::zoneDisplayDisable( "pcbnew.Control.zoneDisplayDisable", +TOOL_ACTION PCB_ACTIONS::zoneDisplayOutline( "pcbnew.Control.zoneDisplayDisable", AS_GLOBAL, 0, "", - _( "Wireframe Zones" ), _( "Show only zone boundaries" ), + _( "Draw Zone Outlines" ), _( "Show only zone boundaries" ), BITMAPS::show_zone_disable ); -TOOL_ACTION PCB_ACTIONS::zoneDisplayOutlines( "pcbnew.Control.zoneDisplayOutlines", +TOOL_ACTION PCB_ACTIONS::zoneDisplayFractured( "pcbnew.Control.zoneDisplayOutlines", AS_GLOBAL, 0, "", - _( "Sketch Zones" ), _( "Show solid areas of zones in outline mode" ), + _( "Draw Zone Fill Fracture Borders" ), "", BITMAPS::show_zone_outline_only ); +TOOL_ACTION PCB_ACTIONS::zoneDisplayTriangulated( "pcbnew.Control.zoneDisplayTesselation", + AS_GLOBAL, 0, "", + _( "Draw Zone Fill Triangulation" ), "", + BITMAPS::show_zone_triangulation ); + TOOL_ACTION PCB_ACTIONS::zoneDisplayToggle( "pcbnew.Control.zoneDisplayToggle", AS_GLOBAL, 'A', "", _( "Toggle Zone Display" ), - _( "Cycle between showing filled zones, wireframed zones and sketched zones" ), + _( "Cycle between showing zone fills and just their outlines" ), BITMAPS::show_zone ); diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 78dbdd16f9..13348946b1 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -243,9 +243,10 @@ public: static TOOL_ACTION trackDisplayMode; static TOOL_ACTION padDisplayMode; static TOOL_ACTION viaDisplayMode; - static TOOL_ACTION zoneDisplayEnable; - static TOOL_ACTION zoneDisplayDisable; - static TOOL_ACTION zoneDisplayOutlines; + static TOOL_ACTION zoneDisplayFilled; + static TOOL_ACTION zoneDisplayOutline; + static TOOL_ACTION zoneDisplayFractured; + static TOOL_ACTION zoneDisplayTriangulated; static TOOL_ACTION zoneDisplayToggle; static TOOL_ACTION showPadNumbers; static TOOL_ACTION zoomFootprintAutomatically; diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 4579e8b785..cecd9d5c48 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -190,22 +190,28 @@ int PCB_CONTROL::ZoneDisplayMode( const TOOL_EVENT& aEvent ) auto opts = displayOptions(); // Apply new display options to the GAL canvas - if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayEnable ) ) + if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFilled ) ) { opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED; } - else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) ) + else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutline ) ) { opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE; } - else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) ) + else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayFractured ) ) { - opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE; + opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS; + } + else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayTriangulated ) ) + { + opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_TRIANGULATION; } else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) ) { - int nextMode = ( static_cast( opts.m_ZoneDisplayMode ) + 1 ) % 3; - opts.m_ZoneDisplayMode = static_cast( nextMode ); + if( opts.m_ZoneDisplayMode == ZONE_DISPLAY_MODE::SHOW_FILLED ) + opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE; + else + opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED; } else { @@ -1176,9 +1182,10 @@ void PCB_CONTROL::setTransitions() Go( &PCB_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() ); Go( &PCB_CONTROL::ToggleRatsnest, PCB_ACTIONS::ratsnestLineMode.MakeEvent() ); Go( &PCB_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() ); - Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayEnable.MakeEvent() ); - Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayDisable.MakeEvent() ); - Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutlines.MakeEvent() ); + Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayFilled.MakeEvent() ); + Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutline.MakeEvent() ); + Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayFractured.MakeEvent() ); + Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayTriangulated.MakeEvent() ); Go( &PCB_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayToggle.MakeEvent() ); Go( &PCB_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() ); Go( &PCB_CONTROL::HighContrastModeCycle, ACTIONS::highContrastModeCycle.MakeEvent() );