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 The 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
45
46
48{
49 GERBER_FILE_IMAGE* gbrImage = m_parent->GetGbrImage( m_parent->GetActiveLayer() );
50
51 if( !gbrImage )
52 return true;
53
54 wxFileName filename( gbrImage->m_FileName );
55 m_stLayerName->SetLabel( filename.GetFullName() );
56
57 m_offsetX.SetValue( gbrImage->m_DisplayOffset.x );
58 m_offsetY.SetValue( gbrImage->m_DisplayOffset.y );
59 m_rotation.SetValue( gbrImage->m_DisplayRotation.AsDegrees() );
60
61 return true;
62}
63
65{
66 std::vector <GERBER_FILE_IMAGE*> gbrCandidates;
67 GERBER_FILE_IMAGE* gbrImage;
68 GERBER_FILE_IMAGE_LIST* images = m_parent->GetGerberLayout()->GetImagesList();
69
70 switch( m_rbScope->GetSelection() )
71 {
72 case 0: // candidate = active layer
73 gbrImage = m_parent->GetGbrImage( m_parent->GetActiveLayer() );
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();
107 EDA_ANGLE rot = m_rotation.GetAngleValue();
108
109 gbrImage->SetDrawOffetAndRotation( VECTOR2D( offsetX/gerbIUScale.IU_PER_MM,
110 offsetY/gerbIUScale.IU_PER_MM ), rot );
111 }
112
113 return true;
114}
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:111
DIALOG_DRAW_LAYERS_SETTINGS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Layers Settings"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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:116
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.
VECTOR2< double > VECTOR2D
Definition vector2d.h:694