-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
47 changed files
with
1,014 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "board_panel.hpp" | ||
#include "nlohmann/json.hpp" | ||
#include "board.hpp" | ||
|
||
namespace horizon { | ||
BoardPanel::BoardPanel(const UUID &uu, const json &j, const Board &brd) | ||
: uuid(uu), included_board(&brd.included_boards.at(UUID(j.at("included_board").get<std::string>()))), | ||
placement(j.at("placement")), omit_outline(j.value("omit_outline", false)) | ||
{ | ||
} | ||
BoardPanel::BoardPanel(const UUID &uu, const IncludedBoard &inc) : uuid(uu), included_board(&inc) | ||
{ | ||
} | ||
|
||
|
||
json BoardPanel::serialize() const | ||
{ | ||
json j; | ||
j["included_board"] = (std::string)included_board->uuid; | ||
j["placement"] = placement.serialize(); | ||
j["omit_outline"] = omit_outline; | ||
return j; | ||
} | ||
|
||
} // namespace horizon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include "included_board.hpp" | ||
|
||
namespace horizon { | ||
class BoardPanel { | ||
public: | ||
BoardPanel(const UUID &uu, const json &j, const Board &brd); | ||
BoardPanel(const UUID &uu, const IncludedBoard &inc); | ||
|
||
json serialize() const; | ||
|
||
UUID uuid; | ||
uuid_ptr<const IncludedBoard> included_board; | ||
Placement placement; | ||
bool omit_outline = false; | ||
}; | ||
} // namespace horizon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "included_board.hpp" | ||
#include "nlohmann/json.hpp" | ||
#include "project/project.hpp" | ||
#include "pool/pool_manager.hpp" | ||
#include "board/board.hpp" | ||
#include "pool/entity.hpp" | ||
#include "pool/part.hpp" | ||
#include "pool/symbol.hpp" | ||
#include "block/block.hpp" | ||
#include "board/via_padstack_provider.hpp" | ||
#include "pool/pool_cached.hpp" | ||
|
||
namespace horizon { | ||
IncludedBoard::IncludedBoard(const UUID &uu, const Project &prj, const std::string &p) : uuid(uu), project_filename(p) | ||
{ | ||
reload(); | ||
} | ||
|
||
IncludedBoard::IncludedBoard(const UUID &uu, const json &j) | ||
: IncludedBoard(uu, j.at("project_filename").get<std::string>()) | ||
{ | ||
} | ||
|
||
IncludedBoard::IncludedBoard(const UUID &uu, const std::string &prj_filename) | ||
: IncludedBoard(uu, Project::new_from_file(prj_filename), prj_filename) | ||
{ | ||
} | ||
|
||
IncludedBoard::IncludedBoard(const IncludedBoard &other) | ||
: uuid(other.uuid), project_filename(other.project_filename), | ||
pool(std::make_unique<PoolCached>(other.pool->get_base_path(), other.pool->get_cache_path())), | ||
block(std::make_unique<Block>(*other.block)), vpp(std::make_unique<ViaPadstackProvider>(*other.vpp)), | ||
board(std::make_unique<Board>(*other.board)) | ||
{ | ||
board->block = block.get(); | ||
board->update_refs(); | ||
} | ||
|
||
void IncludedBoard::reload() | ||
{ | ||
auto prj = Project::new_from_file(project_filename); | ||
reset(); | ||
|
||
try { | ||
pool = std::make_unique<PoolCached>(horizon::PoolManager::get().get_by_uuid(prj.pool_uuid)->base_path, | ||
prj.pool_cache_directory); | ||
block = std::make_unique<Block>(horizon::Block::new_from_file(prj.get_top_block().block_filename, *pool)); | ||
vpp = std::make_unique<ViaPadstackProvider>(prj.vias_directory, *pool); | ||
board = std::make_unique<Board>(horizon::Board::new_from_file(prj.board_filename, *block, *pool, *vpp)); | ||
board->expand(); | ||
} | ||
catch (...) { | ||
reset(); | ||
throw; | ||
} | ||
} | ||
|
||
void IncludedBoard::reset() | ||
{ | ||
pool.reset(); | ||
block.reset(); | ||
board.reset(); | ||
vpp.reset(); | ||
} | ||
|
||
bool IncludedBoard::is_valid() const | ||
{ | ||
return board != nullptr; | ||
} | ||
|
||
json IncludedBoard::serialize() const | ||
{ | ||
json j; | ||
j["project_filename"] = project_filename; | ||
return j; | ||
} | ||
|
||
std::string IncludedBoard::get_name() const | ||
{ | ||
if (!is_valid()) | ||
return "invalid"; | ||
else if (block->project_meta.count("project_title")) | ||
return block->project_meta.at("project_title"); | ||
else | ||
return "unknown"; | ||
} | ||
|
||
UUID IncludedBoard::get_uuid() const | ||
{ | ||
return uuid; | ||
} | ||
} // namespace horizon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include "util/uuid.hpp" | ||
#include "nlohmann/json_fwd.hpp" | ||
#include "pool/pool_cached.hpp" | ||
#include <memory> | ||
|
||
namespace horizon { | ||
using json = nlohmann::json; | ||
|
||
class IncludedBoard { | ||
public: | ||
IncludedBoard(const UUID &uu, const json &j); | ||
IncludedBoard(const UUID &uu, const std::string &p); | ||
IncludedBoard(const IncludedBoard &other); | ||
json serialize() const; | ||
UUID get_uuid() const; | ||
std::string get_name() const; | ||
void reload(); | ||
bool is_valid() const; | ||
|
||
UUID uuid; | ||
std::string project_filename; | ||
|
||
std::unique_ptr<class PoolCached> pool; | ||
std::unique_ptr<class Block> block; | ||
std::unique_ptr<class ViaPadstackProvider> vpp; | ||
std::unique_ptr<class Board> board; | ||
|
||
private: | ||
IncludedBoard(const UUID &uu, const class Project &prj, const std::string &p); | ||
void reset(); | ||
}; | ||
} // namespace horizon |
Oops, something went wrong.