Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #680 from LibrePCB/412-device-check-for-unconnecte…
…d-pads Device editor: Show warning if no pads are connected
- Loading branch information
Showing
7 changed files
with
286 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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 "devicecheck.h" | ||
|
||
#include "device.h" | ||
#include "msg/msgnopadsindeviceconnected.h" | ||
|
||
#include <QtCore> | ||
|
||
/******************************************************************************* | ||
* Namespace | ||
******************************************************************************/ | ||
namespace librepcb { | ||
namespace library { | ||
|
||
/******************************************************************************* | ||
* Constructors / Destructor | ||
******************************************************************************/ | ||
|
||
DeviceCheck::DeviceCheck(const Device& device) noexcept | ||
: LibraryElementCheck(device), mDevice(device) { | ||
} | ||
|
||
DeviceCheck::~DeviceCheck() noexcept { | ||
} | ||
|
||
/******************************************************************************* | ||
* General Methods | ||
******************************************************************************/ | ||
|
||
LibraryElementCheckMessageList DeviceCheck::runChecks() const { | ||
LibraryElementCheckMessageList msgs = LibraryElementCheck::runChecks(); | ||
checkNoPadsConnected(msgs); | ||
return msgs; | ||
} | ||
|
||
/******************************************************************************* | ||
* Protected Methods | ||
******************************************************************************/ | ||
|
||
void DeviceCheck::checkNoPadsConnected(MsgList& msgs) const { | ||
for (const DevicePadSignalMapItem& item : mDevice.getPadSignalMap()) { | ||
if (item.getSignalUuid()) { | ||
return; // pad is connected, don't show this message | ||
} | ||
} | ||
|
||
if (!mDevice.getPadSignalMap().isEmpty()) { | ||
msgs.append(std::make_shared<MsgNoPadsInDeviceConnected>()); | ||
} | ||
} | ||
|
||
/******************************************************************************* | ||
* End of File | ||
******************************************************************************/ | ||
|
||
} // namespace library | ||
} // namespace librepcb |
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,73 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
#ifndef LIBREPCB_LIBRARY_DEVICECHECK_H | ||
#define LIBREPCB_LIBRARY_DEVICECHECK_H | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include "libraryelementcheck.h" | ||
|
||
#include <QtCore> | ||
|
||
/******************************************************************************* | ||
* Namespace / Forward Declarations | ||
******************************************************************************/ | ||
namespace librepcb { | ||
namespace library { | ||
|
||
class Device; | ||
|
||
/******************************************************************************* | ||
* Class DeviceCheck | ||
******************************************************************************/ | ||
|
||
/** | ||
* @brief The DeviceCheck class | ||
*/ | ||
class DeviceCheck : public LibraryElementCheck { | ||
public: | ||
// Constructors / Destructor | ||
DeviceCheck() = delete; | ||
DeviceCheck(const DeviceCheck& other) = delete; | ||
explicit DeviceCheck(const Device& device) noexcept; | ||
virtual ~DeviceCheck() noexcept; | ||
|
||
// General Methods | ||
virtual LibraryElementCheckMessageList runChecks() const override; | ||
|
||
// Operator Overloadings | ||
DeviceCheck& operator=(const DeviceCheck& rhs) = delete; | ||
|
||
protected: // Methods | ||
void checkNoPadsConnected(MsgList& msgs) const; | ||
|
||
private: // Data | ||
const Device& mDevice; | ||
}; | ||
|
||
/******************************************************************************* | ||
* End of File | ||
******************************************************************************/ | ||
|
||
} // namespace library | ||
} // namespace librepcb | ||
|
||
#endif // LIBREPCB_LIBRARY_DEVICECHECK_H |
56 changes: 56 additions & 0 deletions
56
libs/librepcb/library/dev/msg/msgnopadsindeviceconnected.cpp
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,56 @@ | ||
/* | ||
* 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 "msgnopadsindeviceconnected.h" | ||
|
||
/******************************************************************************* | ||
* Namespace | ||
******************************************************************************/ | ||
namespace librepcb { | ||
namespace library { | ||
|
||
/******************************************************************************* | ||
* Constructors / Destructor | ||
******************************************************************************/ | ||
|
||
MsgNoPadsInDeviceConnected::MsgNoPadsInDeviceConnected() noexcept | ||
: LibraryElementCheckMessage( | ||
Severity::Warning, // Only warning because it could be a false-positive | ||
tr("No pads connected"), | ||
tr("The chosen package contains pads, but none of them are connected " | ||
"to component signals. So these pads have no electrical function " | ||
"and when adding the device to a PCB, no traces can be connected to " | ||
"them.\n\nTo fix this issue, connect the package pads to their " | ||
"corresponding component signals in the table widget.\n\nIf all " | ||
"pads have only a mechanical purpose and thus don't need to be " | ||
"connected to component signals, this message can be ignored.")) { | ||
} | ||
|
||
MsgNoPadsInDeviceConnected::~MsgNoPadsInDeviceConnected() noexcept { | ||
} | ||
|
||
/******************************************************************************* | ||
* End of File | ||
******************************************************************************/ | ||
|
||
} // namespace library | ||
} // namespace librepcb |
61 changes: 61 additions & 0 deletions
61
libs/librepcb/library/dev/msg/msgnopadsindeviceconnected.h
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,61 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
#ifndef LIBREPCB_LIBRARY_MSGNOPADSINDEVICECONNECTED_H | ||
#define LIBREPCB_LIBRARY_MSGNOPADSINDEVICECONNECTED_H | ||
|
||
/******************************************************************************* | ||
* Includes | ||
******************************************************************************/ | ||
#include "../../msg/libraryelementcheckmessage.h" | ||
|
||
#include <QtCore> | ||
|
||
/******************************************************************************* | ||
* Namespace / Forward Declarations | ||
******************************************************************************/ | ||
namespace librepcb { | ||
namespace library { | ||
|
||
/******************************************************************************* | ||
* Class MsgNoPadsInDeviceConnected | ||
******************************************************************************/ | ||
|
||
/** | ||
* @brief The MsgNoPadsInDeviceConnected class | ||
*/ | ||
class MsgNoPadsInDeviceConnected final : public LibraryElementCheckMessage { | ||
Q_DECLARE_TR_FUNCTIONS(MsgNoPadsInDeviceConnected) | ||
|
||
public: | ||
// Constructors / Destructor | ||
MsgNoPadsInDeviceConnected() noexcept; | ||
MsgNoPadsInDeviceConnected(const MsgNoPadsInDeviceConnected& other) noexcept | ||
: LibraryElementCheckMessage(other) {} | ||
virtual ~MsgNoPadsInDeviceConnected() noexcept; | ||
}; | ||
|
||
/******************************************************************************* | ||
* End of File | ||
******************************************************************************/ | ||
|
||
} // namespace library | ||
} // namespace librepcb | ||
|
||
#endif // LIBREPCB_LIBRARY_MSGNOPADSINDEVICECONNECTED_H |
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