From 4a461cd09baaebd3ff58bea8c2a188506264e953 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 28 Feb 2014 11:51:47 +0100 Subject: [PATCH] 3D viewer: shows now the texts of footprints (ref, value and others) when visible. Fix also other very minor issues. Realistic mode shows or not the copper thickness (depending on selected option in preferences) to speed up the screen redraw. --- 3d-viewer/info3d_visu.cpp | 25 ++++---- 3d-viewer/info3d_visu.h | 14 +++-- ...board_items_to_polygon_shape_transform.cpp | 58 ++++++++++++++----- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/3d-viewer/info3d_visu.cpp b/3d-viewer/info3d_visu.cpp index 0dc0f04848..3e0afc43c1 100644 --- a/3d-viewer/info3d_visu.cpp +++ b/3d-viewer/info3d_visu.cpp @@ -88,8 +88,8 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard ) if( bbbox.GetWidth() == 0 && bbbox.GetHeight() == 0 ) { - bbbox.SetWidth( 100 * IU_PER_MM ); - bbbox.SetHeight( 100 * IU_PER_MM ); + bbbox.SetWidth( Millimeter2iu( 100 ) ); + bbbox.SetHeight( Millimeter2iu( 100 ) ); } m_BoardSettings = &aBoard->GetDesignSettings(); @@ -131,6 +131,7 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard ) // Fill remaining unused copper layers and front layer zpos // with m_EpoxyThickness + // Solder mask and Solder paste have the same Z position for( ; layer <= LAST_COPPER_LAYER; layer++ ) { m_LayerZcoord[layer] = m_EpoxyThickness; @@ -144,21 +145,21 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard ) switch( layer_id ) { case ADHESIVE_N_BACK: - zpos = zpos_copper_back - 4 * zpos_offset; - break; - - case ADHESIVE_N_FRONT: - zpos = zpos_copper_front + 4 * zpos_offset; - break; - - case SOLDERPASTE_N_BACK: zpos = zpos_copper_back - 3 * zpos_offset; break; - case SOLDERPASTE_N_FRONT: + case ADHESIVE_N_FRONT: zpos = zpos_copper_front + 3 * zpos_offset; break; + case SOLDERPASTE_N_BACK: + zpos = zpos_copper_back - 1 * zpos_offset; + break; + + case SOLDERPASTE_N_FRONT: + zpos = zpos_copper_front + 1 * zpos_offset; + break; + case SOLDERMASK_N_BACK: zpos = zpos_copper_back - 1 * zpos_offset; break; @@ -177,7 +178,7 @@ void INFO3D_VISU::InitSettings( BOARD* aBoard ) default: zpos = zpos_copper_front + - (layer_id - FIRST_NON_COPPER_LAYER + 5) * zpos_offset; + (layer_id - FIRST_NON_COPPER_LAYER + 4) * zpos_offset; break; } diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h index de9d755eed..00acbbd226 100644 --- a/3d-viewer/info3d_visu.h +++ b/3d-viewer/info3d_visu.h @@ -148,9 +148,10 @@ public: INFO3D_VISU(); */ int GetCopperThicknessBIU() const { - bool use_copper_thickness = GetFlag( FL_USE_COPPER_THICKNESS ) || - GetFlag( FL_USE_REALISTIC_MODE ); - return use_copper_thickness ? + bool use_thickness = GetFlag( FL_USE_COPPER_THICKNESS ) +// || GetFlag( FL_USE_REALISTIC_MODE ) + ; + return use_thickness ? KiROUND( m_CopperThickness / m_BiuTo3Dunits ) : 0; } @@ -173,9 +174,10 @@ public: INFO3D_VISU(); */ int GetNonCopperLayerThicknessBIU() const { - bool use_copper_thickness = GetFlag( FL_USE_COPPER_THICKNESS ) || - GetFlag( FL_USE_REALISTIC_MODE ); - return use_copper_thickness ? + bool use_thickness = GetFlag( FL_USE_COPPER_THICKNESS ) +// || GetFlag( FL_USE_REALISTIC_MODE ) + ; + return use_thickness ? KiROUND( m_NonCopperLayerThickness / m_BiuTo3Dunits ) : 0; } diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 68059370d1..aea31b9ca7 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -23,6 +23,21 @@ #include #include +// These variables are parameters used in addTextSegmToPoly. +// But addTextSegmToPoly is a call-back function, +// so we cannot send them as arguments. +int s_textWidth; +int s_textCircle2SegmentCount; +CPOLYGONS_LIST* s_cornerBuffer; + +// This is a call back function, used by DrawGraphicText to draw the 3D text shape: +static void addTextSegmToPoly( int x0, int y0, int xf, int yf ) +{ + TransformRoundedEndsSegmentToPolygon( *s_cornerBuffer, + wxPoint( x0, y0), wxPoint( xf, yf ), + s_textCircle2SegmentCount, s_textWidth ); +} + /* generate pads shapes on layer aLayer as polygons, * and adds these polygons to aCornerBuffer * aCornerBuffer = the buffer to store polygons @@ -91,12 +106,16 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( int aCircleToSegmentsCount, double aCorrectionFactor ) { + std::vector texts; // List of TEXTE_MODULE to convert EDGE_MODULE* outline; + for( EDA_ITEM* item = GraphicalItems(); item != NULL; item = item->Next() ) { switch( item->Type() ) { case PCB_MODULE_TEXT_T: + if( ((TEXTE_MODULE*)item)->GetLayer() == aLayer ) + texts.push_back( (TEXTE_MODULE *) item ); break; case PCB_MODULE_EDGE_T: @@ -153,6 +172,29 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( break; } } + + // Convert texts sur modules + if( Reference().GetLayer() == aLayer && Reference().IsVisible() ) + texts.push_back( &Reference() ); + + if( Value().GetLayer() == aLayer && Value().IsVisible() ) + texts.push_back( &Value() ); + + s_cornerBuffer = &aCornerBuffer; + s_textCircle2SegmentCount = aCircleToSegmentsCount; + + for( unsigned ii = 0; ii < texts.size(); ii++ ) + { + TEXTE_MODULE *textmod = texts[ii]; + s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue ); + DrawGraphicText( NULL, NULL, textmod->GetTextPosition(), BLACK, + textmod->GetText(), textmod->GetDrawRotation(), + textmod->GetSize(), + textmod->GetHorizJustify(), textmod->GetVertJustify(), + textmod->GetThickness(), textmod->IsItalic(), + true, addTextSegmToPoly ); + } + } /* Function TransformSolidAreasShapesToPolygonSet @@ -257,20 +299,6 @@ void TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon( * clearance when the circle is approximated by segment bigger or equal * to the real clearance value (usually near from 1.0) */ -// These variables are parameters used in addTextSegmToPoly. -// But addTextSegmToPoly is a call-back function, -// so we cannot send them as arguments. -int s_textWidth; -int s_textCircle2SegmentCount; -CPOLYGONS_LIST* s_cornerBuffer; - -// This is a call back function, used by DrawGraphicText to draw the 3D text shape: -static void addTextSegmToPoly( int x0, int y0, int xf, int yf ) -{ - TransformRoundedEndsSegmentToPolygon( *s_cornerBuffer, - wxPoint( x0, y0), wxPoint( xf, yf ), - s_textCircle2SegmentCount, s_textWidth ); -} void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( CPOLYGONS_LIST& aCornerBuffer, @@ -309,7 +337,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet( } else { - DrawGraphicText( NULL, NULL, GetTextPosition(), (EDA_COLOR_T) color, + DrawGraphicText( NULL, NULL, GetTextPosition(), color, GetText(), GetOrientation(), size, GetHorizJustify(), GetVertJustify(), GetThickness(), IsItalic(),