KiCad PCB EDA Suite
Loading...
Searching...
No Matches
odb_test_utils.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef QA_PCBNEW_ODBPP_TEST_UTILS_H
21#define QA_PCBNEW_ODBPP_TEST_UTILS_H
22
23#include <clocale>
24#include <filesystem>
25#include <map>
26#include <set>
27#include <string>
28#include <vector>
29
30#include <wx/string.h>
31
32#include <layer_ids.h>
33#include <pad.h>
34#include <qa_utils/file_utils.h>
36
37class BOARD;
38class REPORTER;
39
42{
43public:
44 SCOPED_C_CTYPE() : m_previous( std::setlocale( LC_CTYPE, nullptr ) )
45 {
46#ifndef _WIN32
47 m_ok = std::setlocale( LC_CTYPE, "C" ) != nullptr;
48#endif
49 }
50
51 ~SCOPED_C_CTYPE() { std::setlocale( LC_CTYPE, m_previous.c_str() ); }
52
53 bool Ok() const { return m_ok; }
54
55private:
56 std::string m_previous;
57 bool m_ok = true;
58};
59
66std::filesystem::path ExportOdb( const BOARD& aBoard, const std::filesystem::path& aDir,
67 const std::string& aUnits = "mm", const std::string& aSigfig = "6",
68 REPORTER* aReporter = nullptr );
69
73std::vector<std::string> ReadLines( const std::filesystem::path& aFile );
74
76
77size_t CountPads( const BOARD& aBoard, PAD_PROP aProperty, PCB_LAYER_ID aLayer );
78
80{
81public:
82 explicit OdbFeatureFile( const std::filesystem::path& aFile );
83
84 size_t CountRecordsWithOption( const std::string& aName, const std::string& aOption ) const;
85 size_t CountRecordsWithFlag( const std::string& aName ) const;
86 size_t CountRecordsWithInteger( const std::string& aName, int aValue ) const;
87
88private:
89 size_t CountRecordsWithValue( const std::string& aName, const std::string& aValue ) const;
90
91 std::map<std::string, std::string> m_names;
92 std::vector<std::string> m_records;
93};
94
99{
100public:
101 explicit ODB_PRODUCT( const std::filesystem::path& aRoot );
102
103 const std::vector<ODB_MATRIX_ROW>& Matrix() const { return m_matrix; }
104
106 wxString LayerFile( const wxString& aLayer, const wxString& aFile ) const;
107
108private:
109 std::filesystem::path m_stepDir;
110 std::vector<ODB_MATRIX_ROW> m_matrix;
111};
112
113#endif // QA_PCBNEW_ODBPP_TEST_UTILS_H
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
std::vector< ODB_MATRIX_ROW > m_matrix
std::filesystem::path m_stepDir
wxString LayerFile(const wxString &aLayer, const wxString &aFile) const
Path of a file in a layer directory, matched to the directory name without regard to case.
const std::vector< ODB_MATRIX_ROW > & Matrix() const
ODB_PRODUCT(const std::filesystem::path &aRoot)
std::map< std::string, std::string > m_names
std::vector< std::string > m_records
size_t CountRecordsWithInteger(const std::string &aName, int aValue) const
size_t CountRecordsWithOption(const std::string &aName, const std::string &aOption) const
OdbFeatureFile(const std::filesystem::path &aFile)
size_t CountRecordsWithValue(const std::string &aName, const std::string &aValue) const
size_t CountRecordsWithFlag(const std::string &aName) const
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
std::string m_previous
bool Ok() const
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
STL namespace.
size_t CountPads(const BOARD &aBoard, PAD_PROP aProperty, PCB_LAYER_ID aLayer)
std::vector< std::string > ReadLines(const std::filesystem::path &aFile)
Read a text file into one string per line, with no trailing newline characters.
const KI_TEST::SCOPED_TEMP_DIR & TempDir()
std::filesystem::path ExportOdb(const BOARD &aBoard, const std::filesystem::path &aDir, const std::string &aUnits="mm", const std::string &aSigfig="6", REPORTER *aReporter=nullptr)
Export a board to an ODB++ product model tree rooted at aDir and return aDir.
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition padstack.h:113