KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_import_graphics.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) 2013 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#pragma once
22
23#include <widgets/unit_binder.h>
24#include <pcb_edit_frame.h>
25#include <pcbnew_settings.h>
28
30
31
33{
34public:
36
40 std::list<std::unique_ptr<EDA_ITEM>>& GetImportedItems() { return m_importer->GetItems(); }
41
47 bool IsPlacementInteractive() { return !m_placeAtCheckbox->GetValue(); }
48
52 bool ShouldFixDiscontinuities() { return m_rbFixDiscontinuities->GetValue(); }
53
57 int GetTolerance() { return m_tolerance.GetIntValue(); }
58
62 bool ShouldGroupItems() { return m_cbGroupItems->IsChecked(); }
63
67 void SetFilenameOverride( const wxString& aFilenameOverride );
68
69 bool TransferDataToWindow() override;
70 bool TransferDataFromWindow() override;
71
72private:
73 // Virtual event handlers
74 void onBrowseFiles( wxCommandEvent& event ) override;
75 void onFilenameChanged( wxCommandEvent& event ) override;
76 void onThresholdChanged( wxScrollEvent& event ) override;
77 void onInvertChanged( wxCommandEvent& event ) override;
78 void onScaleChanged( wxCommandEvent& event ) override;
79 void onWidthChanged( wxCommandEvent& event ) override;
80 void onHeightChanged( wxCommandEvent& event ) override;
81 void onLockAspectChanged( wxCommandEvent& event ) override;
82 void onUpdateUI( wxUpdateUIEvent& event ) override;
83
85 void loadSourceFile();
86
89
90 void updatePreview();
91
93 void updateSizeControls();
94
96 void sizeFromScale();
97
99 void scaleFromSize( bool aFromWidth );
100
101private:
103 std::unique_ptr<GRAPHICS_IMPORTER_PCBNEW> m_importer;
104 std::unique_ptr<GRAPHICS_IMPORT_MGR> m_gfxImportMgr;
105
112
114
116 wxString m_sourcePath;
117
120
121 double m_xScale;
122 double m_yScale;
123
125};
DIALOG_IMPORT_GRAPHICS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Import Graphics File"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void onHeightChanged(wxCommandEvent &event) override
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
std::unique_ptr< GRAPHICS_IMPORT_MGR > m_gfxImportMgr
void updateImageControls()
Show the image controls only when the chosen file is a raster image.
std::unique_ptr< GRAPHICS_IMPORTER_PCBNEW > m_importer
void onInvertChanged(wxCommandEvent &event) override
void onLockAspectChanged(wxCommandEvent &event) override
void onThresholdChanged(wxScrollEvent &event) override
void updateSizeControls()
Offer the size fields only when the source has a size to scale.
void scaleFromSize(bool aFromWidth)
Work the scale out from a size the user typed.
void loadSourceFile()
Read the chosen file, which is where the preview and the source size come from.
void onBrowseFiles(wxCommandEvent &event) override
void onFilenameChanged(wxCommandEvent &event) override
wxString m_sourcePath
The file the source size and the preview were taken from.
void SetFilenameOverride(const wxString &aFilenameOverride)
Set the filename override to be applied in TransferDataToWindow.
void sizeFromScale()
Write the scale into the size fields.
void onWidthChanged(wxCommandEvent &event) override
void onScaleChanged(wxCommandEvent &event) override
VECTOR2D m_sourceSizeMM
Size of the source file's contents in mm, (0,0) when it has none to report.
void onUpdateUI(wxUpdateUIEvent &event) override
DIALOG_IMPORT_GRAPHICS(PCB_BASE_FRAME *aParent)
Manage vector graphics importers.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
VECTOR2< double > VECTOR2D
Definition vector2d.h:707