forked from KiCad/kicad-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gerber_file_image_list.h
136 lines (119 loc) · 5.17 KB
/
gerber_file_image_list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef GERBER_FILE_IMAGE_LIST_H
#define GERBER_FILE_IMAGE_LIST_H
#include <vector>
#include <set>
#include <unordered_map>
#include <gerber_draw_item.h>
#include <am_primitive.h>
/* gerber files have different parameters to define units and how items must be plotted.
* some are for the entire file, and other can change along a file.
* In Gerber world:
* an image is the entire gerber file and its "global" parameters
* a layer (that is very different from a board layer) is just a sub set of a file that
* have specific parameters
* if a Image parameter is set more than once, only the last value is used
* Some parameters can change along a file and are not layer specific: they are stored
* in GERBER_ITEM items, when instanced.
*
* In GerbView, to handle these parameters, there are 2 classes:
* GERBER_FILE_IMAGE : the main class containing most of parameters and data to plot a graphic layer
* Some of them can change along the file
* There is one GERBER_FILE_IMAGE per file and one graphic layer per file or GERBER_FILE_IMAGE
* GerbView does not read and merge 2 gerber file in one graphic layer:
* I believe this is not possible due to the constraints in Image parameters.
* GERBER_LAYER : containing the subset of parameters that is layer specific
* A GERBER_FILE_IMAGE must include one GERBER_LAYER to define all parameters to plot a file.
* But a GERBER_FILE_IMAGE can use more than one GERBER_LAYER.
*/
class GERBER_FILE_IMAGE;
/**
* @brief GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files
* which are loaded and can be displayed
* there are 32 images max which can be loaded
*/
class GERBER_FILE_IMAGE_LIST
{
public:
GERBER_FILE_IMAGE_LIST();
~GERBER_FILE_IMAGE_LIST();
static GERBER_FILE_IMAGE_LIST& GetImagesList();
GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
unsigned ImagesMaxCount() { return m_GERBER_List.size(); }
/**
* Add a GERBER_FILE_IMAGE* at index aIdx or at the first free location if aIdx < 0
*
* @param aGbrImage is the image to add.
* @param aIdx is the location to use ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ).
* @return true if the index used, or -1 if no room to add image
*/
int AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx );
/**
* Remove all loaded data in list, and delete all images, freeing the memory.
*/
void DeleteAllImages();
/**
* Delete the loaded data of image \a aIdx, freeing the memory.
*
* @param aIdx is the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ).
*/
void DeleteImage( int aIdx );
/**
* Get the display name for the layer at \a aIdx.
*
* if a file is loaded, the name is:
* "<aIdx+1> <short filename> <X2 FileFunction info> if a X2 FileFunction info is found"
* or (if no FileFunction info)
* "<aIdx+1> <short filename> *"
* if no file loaded, the name is:
* "Layer n" with n = aIdx+1
*
* @param aIdx is the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 ).
* @param aNameOnly set to false (default) to add the layer number (for layers manager)
* or true to return only the name without layer name (status bar)/
* @param aFullName set to false (default) to ellipsize the name, true to return the full name.
*
* @return a name for image aIdx which can be used in layers manager and layer selector or
* in the status bar
*/
const wxString GetDisplayName( int aIdx, bool aNameOnly = false, bool aFullName = false );
/**
* Sort loaded images by Z order priority, if they have the X2 FileFormat info
* (SortImagesByZOrder updates the graphic layer of these items)
*
* @return a mapping of old to new layer index
*/
std::unordered_map<int, int> SortImagesByZOrder();
/**
* Get number of loaded images
*
* @return number of images loaded
*/
unsigned GetLoadedImageCount();
private:
// the list of loaded images (1 image = 1 gerber file)
std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;
};
#endif // ifndef GERBER_FILE_IMAGE_LIST_H