KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_draw_layers_settings.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) 2023 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright (C) 2023 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#include <gerbview_frame.h>
26#include <gerber_file_image.h>
29#include <widgets/wx_grid.h>
30
31
34 m_parent( aParent ),
35 m_offsetX( aParent, m_stOffsetX, m_tcOffsetX, m_stUnitX, true ),
36 m_offsetY( aParent, m_stOffsetY, m_tcOffsetY, m_stUnitY, true ),
37 m_rotation( aParent, m_stLayerRot, m_tcRotation, m_stUnitRot, true )
38{
39 m_rotation.SetUnits( EDA_UNITS::DEGREES );
41
44}
45
46
48{
50
51 if( !gbrImage )
52 return true;
53
54 wxFileName filename( gbrImage->m_FileName );
55 m_stLayerName->SetLabel( filename.GetFullName() );
56
60
61 return true;
62}
63
65{
66 std::vector <GERBER_FILE_IMAGE*> gbrCandidates;
67 GERBER_FILE_IMAGE* gbrImage;
69
70 switch( m_rbScope->GetSelection() )
71 {
72 case 0: // candidate = active layer
74
75 if( gbrImage )
76 gbrCandidates.push_back( gbrImage );
77
78 break;
79
80 case 1: // All layers
81 for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
82 {
83 gbrImage = images->GetGbrImage( layer );
84
85 if( gbrImage )
86 gbrCandidates.push_back( gbrImage );
87 }
88 break;
89
90 case 2: // All active layers
91 for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
92 {
93 gbrImage = images->GetGbrImage( layer );
94
95 if( gbrImage && m_parent->IsLayerVisible( layer ) )
96 gbrCandidates.push_back( gbrImage );
97 }
98 break;
99 }
100
101 // Now update all candidates
102 for( unsigned ii = 0; ii < gbrCandidates.size(); ++ii )
103 {
104 gbrImage = gbrCandidates[ii];
105 double offsetX = m_offsetX.GetValue();
106 double offsetY = m_offsetY.GetValue();
108
110 offsetY/gerbIUScale.IU_PER_MM ), rot );
111 }
112
113 return true;
114}
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:107
Class DIALOG_DRAW_LAYERS_SETTINGS_BASE.
DIALOG_DRAW_LAYERS_SETTINGS(GERBVIEW_FRAME *aParent)
bool TransferDataFromWindow() override
Update layerset basing on the selected layers.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
double AsDegrees() const
Definition: eda_angle.h:155
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files which are loaded...
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
Hold the image data and parameters for one gerber file and layer parameters.
void SetDrawOffetAndRotation(VECTOR2D aOffsetMM, EDA_ANGLE aRotation)
Set the offset and rotation to draw a file image Does not change any coordinate od draw items.
wxString m_FileName
Full File Name for this layer.
VECTOR2I m_DisplayOffset
< Parameters used only to draw (display) items on this layer.
bool IsLayerVisible(int aLayer) const
Test whether a given layer is visible.
GBR_LAYOUT * GetGerberLayout() const
int GetActiveLayer() const
Return the active layer.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetPrecision(int aLength)
Normally not needed, but can be used to set the precision when using internal units that are floats (...
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
virtual EDA_ANGLE GetAngleValue()
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
const double IU_PER_MM
Definition: base_units.h:76
VECTOR2< double > VECTOR2D
Definition: vector2d.h:601