diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 786041ce..ecd7bc2a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -356,7 +356,6 @@ void InsightWindow::selectVariant(const TargetVariant* variant) { ) { this->targetPackageWidget = new InsightTargetWidgets::Dip::DualInlinePackageWidget( *variant, - this, this->insightWorker, this->ioContainerWidget ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp index 7d7c193b..66707a38 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/BodyWidget.cpp @@ -31,11 +31,8 @@ void BodyWidget::drawWidget(QPainter& painter) { painter.setPen(Qt::PenStyle::NoPen); painter.setBrush(targetBodyColor); - auto parentContainerWidth = parentWidget->width(); - auto targetBodyHeight = 150; - auto targetBodyWidth = parentContainerWidth; + auto targetBodyHeight = this->height(); - this->setFixedSize(targetBodyWidth, targetBodyHeight); auto targetBodyPoint = QPoint( 0, 0 @@ -44,7 +41,7 @@ void BodyWidget::drawWidget(QPainter& painter) { painter.drawRect( targetBodyPoint.x(), targetBodyPoint.y(), - targetBodyWidth, + this->width(), targetBodyHeight ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp index 6c20381f..f2f59aad 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.cpp @@ -1,6 +1,5 @@ #include "DualInlinePackageWidget.hpp" -#include #include #include #include @@ -8,8 +7,6 @@ #include #include "../../../InsightWindow.hpp" -#include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" #include "src/Helpers/Paths.hpp" #include "PinWidget.hpp" #include "BodyWidget.hpp" @@ -21,7 +18,6 @@ using Bloom::Targets::TargetVariant; DualInlinePackageWidget::DualInlinePackageWidget( const TargetVariant& targetVariant, - QObject* insightWindowObj, InsightWorker& insightWorker, QWidget* parent ): TargetPackageWidget(targetVariant, insightWorker, parent) { @@ -39,13 +35,10 @@ DualInlinePackageWidget::DualInlinePackageWidget( this->layout->setContentsMargins(0, 0, 0, 0); this->topPinLayout = new QHBoxLayout(); - this->topPinLayout->setSpacing(8); + this->topPinLayout->setSpacing(PinWidget::WIDTH_SPACING); this->topPinLayout->setDirection(QBoxLayout::Direction::RightToLeft); this->bottomPinLayout = new QHBoxLayout(); - this->bottomPinLayout->setSpacing(8); - - auto insightWindow = qobject_cast(insightWindowObj); - assert(insightWindow != nullptr); + this->bottomPinLayout->setSpacing(PinWidget::WIDTH_SPACING); for (const auto& [targetPinNumber, targetPinDescriptor]: targetVariant.pinDescriptorsByNumber) { auto pinWidget = new PinWidget(targetPinDescriptor, targetVariant, insightWorker, this); @@ -64,64 +57,29 @@ DualInlinePackageWidget::DualInlinePackageWidget( this->layout->addLayout(this->bottomPinLayout); this->setLayout(this->layout); - auto insightWindowWidget = this->window(); - assert(insightWindowWidget != nullptr); + const auto bodyWidgetWidth = ((PinWidget::MINIMUM_WIDTH + PinWidget::WIDTH_SPACING) + * static_cast(this->pinWidgets.size() / 2)) - PinWidget::WIDTH_SPACING + 46; + const auto bodyWidgetHeight = 150; - insightWindowWidget->setMinimumHeight(540); - insightWindowWidget->setMinimumWidth(1100); -} - -void DualInlinePackageWidget::paintEvent(QPaintEvent* event) { -// Logger::debug("Drawing main package widget"); - - auto painter = QPainter(this); - this->drawWidget(painter); -} - -void DualInlinePackageWidget::resizeEvent(QResizeEvent* event) { -// Logger::debug("RESIZE EVENT"); -} - -void DualInlinePackageWidget::drawWidget(QPainter& painter) { - auto parentWidget = this->parentWidget(); - - if (parentWidget == nullptr) { - throw Exception("DualInlinePackageWidget requires a parent widget"); - } - - auto parentContainerHeight = parentWidget->height(); - auto parentContainerWidth = parentWidget->width(); - - auto width = ((PinWidget::MINIMUM_WIDTH + 8) * static_cast(this->pinWidgets.size() / 2)) + 46; + const auto width = bodyWidgetWidth; + const auto height = (PinWidget::MAXIMUM_HEIGHT * 2) + bodyWidgetHeight + (8 * 3); + this->bodyWidget->setGeometry(0, PinWidget::MAXIMUM_HEIGHT + 8, width, bodyWidgetHeight); this->topPinLayout->setGeometry(QRect(0, 0, width, PinWidget::MAXIMUM_HEIGHT)); - auto bodyGeometry = QRect(0, this->topPinLayout->geometry().height() + 8, width, this->bodyWidget->height()); - this->bodyWidget->setGeometry(bodyGeometry); this->bottomPinLayout->setGeometry( QRect( 0, - bodyGeometry.top() + bodyGeometry.height() + 8, + (PinWidget::MAXIMUM_HEIGHT + bodyWidgetHeight + (8 * 2)), width, PinWidget::MAXIMUM_HEIGHT ) ); - this->topPinLayout->setContentsMargins( - static_cast(width * 0.04), - 0, - static_cast(width * 0.04), - 0 - ); - this->bottomPinLayout->setContentsMargins( - static_cast(width * 0.04), - 0, - static_cast(width * 0.04), - 0 - ); + this->topPinLayout->setContentsMargins(23, 0, 23, 0); + this->bottomPinLayout->setContentsMargins( 23, 0, 23, 0); - auto height = (PinWidget::MAXIMUM_HEIGHT * 2) + bodyGeometry.height() + (8 * 3); this->setGeometry( - (parentContainerWidth / 2) - (width / 2), - (parentContainerHeight / 2) - (height / 2), + (parent->width() / 2) - (width / 2), + (parent->height() / 2) - (height / 2), width, height ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp index 5ec51917..9663e162 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/DualInlinePackageWidget.hpp @@ -24,15 +24,9 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip QHBoxLayout* bottomPinLayout = nullptr; BodyWidget* bodyWidget = nullptr; - protected: - void paintEvent(QPaintEvent* event) override; - void resizeEvent(QResizeEvent* event) override; - void drawWidget(QPainter& painter); - public: DualInlinePackageWidget( const Targets::TargetVariant& targetVariant, - QObject* insightWindowObj, InsightWorker& insightWorker, QWidget* parent ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp index 4d78ba32..26211490 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/PinWidget.hpp @@ -28,6 +28,7 @@ namespace Bloom::Widgets::InsightTargetWidgets::Dip public: static const int MINIMUM_WIDTH = 30; + static const int WIDTH_SPACING = 8; static const int MAXIMUM_LABEL_COUNT = 3; static const int LABEL_HEIGHT = 20; static const int MAXIMUM_HEIGHT = PinBodyWidget::HEIGHT