KiCad PCB EDA Suite
draw_gerber_screen.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013 Jean-Pierre Charras, jpierre.charras at wanadoo
5  * Copyright (C) 2013-2015 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <gr_basic.h>
33 #include <common.h>
34 #include <class_drawpanel.h>
35 #include <draw_graphic_text.h>
36 #include <base_units.h>
37 
38 #include <gerbview.h>
39 #include <gerbview_frame.h>
40 #include <gerber_file_image.h>
41 #include <gerber_file_image_list.h>
42 #include "gerbview_printout.h"
43 
44 
45 void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
46 {
47  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
48 
49  if( !GetGerberLayout() )
50  return;
51 
52  wxBusyCursor dummy;
53 
55 
56  switch( GetDisplayMode() )
57  {
58  default:
59  case 0:
60  break;
61 
62  case 1:
63  drawMode = GR_COPY;
64  break;
65 
66  case 2:
67  drawMode = GR_OR;
68  break;
69  }
70 
71  // Draw according to the current setting. This needs to be GR_COPY or GR_OR.
74  GetGerberLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ), &m_DisplayOptions );
75 
77  {
79  GetGerberLayout()->DrawItemsDCodeID( m_canvas, DC, GR_COPY, dcode_color );
80  }
81 
82  // Draw the "background" now, i.e. grid and axis after gerber layers
83  // because most of time the actual background is erased by successive drawings of each gerber
84  // layer mainly in COPY mode
85  m_canvas->DrawBackGround( DC );
86 
87  DrawWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
88 
89 #ifdef USE_WX_OVERLAY
90  if( IsShown() )
91  {
92  m_overlay.Reset();
93 
94  // On macOS, the call to create overlaydc fails for some reason due to
95  // the DC having zero size initially.
96  wxCoord w = 0, h = 0;
97  static_cast<wxWindowDC*>( DC )->GetSize( &w, &h );
98 
99  if( w == 0 || h == 0)
100  {
101  w = h = 1;
102  }
103 
104  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC, 0, 0, 1, 1 );
105  overlaydc.Clear();
106  }
107 #endif
108 
109  if( m_canvas->IsMouseCaptured() )
110  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
111 
112  m_canvas->DrawCrossHair( DC );
113 }
Implementation of conversion functions that require both schematic and board internal units...
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
int GetDisplayMode()
Function GetDisplayMode.
COLOR4D GetVisibleElementColor(int aLayerID)
Function GetVisibleElementColor returns the color of a gerber visible element.
COLOR4D m_BgDrawColor
The background color.
void DrawItemsDCodeID(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, COLOR4D aDrawColor)
Function DrawItemsDCodeID Draw the DCode value (if exists) corresponding to gerber item (polygons do ...
Definition: gbr_layout.cpp:352
COLOR4D m_NegativeDrawColor
The color used to draw negative objects, usually the background color, but not always, when negative objects must be visible.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:375
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
GBR_DISPLAY_OPTIONS m_DisplayOptions
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
virtual void DrawCrossHair(wxDC *aDC=nullptr, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
GBR_LAYOUT * GetGerberLayout() const
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
Definition: gr_basic.h:38
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
#define IU_PER_MILS
Definition: plotter.cpp:134
The common library.
virtual void DrawBackGround(wxDC *DC)
Function DrawBackGround.
void DrawWorkSheet(wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Draws on screen the page layout with the frame and the basic inscriptions.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset, GBR_DISPLAY_OPTIONS *aDisplayOptions)
Function Draw.
Definition: gbr_layout.cpp:88