KiCad PCB EDA Suite
gerber_file_image_list.h
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) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef GERBER_FILE_IMAGE_LIST_H
26 #define GERBER_FILE_IMAGE_LIST_H
27 
28 #include <vector>
29 #include <set>
30 #include <unordered_map>
31 
32 #include <gerber_draw_item.h>
33 #include <am_primitive.h>
34 
35 /* gerber files have different parameters to define units and how items must be plotted.
36  * some are for the entire file, and other can change along a file.
37  * In Gerber world:
38  * an image is the entire gerber file and its "global" parameters
39  * a layer (that is very different from a board layer) is just a sub set of a file that
40  * have specific parameters
41  * if a Image parameter is set more than once, only the last value is used
42  * Some parameters can change along a file and are not layer specific: they are stored
43  * in GERBER_ITEM items, when instancied.
44  *
45  * In GerbView, to handle these parameters, there are 2 classes:
46  * GERBER_FILE_IMAGE : the main class containing most of parameters and data to plot a graphic layer
47  * Some of them can change along the file
48  * There is one GERBER_FILE_IMAGE per file and one graphic layer per file or GERBER_FILE_IMAGE
49  * GerbView does not read and merge 2 gerber file in one graphic layer:
50  * I believe this is not possible due to the constraints in Image parameters.
51  * GERBER_LAYER : containing the subset of parameters that is layer speficic
52  * A GERBER_FILE_IMAGE must include one GERBER_LAYER to define all parameters to plot a file.
53  * But a GERBER_FILE_IMAGE can use more than one GERBER_LAYER.
54  */
55 
56 class GERBER_FILE_IMAGE;
57 
64 {
65  // the list of loaded images (1 image = 1 gerber file)
66  std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;
67 
68 public:
71 
72  wxString GetClass() const override
73  {
74  return wxT( "GERBER_FILE_IMAGE_LIST" );
75  }
76 
77  //Accessor
79  GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
80 
81  unsigned ImagesMaxCount() { return m_GERBER_List.size(); }
82 
90  int AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx );
91 
92 
96  void DeleteAllImages();
97 
102  void DeleteImage( int aIdx );
103 
117  const wxString GetDisplayName( int aIdx, bool aNameOnly = false );
118 
125  std::unordered_map<int, int> SortImagesByZOrder();
126 
127  #if defined(DEBUG)
128 
129  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
130 
131  #endif
132 };
133 
134 #endif // ifndef GERBER_FILE_IMAGE_LIST_H
void DeleteAllImages()
remove all loaded data in list, and delete all images.
const wxString GetDisplayName(int aIdx, bool aNameOnly=false)
std::unordered_map< int, int > SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
Class GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters ...
int AddGbrImage(GERBER_FILE_IMAGE *aGbrImage, int aIdx)
Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0. ...
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
wxString GetClass() const override
Function GetClass returns the class name.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
static GERBER_FILE_IMAGE_LIST & GetImagesList()
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void DeleteImage(int aIdx)
delete the loaded data of image aIdx.
std::vector< GERBER_FILE_IMAGE * > m_GERBER_List