Skip to content

Commit

Permalink
Begin implementation of "simplify" command
Browse files Browse the repository at this point in the history
- New Tool class created and added to GUI
- Merge NetPoints at the same location
- Connect Vias with the NetPoints at the same location
- Remove duplicate NetLines with the same start and end points
- Add default nullptr when searching for items at location
- Plan out other simplifications
- Add myself to AUTHORS.md
  • Loading branch information
5n8ke committed Aug 4, 2020
1 parent 9d06ac2 commit 22c9f31
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 14 deletions.
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))
29 changes: 15 additions & 14 deletions libs/librepcb/project/boards/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,21 @@ class Board final : public QObject,
}
bool isEmpty() const noexcept;
QList<BI_Base*> getItemsAtScenePos(const Point& pos) const noexcept;
QList<BI_Via*> getViasAtScenePos(const Point& pos,
const NetSignal* netsignal) const noexcept;
QList<BI_NetPoint*> getNetPointsAtScenePos(const Point& pos,
const GraphicsLayer* layer,
const NetSignal* netsignal) const
noexcept;
QList<BI_NetLine*> getNetLinesAtScenePos(const Point& pos,
const GraphicsLayer* layer,
const NetSignal* netsignal) const
noexcept;
QList<BI_FootprintPad*> getPadsAtScenePos(const Point& pos,
const GraphicsLayer* layer,
const NetSignal* netsignal) const
noexcept;
QList<BI_Via*> getViasAtScenePos(const Point& pos,
const NetSignal* netsignal = nullptr)
const noexcept;
QList<BI_NetPoint*> getNetPointsAtScenePos(const Point& pos,
const GraphicsLayer* layer = nullptr,
const NetSignal* netsignal = nullptr)
const noexcept;
QList<BI_NetLine*> getNetLinesAtScenePos(const Point& pos,
const GraphicsLayer* layer = nullptr,
const NetSignal* netsignal = nullptr)
const noexcept;
QList<BI_FootprintPad*> getPadsAtScenePos(const Point& pos,
const GraphicsLayer* layer = nullptr,
const NetSignal* netsignal = nullptr)
const noexcept;
QList<BI_Base*> getAllItems() const noexcept;

// Setters: General
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 @@ -208,6 +208,8 @@ BoardEditor::BoardEditor(ProjectEditor& projectEditor, Project& project)
mUi->actionToolAddText);
mToolsActionGroup->addAction(BES_FSM::State::State_AddHole,
mUi->actionToolAddHole);
mToolsActionGroup->addAction(BES_FSM::State::State_Simplify,
mUi->actionToolSimplify);
mToolsActionGroup->setCurrentAction(mFsm->getCurrentState());
connect(mFsm, &BES_FSM::stateChanged, mToolsActionGroup.data(),
&ExclusiveActionGroup::setCurrentAction);
Expand Down Expand Up @@ -812,6 +814,9 @@ void BoardEditor::toolActionGroupChangeTriggered(
case BES_FSM::State::State_AddHole:
mFsm->processEvent(new BEE_Base(BEE_Base::StartAddHole), true);
break;
case BES_FSM::State::State_Simplify:
mFsm->processEvent(new BEE_Base(BEE_Base::StartSimplify), true);
break;
default:
Q_ASSERT(false);
qCritical() << "Unknown tool triggered!";
Expand Down
14 changes: 14 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/boardeditor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<addaction name="actionToolSelect"/>
<addaction name="actionToolAddVia"/>
<addaction name="actionToolDrawTrace"/>
<addaction name="actionToolSimplify"/>
<addaction name="actionToolDrawPolygon"/>
<addaction name="actionToolAddText"/>
<addaction name="actionToolAddHole"/>
Expand Down Expand Up @@ -272,6 +273,7 @@
<addaction name="actionToolSelect"/>
<addaction name="actionToolAddVia"/>
<addaction name="actionToolDrawTrace"/>
<addaction name="actionToolSimplify"/>
<addaction name="actionToolDrawPolygon"/>
<addaction name="actionToolAddText"/>
<addaction name="actionToolAddHole"/>
Expand Down Expand Up @@ -926,6 +928,18 @@
<string notr="true">Ctrl+A</string>
</property>
</action>
<action name="actionToolSimplify">
<property name="icon">
<iconset>
<normaloff>:/img/actions/ruler.png</normaloff>:/img/actions/ruler.png</iconset>
</property>
<property name="text">
<string>Simplify</string>
</property>
<property name="toolTip">
<string>Simplify traces</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
7 changes: 7 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/fsm/bes_fsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "bes_drawpolygon.h"
#include "bes_drawtrace.h"
#include "bes_select.h"
#include "bes_simplify.h"
#include "boardeditorevent.h"
#include "ui_boardeditor.h"

Expand Down Expand Up @@ -80,6 +81,9 @@ BES_FSM::BES_FSM(BoardEditor& editor, Ui::BoardEditor& editorUi,
mSubStates.insert(
State_AddHole,
new BES_AddHole(mEditor, mEditorUi, mEditorGraphicsView, mUndoStack));
mSubStates.insert(
State_Simplify,
new BES_Simplify(mEditor, mEditorUi, mEditorGraphicsView, mUndoStack));

// go to state "Select"
if (mSubStates[State_Select]->entry(nullptr)) {
Expand Down Expand Up @@ -190,6 +194,9 @@ BES_FSM::State BES_FSM::processEventFromChild(BEE_Base* event) noexcept {
case BEE_Base::StartAddDevice:
event->setAccepted(true);
return State_AddDevice;
case BEE_Base::StartSimplify:
event->setAccepted(true);
return State_Simplify;
case BEE_Base::GraphicsViewEvent: {
QEvent* e = BEE_RedirectedQEvent::getQEventFromBEE(event);
Q_ASSERT(e);
Expand Down
1 change: 1 addition & 0 deletions libs/librepcb/projecteditor/boardeditor/fsm/bes_fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class BES_FSM final : public BES_Base {
State_AddVia, ///< ::librepcb::project::editor::BES_AddVia
State_AddDevice, ///< ::librepcb::project::editor::BES_AddDevice
State_DrawPlane, ///< ::librepcb::project::editor::BES_DrawPlane
State_Simplify, ///< ::librepcb::project::editor::BES_Simplify
};

// Constructors / Destructor
Expand Down
Loading

0 comments on commit 22c9f31

Please sign in to comment.