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: Allow to hide copper planes #531

Merged
merged 2 commits into from Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added img/actions/hide_planes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/actions/show_planes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions img/images.qrc
Expand Up @@ -37,6 +37,7 @@
<file>actions/generate_bom.png</file>
<file>actions/grid.png</file>
<file>actions/help.png</file>
<file>actions/hide_planes.png</file>
<file>actions/home.png</file>
<file>actions/info.png</file>
<file>actions/layers.png</file>
Expand Down Expand Up @@ -67,6 +68,7 @@
<file>actions/select.png</file>
<file>actions/select_rect.png</file>
<file>actions/settings.png</file>
<file>actions/show_planes.png</file>
<file>actions/stop.png</file>
<file>actions/undo.png</file>
<file>actions/up.png</file>
Expand Down
10 changes: 6 additions & 4 deletions libs/librepcb/project/boards/graphicsitems/bgi_plane.cpp
Expand Up @@ -110,10 +110,12 @@ void BGI_Plane::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
painter->setBrush(Qt::NoBrush);
painter->drawPath(mOutline);

// draw plane
painter->setPen(Qt::NoPen);
painter->setBrush(mLayer->getColor(selected));
foreach (const QPainterPath& area, mAreas) { painter->drawPath(area); }
// draw plane only if plane should be visible
if (mPlane.isVisible()) {
painter->setPen(Qt::NoPen);
painter->setBrush(mLayer->getColor(selected));
foreach (const QPainterPath& area, mAreas) { painter->drawPath(area); }
}
}

#ifdef QT_DEBUG
Expand Down
18 changes: 14 additions & 4 deletions libs/librepcb/project/boards/items/bi_plane.cpp
Expand Up @@ -55,6 +55,7 @@ BI_Plane::BI_Plane(Board& board, const BI_Plane& other)
mConnectStyle(other.mConnectStyle),
// mThermalGapWidth(other.mThermalGapWidth),
// mThermalSpokeWidth(other.mThermalSpokeWidth),
mIsVisible(true),
mFragments(other.mFragments) // also copy fragments to avoid the need for
// a rebuild
{
Expand All @@ -71,10 +72,11 @@ BI_Plane::BI_Plane(Board& board, const SExpression& node)
mMinClearance(node.getValueByPath<UnsignedLength>("min_clearance")),
mKeepOrphans(node.getValueByPath<bool>("keep_orphans")),
mPriority(node.getValueByPath<int>("priority")),
mConnectStyle(node.getValueByPath<ConnectStyle>("connect_style"))
// mThermalGapWidth(node.getValueByPath<Length>("thermal_gap_width", true)),
// mThermalSpokeWidth(node.getValueByPath<Length>("thermal_spoke_width", true))
{
mConnectStyle(node.getValueByPath<ConnectStyle>("connect_style")),
// mThermalGapWidth(node.getValueByPath<Length>("thermal_gap_width", true)),
// mThermalSpokeWidth(node.getValueByPath<Length>("thermal_spoke_width",
// true))
mIsVisible(true) {
Uuid netSignalUuid = node.getValueByPath<Uuid>("net");
mNetSignal =
mBoard.getProject().getCircuit().getNetSignalByUuid(netSignalUuid);
Expand All @@ -101,6 +103,7 @@ BI_Plane::BI_Plane(Board& board, const Uuid& uuid,
mPriority(0),
mConnectStyle(ConnectStyle::Solid),
// mThermalGapWidth(100000), mThermalSpokeWidth(100000),
mIsVisible(true),
mFragments() {
init();
}
Expand Down Expand Up @@ -182,6 +185,13 @@ void BI_Plane::setKeepOrphans(bool keepOrphans) noexcept {
}
}

void BI_Plane::setVisible(bool visible) noexcept {
if (visible != mIsVisible) {
mIsVisible = visible;
mGraphicsItem->update();
}
}

/*******************************************************************************
* General Methods
******************************************************************************/
Expand Down
3 changes: 3 additions & 0 deletions libs/librepcb/project/boards/items/bi_plane.h
Expand Up @@ -87,6 +87,7 @@ class BI_Plane final : public BI_Base, public SerializableObject {
const Path& getOutline() const noexcept { return mOutline; }
const QVector<Path>& getFragments() const noexcept { return mFragments; }
bool isSelectable() const noexcept override;
bool isVisible() const noexcept { return mIsVisible; }

// Setters
void setOutline(const Path& outline) noexcept;
Expand All @@ -97,6 +98,7 @@ class BI_Plane final : public BI_Base, public SerializableObject {
void setConnectStyle(ConnectStyle style) noexcept;
void setPriority(int priority) noexcept;
void setKeepOrphans(bool keepOrphans) noexcept;
void setVisible(bool visible) noexcept;

// General Methods
void addToBoard() override;
Expand Down Expand Up @@ -142,6 +144,7 @@ private slots:
// Length mThermalSpokeWidth;
// style [round square miter] ?
QScopedPointer<BGI_Plane> mGraphicsItem;
bool mIsVisible; // volatile, not saved to file

QVector<Path> mFragments;
};
Expand Down
16 changes: 16 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/boardeditor.cpp
Expand Up @@ -531,6 +531,22 @@ void BoardEditor::on_actionRebuildPlanes_triggered() {
}
}

void BoardEditor::on_actionShowAllPlanes_triggered() {
if (Board* board = getActiveBoard()) {
foreach (BI_Plane* plane, board->getPlanes()) {
plane->setVisible(true); // No undo command needed since it is not saved
}
}
}

void BoardEditor::on_actionHideAllPlanes_triggered() {
if (Board* board = getActiveBoard()) {
foreach (BI_Plane* plane, board->getPlanes()) {
plane->setVisible(false); // No undo command needed since it is not saved
}
}
}

void BoardEditor::on_tabBar_currentChanged(int index) {
setActiveBoardIndex(index);
}
Expand Down
2 changes: 2 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/boardeditor.h
Expand Up @@ -108,6 +108,8 @@ private slots:
void on_actionLayerStackSetup_triggered();
void on_actionModifyDesignRules_triggered();
void on_actionRebuildPlanes_triggered();
void on_actionShowAllPlanes_triggered();
void on_actionHideAllPlanes_triggered();
void on_tabBar_currentChanged(int index);
void on_lblUnplacedComponentsNote_linkActivated();
void boardListActionGroupTriggered(QAction* action);
Expand Down
21 changes: 21 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/boardeditor.ui
Expand Up @@ -112,6 +112,9 @@
</property>
<addaction name="actionGrid"/>
<addaction name="separator"/>
<addaction name="actionHideAllPlanes"/>
<addaction name="actionShowAllPlanes"/>
<addaction name="separator"/>
<addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/>
<addaction name="actionZoomAll"/>
Expand Down Expand Up @@ -760,6 +763,24 @@
<string>Generate BOM</string>
</property>
</action>
<action name="actionShowAllPlanes">
<property name="icon">
<iconset resource="../../../../img/images.qrc">
<normaloff>:/img/actions/show_planes.png</normaloff>:/img/actions/show_planes.png</iconset>
</property>
<property name="text">
<string>Show All Planes</string>
</property>
</action>
<action name="actionHideAllPlanes">
<property name="icon">
<iconset resource="../../../../img/images.qrc">
<normaloff>:/img/actions/hide_planes.png</normaloff>:/img/actions/hide_planes.png</iconset>
</property>
<property name="text">
<string>Hide All Planes</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
16 changes: 16 additions & 0 deletions libs/librepcb/projecteditor/boardeditor/fsm/bes_select.cpp
Expand Up @@ -444,6 +444,10 @@ BES_Base::ProcRetVal BES_Select::proccessIdleSceneRightMouseButtonReleased(
QAction* aRemove =
menu.addAction(QIcon(":/img/actions/delete.png"), "Remove Plane");
menu.addSeparator();
QAction* aIsVisible = menu.addAction(tr("Visible"));
aIsVisible->setCheckable(true);
aIsVisible->setChecked(plane->isVisible());
menu.addSeparator();
QAction* aProperties = menu.addAction(QIcon(":/img/actions/settings.png"),
tr("Plane Properties"));

Expand All @@ -457,6 +461,9 @@ BES_Base::ProcRetVal BES_Select::proccessIdleSceneRightMouseButtonReleased(
flipSelectedItems(Qt::Horizontal);
} else if (action == aRemove) {
removeSelectedItems();
} else if (action == aIsVisible) {
// Visibility is not saved, thus no undo command is needed here.
plane->setVisible(aIsVisible->isChecked());
} else if (action == aProperties) {
openPlanePropertiesDialog(*plane);
}
Expand Down Expand Up @@ -750,7 +757,16 @@ void BES_Select::openViaPropertiesDialog(BI_Via& via) noexcept {

void BES_Select::openPlanePropertiesDialog(BI_Plane& plane) noexcept {
BoardPlanePropertiesDialog dialog(mProject, plane, mUndoStack, &mEditor);

// Make sure the plane is visible visible since it's useful to see the actual
// plane fragments while the plane properties are modified.
bool visible = plane.isVisible();
plane.setVisible(true);

dialog.exec();

// Restore visibility
plane.setVisible(visible);
}

void BES_Select::openPolygonPropertiesDialog(Board& board,
Expand Down