2020-05-25 17:06:53 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 CERN
|
2022-06-06 20:58:00 +00:00
|
|
|
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-05-25 17:06:53 +00:00
|
|
|
* @author Jon Evans <jon@craftyjon.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KICAD_PROJECT_FILE_H
|
|
|
|
#define KICAD_PROJECT_FILE_H
|
|
|
|
|
2020-10-26 02:29:53 +00:00
|
|
|
#include <common.h> // needed for wxstring hash template
|
2021-03-18 19:31:02 +00:00
|
|
|
#include <kiid.h>
|
2020-07-11 17:40:23 +00:00
|
|
|
#include <project/board_project_settings.h>
|
2020-05-25 17:06:53 +00:00
|
|
|
#include <settings/json_settings.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
#include <settings/nested_settings.h>
|
2020-05-25 17:06:53 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
class BOARD_DESIGN_SETTINGS;
|
|
|
|
class ERC_SETTINGS;
|
2020-05-31 21:42:04 +00:00
|
|
|
class NET_SETTINGS;
|
2020-06-08 02:19:46 +00:00
|
|
|
class SCHEMATIC_SETTINGS;
|
|
|
|
class TEMPLATES;
|
2020-05-25 17:06:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For files like sheets and boards, a pair of that object KIID and display name
|
|
|
|
* Display name is typically blank for the project root sheet
|
|
|
|
*/
|
|
|
|
typedef std::pair<KIID, wxString> FILE_INFO_PAIR;
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
/**
|
|
|
|
* For storing PcbNew MRU paths of various types
|
|
|
|
*/
|
|
|
|
enum LAST_PATH_TYPE : unsigned int
|
|
|
|
{
|
2023-07-12 13:26:52 +00:00
|
|
|
LAST_PATH_FIRST = 0,
|
|
|
|
LAST_PATH_NETLIST = LAST_PATH_FIRST,
|
2020-05-31 21:42:04 +00:00
|
|
|
LAST_PATH_STEP,
|
|
|
|
LAST_PATH_IDF,
|
|
|
|
LAST_PATH_VRML,
|
|
|
|
LAST_PATH_SPECCTRADSN,
|
|
|
|
LAST_PATH_GENCAD,
|
2023-07-12 13:26:52 +00:00
|
|
|
LAST_PATH_POS_FILES,
|
|
|
|
LAST_PATH_SVG,
|
|
|
|
LAST_PATH_PLOT,
|
2023-06-12 18:12:39 +00:00
|
|
|
LAST_PATH_2581,
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
LAST_PATH_SIZE
|
|
|
|
};
|
2020-05-25 17:06:53 +00:00
|
|
|
|
|
|
|
/**
|
2021-03-18 19:31:02 +00:00
|
|
|
* The backing store for a PROJECT, in JSON format.
|
2020-05-25 17:06:53 +00:00
|
|
|
*
|
|
|
|
* There is either zero or one PROJECT_FILE for every PROJECT
|
|
|
|
* (you can have a dummy PROJECT that has no file)
|
|
|
|
*/
|
2024-03-20 01:53:21 +00:00
|
|
|
class KICOMMON_API PROJECT_FILE : public JSON_SETTINGS
|
2020-05-25 17:06:53 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2021-03-18 19:31:02 +00:00
|
|
|
* Construct the project file for a project
|
2020-05-25 17:06:53 +00:00
|
|
|
* @param aFullPath is the full disk path to the project
|
|
|
|
*/
|
2020-08-02 09:23:21 +00:00
|
|
|
PROJECT_FILE( const wxString& aFullPath );
|
2020-05-25 17:06:53 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
virtual ~PROJECT_FILE() = default;
|
|
|
|
|
|
|
|
virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
|
|
|
|
|
2020-08-02 09:23:21 +00:00
|
|
|
bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
|
2020-05-25 17:06:53 +00:00
|
|
|
|
2021-10-30 22:01:19 +00:00
|
|
|
bool SaveAs( const wxString& aDirectory, const wxString& aFile );
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
void SetProject( PROJECT* aProject )
|
|
|
|
{
|
|
|
|
m_project = aProject;
|
|
|
|
}
|
2020-05-25 17:06:53 +00:00
|
|
|
|
2020-05-26 02:27:27 +00:00
|
|
|
std::vector<FILE_INFO_PAIR>& GetSheets()
|
|
|
|
{
|
|
|
|
return m_sheets;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<FILE_INFO_PAIR>& GetBoards()
|
|
|
|
{
|
|
|
|
return m_boards;
|
|
|
|
}
|
|
|
|
|
2022-08-14 11:03:18 +00:00
|
|
|
std::shared_ptr<NET_SETTINGS>& NetSettings()
|
2020-05-31 21:42:04 +00:00
|
|
|
{
|
2022-08-14 11:03:18 +00:00
|
|
|
return m_NetSettings;
|
2020-05-31 21:42:04 +00:00
|
|
|
}
|
|
|
|
|
2020-05-25 17:06:53 +00:00
|
|
|
protected:
|
2020-05-25 20:41:24 +00:00
|
|
|
wxString getFileExt() const override;
|
|
|
|
|
2020-05-25 17:06:53 +00:00
|
|
|
wxString getLegacyFileExt() const override;
|
|
|
|
|
2020-05-26 02:27:27 +00:00
|
|
|
/**
|
|
|
|
* Below are project-level settings that have not been moved to a dedicated file
|
|
|
|
*/
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Shared params, used by more than one application
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// The list of pinned symbol libraries
|
|
|
|
std::vector<wxString> m_PinnedSymbolLibs;
|
|
|
|
|
|
|
|
/// The list of pinned footprint libraries
|
|
|
|
std::vector<wxString> m_PinnedFootprintLibs;
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
std::map<wxString, wxString> m_TextVars;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Eeschema params
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Schematic ERC settings: lifecycle managed by SCHEMATIC
|
|
|
|
ERC_SETTINGS* m_ErcSettings;
|
|
|
|
|
|
|
|
// Schematic editing and misc settings: lifecycle managed by SCHEMATIC
|
|
|
|
SCHEMATIC_SETTINGS* m_SchematicSettings;
|
|
|
|
|
|
|
|
// Legacy parameters LibDir and LibName, for importing old projects
|
|
|
|
wxString m_LegacyLibDir;
|
|
|
|
|
|
|
|
wxArrayString m_LegacyLibNames;
|
|
|
|
|
2020-05-26 02:27:27 +00:00
|
|
|
/**
|
|
|
|
* CvPcb params
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// List of equivalence (equ) files used in the project
|
|
|
|
std::vector<wxString> m_EquivalenceFiles;
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PcbNew params
|
|
|
|
*/
|
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
/// Drawing sheet file
|
|
|
|
wxString m_BoardDrawingSheetFile;
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
/// MRU path storage
|
|
|
|
wxString m_PcbLastPath[LAST_PATH_SIZE];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Board design settings for this project's board. This will be initialized by PcbNew after
|
|
|
|
* loading a board so that BOARD_DESIGN_SETTINGS doesn't need to live in common for now.
|
|
|
|
* Owned by the BOARD; may be null if a board isn't loaded: be careful
|
|
|
|
*/
|
2020-06-08 02:19:46 +00:00
|
|
|
BOARD_DESIGN_SETTINGS* m_BoardSettings;
|
2020-05-31 21:42:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Net settings for this project (owned here)
|
2021-03-18 19:31:02 +00:00
|
|
|
*
|
|
|
|
* @note If we go multi-board in the future, we have to decide whether to use a global
|
|
|
|
* NET_SETTINGS or have one per board. Right now I think global makes more sense
|
|
|
|
* (one set of schematics, one netlist partitioned into multiple boards)
|
2020-05-31 21:42:04 +00:00
|
|
|
*/
|
2021-03-18 19:31:02 +00:00
|
|
|
std::shared_ptr<NET_SETTINGS> m_NetSettings;
|
2020-07-11 17:40:23 +00:00
|
|
|
|
2021-10-24 22:07:06 +00:00
|
|
|
|
|
|
|
std::vector<LAYER_PRESET> m_LayerPresets; /// List of stored layer presets
|
|
|
|
std::vector<VIEWPORT> m_Viewports; /// List of stored viewports (pos + zoom)
|
2022-06-06 20:58:00 +00:00
|
|
|
std::vector<VIEWPORT3D> m_Viewports3D; /// List of stored 3D viewports (view matrixes)
|
2021-06-08 17:47:06 +00:00
|
|
|
|
2023-06-12 18:12:39 +00:00
|
|
|
struct IP2581_BOM m_IP2581Bom; /// IPC-2581 BOM settings
|
|
|
|
|
2021-06-08 17:47:06 +00:00
|
|
|
private:
|
|
|
|
/// An list of schematic sheets in this project
|
|
|
|
std::vector<FILE_INFO_PAIR> m_sheets;
|
|
|
|
|
|
|
|
/// A list of board files in this project
|
|
|
|
std::vector<FILE_INFO_PAIR> m_boards;
|
|
|
|
|
|
|
|
/// A link to the owning PROJECT
|
|
|
|
PROJECT* m_project;
|
2020-05-25 17:06:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
|
|
|
|
|
|
|
|
void to_json( nlohmann::json& aJson, const FILE_INFO_PAIR& aPair );
|
|
|
|
|
|
|
|
void from_json( const nlohmann::json& aJson, FILE_INFO_PAIR& aPair );
|
|
|
|
|
|
|
|
#endif
|