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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <gerbview_frame.h>
22#include <gerber_file_image.h>
25#include <widgets/wx_grid.h>
26
27
41
42
44{
45 GERBER_FILE_IMAGE* gbrImage = m_parent->GetGbrImage( m_parent->GetActiveLayer() );
46
47 if( !gbrImage )
48 return true;
49
50 wxFileName filename( gbrImage->m_FileName );
51 m_stLayerName->SetLabel( filename.GetFullName() );
52
53 m_offsetX.SetValue( gbrImage->m_DisplayOffset.x );
54 m_offsetY.SetValue( gbrImage->m_DisplayOffset.y );
55 m_rotation.SetValue( gbrImage->m_DisplayRotation.AsDegrees() );
56
57 return true;
58}
59
61{
62 std::vector <GERBER_FILE_IMAGE*> gbrCandidates;
63 GERBER_FILE_IMAGE* gbrImage;
64 GERBER_FILE_IMAGE_LIST* images = m_parent->GetGerberLayout()->GetImagesList();
65
66 switch( m_rbScope->GetSelection() )
67 {
68 case 0: // candidate = active layer
69 gbrImage = m_parent->GetGbrImage( m_parent->GetActiveLayer() );
70
71 if( gbrImage )
72 gbrCandidates.push_back( gbrImage );
73
74 break;
75
76 case 1: // All layers
77 for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
78 {
79 gbrImage = images->GetGbrImage( layer );
80
81 if( gbrImage )
82 gbrCandidates.push_back( gbrImage );
83 }
84
85 break;
86
87 case 2: // All active layers
88 for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
89 {
90 gbrImage = images->GetGbrImage( layer );
91
92 if( gbrImage && m_parent->IsLayerVisible( layer ) )
93 gbrCandidates.push_back( gbrImage );
94 }
95
96 break;
97 }
98
99 // Now update all candidates
100 for( unsigned ii = 0; ii < gbrCandidates.size(); ++ii )
101 {
102 gbrImage = gbrCandidates[ii];
103 double offsetX = m_offsetX.GetValue();
104 double offsetY = m_offsetY.GetValue();
105 EDA_ANGLE rot = m_rotation.GetAngleValue();
106
107 gbrImage->SetDrawOffetAndRotation( VECTOR2D( offsetX/gerbIUScale.IU_PER_MM,
108 offsetY/gerbIUScale.IU_PER_MM ), rot );
109 }
110
111 return true;
112}
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:120
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:682