From 9fec8aa269cf2e7bea116bcd464bc07ec78946b2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 1 Mar 2022 11:29:35 +0100 Subject: [PATCH] 3D viewer: disable thickness rendering on tech layers when disabled for copper. Building the vertical walls around shapes to show layer tickness is very time consuming. It can be disabled for copper layers but was always enabled for other layers. Now layer thickness is enabled or disabled for all layers. --- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 2 - 3d-viewer/3d_canvas/create_layer_items.cpp | 115 ++++++++++-------- .../dialogs/panel_3D_opengl_options_base.cpp | 4 +- .../dialogs/panel_3D_opengl_options_base.fbp | 7 +- .../dialogs/panel_3D_opengl_options_base.h | 3 +- 5 files changed, 74 insertions(+), 57 deletions(-) diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 1ca6215f47..569e082ff6 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -627,8 +627,6 @@ void BOARD_ADAPTER::addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aConta aShape->TransformShapeWithClearanceToPolygon( polyList, UNDEFINED_LAYER, 0, ARC_HIGH_DEF, ERROR_INSIDE ); - polyList.Simplify( SHAPE_POLY_SET::PM_FAST ); - if( polyList.IsEmpty() ) // Just for caution break; diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index 9cdc1efb8a..fb113c478a 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -878,6 +878,12 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) aStatusReporter->Report( _( "Build Tech layers" ) ); // draw graphic items, on technical layers + + // Vertical walls (layer thickness) around shapes is really time consumming + // They are built on request + bool buildVerticalWallsForTechLayers = m_Cfg->m_Render.opengl_copper_thickness + && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL; + static const PCB_LAYER_ID teckLayerList[] = { B_Adhes, F_Adhes, @@ -951,39 +957,42 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } } - // Add drawing contours - for( BOARD_ITEM* item : m_board->Drawings() ) + // Add drawing contours (vertical walls) + if( buildVerticalWallsForTechLayers ) { - if( !item->IsOnLayer( curr_layer_id ) ) - continue; - - switch( item->Type() ) + for( BOARD_ITEM* item : m_board->Drawings() ) { - case PCB_SHAPE_T: - item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, - ARC_HIGH_DEF, ERROR_INSIDE ); - break; + if( !item->IsOnLayer( curr_layer_id ) ) + continue; - case PCB_TEXT_T: - { - PCB_TEXT* text = static_cast( item ); - - text->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, + switch( item->Type() ) + { + case PCB_SHAPE_T: + item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, ARC_HIGH_DEF, ERROR_INSIDE ); - break; - } + break; - case PCB_TEXTBOX_T: - { - PCB_TEXTBOX* textbox = static_cast( item ); + case PCB_TEXT_T: + { + PCB_TEXT* text = static_cast( item ); - textbox->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, - ARC_HIGH_DEF, ERROR_INSIDE ); - break; - } + text->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, + ARC_HIGH_DEF, ERROR_INSIDE ); + break; + } - default: - break; + case PCB_TEXTBOX_T: + { + PCB_TEXTBOX* textbox = static_cast( item ); + + textbox->TransformTextShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, + ARC_HIGH_DEF, ERROR_INSIDE ); + break; + } + + default: + break; + } } } @@ -1011,36 +1020,38 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } - // Add footprints tech layers - contours - for( FOOTPRINT* footprint : m_board->Footprints() ) + // Add footprints tech layers - contours (vertical walls) + if( buildVerticalWallsForTechLayers ) { - if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) ) + for( FOOTPRINT* footprint : m_board->Footprints() ) { - int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ]; - - for( PAD* pad : footprint->Pads() ) + if( ( curr_layer_id == F_SilkS ) || ( curr_layer_id == B_SilkS ) ) { - if( !pad->IsOnLayer( curr_layer_id ) ) - continue; + int linewidth = m_board->GetDesignSettings().m_LineThickness[ LAYER_CLASS_SILK ]; - buildPadOutlineAsPolygon( pad, *layerPoly, linewidth ); + for( PAD* pad : footprint->Pads() ) + { + if( !pad->IsOnLayer( curr_layer_id ) ) + continue; + + buildPadOutlineAsPolygon( pad, *layerPoly, linewidth ); + } + } + else + { + footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, + ARC_HIGH_DEF, ERROR_INSIDE ); } - } - else - { - footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0, - ARC_HIGH_DEF, ERROR_INSIDE ); - } - // On tech layers, use a poor circle approximation, only for texts (stroke font) - footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0, - ARC_HIGH_DEF, ERROR_INSIDE ); + // On tech layers, use a poor circle approximation, only for texts (stroke font) + footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0, + ARC_HIGH_DEF, ERROR_INSIDE ); - // Add the remaining things with dynamic seg count for circles - transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly ); + // Add the remaining things with dynamic seg count for circles + transformFPShapesToPolygon( footprint, curr_layer_id, *layerPoly ); + } } - // Draw non copper zones if( m_Cfg->m_Render.show_zones ) { @@ -1050,10 +1061,14 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) addSolidAreasShapes( zone, layerContainer, curr_layer_id ); } - for( ZONE* zone : m_board->Zones() ) + if( buildVerticalWallsForTechLayers ) { - if( zone->IsOnLayer( curr_layer_id ) ) - zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly ); + for( ZONE* zone : m_board->Zones() ) + { + + if( zone->IsOnLayer( curr_layer_id ) ) + zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly ); + } } } diff --git a/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp b/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp index 44d32b053a..5d22e7abcd 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp +++ b/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -25,7 +25,7 @@ PANEL_3D_OPENGL_OPTIONS_BASE::PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wx m_checkBoxBoundingBoxes = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Show model bounding boxes"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizerOpenGLRenderoptions->Add( m_checkBoxBoundingBoxes, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_checkBoxCuThickness = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Show copper thickness"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkBoxCuThickness = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Show copper and tech layers thickness (very slow)"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizerOpenGLRenderoptions->Add( m_checkBoxCuThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_checkBoxHighlightOnRollOver = new wxCheckBox( sbSizerOpenGLRenderoptions->GetStaticBox(), wxID_ANY, _("Highlight items on rollover"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp b/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp index 662341872c..90d82d15c5 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp +++ b/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ panel_3D_opengl_options_base 1000 none + 1 panel_3D_opengl_optionS_base @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -46,6 +48,7 @@ -1,-1 RESETTABLE_PANEL; widgets/resettable_panel.h; forward_declare + 0 wxTAB_TRAVERSAL @@ -172,7 +175,7 @@ 0 0 wxID_ANY - Show copper thickness + Show copper and tech layers thickness (very slow) 0 diff --git a/3d-viewer/dialogs/panel_3D_opengl_options_base.h b/3d-viewer/dialogs/panel_3D_opengl_options_base.h index bc67b49af7..5fc0c7f508 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options_base.h +++ b/3d-viewer/dialogs/panel_3D_opengl_options_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -51,6 +51,7 @@ class PANEL_3D_OPENGL_OPTIONS_BASE : public RESETTABLE_PANEL public: PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_3D_OPENGL_OPTIONS_BASE(); };