Loading files
1cafef23aThis file is pinned to the selected release. Download the original to open it in your design tool.
/*
* LibrePCB - Professional EDA for everyone!
* Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
* https://librepcb.org/
*
* 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/>.
*/
/*******************************************************************************
* Includes
******************************************************************************/
#include "fileformatmigrationunstable.h"
#include "../application.h"
#include "../fileio/transactionaldirectory.h"
#include "../types/elementname.h"
#include "../types/simplestring.h"
#include <QtCore>
/*******************************************************************************
* Namespace
******************************************************************************/
namespace librepcb {
/*******************************************************************************
* Constructors / Destructor
******************************************************************************/
FileFormatMigrationUnstable::FileFormatMigrationUnstable(
QObject* parent) noexcept
: FileFormatMigrationV1(parent) {
mFromVersion = mToVersion; // Clearly distinguish from the base class.
}
FileFormatMigrationUnstable::~FileFormatMigrationUnstable() noexcept {
}
/*******************************************************************************
* General Methods
******************************************************************************/
void FileFormatMigrationUnstable::upgradeComponentCategory(
TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
void FileFormatMigrationUnstable::upgradePackageCategory(
TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
void FileFormatMigrationUnstable::upgradeSymbol(TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
void FileFormatMigrationUnstable::upgradePackage(TransactionalDirectory& dir) {
Q_UNUSED(dir);
// Content File.
{
const QString fp = "package.lp";
std::unique_ptr<SExpression> root =
SExpression::parse(dir.read(fp), dir.getAbsPath(fp));
root->appendChild("min_copper_clearance", SExpression::createToken("0.2"));
dir.write(fp, root->toByteArray());
}
}
void FileFormatMigrationUnstable::upgradeComponent(
TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
void FileFormatMigrationUnstable::upgradeDevice(TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
void FileFormatMigrationUnstable::upgradeLibrary(TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
void FileFormatMigrationUnstable::upgradeWorkspaceData(
TransactionalDirectory& dir) {
Q_UNUSED(dir);
}
/*******************************************************************************
* Protected Methods
******************************************************************************/
void FileFormatMigrationUnstable::upgradeOutputJobs(SExpression& root,
ProjectContext& context) {
Q_UNUSED(root);
Q_UNUSED(context);
}
void FileFormatMigrationUnstable::upgradeCircuit(SExpression& root,
QList<Message>& messages) {
Q_UNUSED(messages);
// Net classes.
for (SExpression* classNode : root.getChildren("netclass")) {
classNode->appendChild("default_trace_width",
SExpression::createToken("inherit"));
classNode->appendChild("default_via_drill_diameter",
SExpression::createToken("inherit"));
classNode->appendChild("min_copper_copper_clearance",
SExpression::createToken("0"));
classNode->appendChild("min_copper_width", SExpression::createToken("0"));
classNode->appendChild("min_via_drill_diameter",
SExpression::createToken("0"));
}
}
void FileFormatMigrationUnstable::upgradeBoard(SExpression& root) {
// Design rules
{
SExpression& rulesNode = root.getChild("design_rules");
rulesNode.appendChild("default_trace_width",
SExpression::createToken("0.5"));
rulesNode.appendChild("default_via_drill_diameter",
SExpression::createToken("0.3"));
}
}
/*******************************************************************************
* End of File
******************************************************************************/
} // namespace librepcb