Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Board Editor: Simplify Trace command #737

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ yourself by creating a pull request (see [CONTRIBUTING.md](CONTRIBUTING.md)).
- [@chrisgwerder](https://github.com/chrisgwerder)
- [@0xB767B](https://github.com/0xB767B)
- Josua Schmid ([@schmijos](https://github.com/schmijos))
- Lucas Keune ([@5n8ke](https://github.com/5n8ke))
16 changes: 11 additions & 5 deletions libs/librepcb/project/boards/items/bi_netpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@ void BI_NetPoint::removeFromBoard() {
}

void BI_NetPoint::registerNetLine(BI_NetLine& netline) {
if ((!isAddedToBoard()) || (mRegisteredNetLines.contains(&netline)) ||
(&netline.getNetSegment() != &mNetSegment) ||
((mRegisteredNetLines.count() > 0) &&
(&netline.getLayer() != getLayerOfLines()))) {
throw LogicError(__FILE__, __LINE__);
if (!isAddedToBoard()) {
throw LogicError(__FILE__, __LINE__, "NetPoint is not added to the board.");
} else if (mRegisteredNetLines.contains(&netline)) {
throw LogicError(__FILE__, __LINE__,
"NetLine already registered to NetPoint.");
} else if (&netline.getNetSegment() != &mNetSegment) {
throw LogicError(__FILE__, __LINE__,
"NetLine is part of a different NetSegment.");
} else if ((mRegisteredNetLines.count() > 0) &&
(&netline.getLayer() != getLayerOfLines())) {
throw LogicError(__FILE__, __LINE__, "NetLine is on a different layer.");
}
mRegisteredNetLines.insert(&netline);
netline.updateLine();
Expand Down
12 changes: 8 additions & 4 deletions libs/librepcb/project/boards/items/bi_netsegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,15 @@ void BI_NetSegment::removeElements(const QList<BI_Via*>& vias,
const QList<BI_NetPoint*>& netpoints,
const QList<BI_NetLine*>& netlines) {
if (!isAddedToBoard()) {
throw LogicError(__FILE__, __LINE__);
throw LogicError(__FILE__, __LINE__,
"Element to be removed not added to board.");
}

ScopeGuardList sgl(netpoints.count() + netlines.count());
foreach (BI_NetLine* netline, netlines) {
if (!mNetLines.contains(netline)) {
throw LogicError(__FILE__, __LINE__);
throw LogicError(__FILE__, __LINE__,
"Netline to be removed not part of the netsegment.");
}
// remove from board
netline->removeFromBoard(); // can throw
Expand All @@ -417,7 +419,8 @@ void BI_NetSegment::removeElements(const QList<BI_Via*>& vias,
}
foreach (BI_NetPoint* netpoint, netpoints) {
if (!mNetPoints.contains(netpoint)) {
throw LogicError(__FILE__, __LINE__);
throw LogicError(__FILE__, __LINE__,
"Netpoint to be removed not part of the netsegment.");
}
// remove from board
netpoint->removeFromBoard(); // can throw
Expand All @@ -429,7 +432,8 @@ void BI_NetSegment::removeElements(const QList<BI_Via*>& vias,
}
foreach (BI_Via* via, vias) {
if (!mVias.contains(via)) {
throw LogicError(__FILE__, __LINE__);
throw LogicError(__FILE__, __LINE__,
"Via to be removed not part of the netsegment.");
}
// remove from board
via->removeFromBoard(); // can throw
Expand Down
5 changes: 5 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/boardeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ BoardEditor::BoardEditor(ProjectEditor& projectEditor, Project& project)
mUi->actionToolAddText);
mToolsActionGroup->addAction(BoardEditorFsm::State::ADD_HOLE,
mUi->actionToolAddHole);
mToolsActionGroup->addAction(BoardEditorFsm::State::SIMPLIFY,
mUi->actionToolSimplify);
mToolsActionGroup->setCurrentAction(mFsm->getCurrentState());
connect(mFsm.data(), &BoardEditorFsm::stateChanged, mToolsActionGroup.data(),
&ExclusiveActionGroup::setCurrentAction);
Expand Down Expand Up @@ -874,6 +876,9 @@ void BoardEditor::toolActionGroupChangeTriggered(
case BoardEditorFsm::State::ADD_HOLE:
mFsm->processAddHole();
break;
case BoardEditorFsm::State::SIMPLIFY:
mFsm->processSimplify();
break;
default:
Q_ASSERT(false);
qCritical() << "Unknown tool triggered!";
Expand Down
Loading