Skip to content

Commit

Permalink
Added BooleanFunctionTab to gatelibrary_manager's tab widget
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrKermet committed Dec 6, 2023
1 parent 39e51e6 commit 59d9114
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QPushButton>
#include <QTabWidget>
#include <QTableView>
#include <gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_boolean_function.h>
#include <gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_general.h>

namespace hal
Expand Down Expand Up @@ -98,6 +99,7 @@ namespace hal

GateLibraryTabFlipFlop* mFlipFlopTab;
GateLibraryTabGeneral* mGeneralTab;
GateLibraryTabBooleanFunction* mBooleanFunctionTab;

const GateLibrary* mGateLibrary;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// MIT License
//
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once

#include "gatelibrary_tab_interface.h"
#include "hal_core/defines.h"
#include "hal_core/netlist/gate_library/gate_type.h"

#include <QGridLayout>
#include <QLabel>

namespace hal
{
/**
* Widget which shows information of the boolean functions of a gate
*/
class GateLibraryTabBooleanFunction : public QWidget, public GateLibraryTabInterface
{
Q_OBJECT

public:
GateLibraryTabBooleanFunction(QWidget* parent = nullptr);


void update(GateType* gate) override;


private:

QGridLayout* mGridLayout;

QLabel* mPlaceholderLabel1;
QLabel* mPlaceholderLabel2;
QLabel* mPlaceholderLabel3;
QLabel* mPlaceholderLabel4;
QLabel* mPlaceholderLabel5;

QLabel* mPlaceholderPropertyLabel1;
QLabel* mPlaceholderPropertyLabel2;
QLabel* mPlaceholderPropertyLabel3;
QLabel* mPlaceholderPropertyLabel4;
QLabel* mPlaceholderPropertyLabel5;

};

}
11 changes: 5 additions & 6 deletions plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

#include "gui/graphics_effects/shadow_effect.h"
#include "gui/plugin_relay/gui_plugin_manager.h"
#include <gui/gui_globals.h>
#include "hal_core/netlist/gate_library/gate_library_manager.h"
#include "hal_core/plugin_system/fac_extension_interface.h"

#include <QDebug>
#include <QDir>
#include <QFileDialog>
#include <QHeaderView>
#include <QPushButton>
#include <QLabel>


#include <QPushButton>
#include <QTableWidget>
#include <gui/gui_globals.h>
namespace hal
{
GateLibraryManager::GateLibraryManager(QWidget* parent)
Expand All @@ -35,7 +33,7 @@ namespace hal
mGeneralTab = new GateLibraryTabGeneral(this);
auto* pinPage = new QWidget(this);
mFlipFlopTab = new GateLibraryTabFlipFlop(this);
auto* booleanFunctionPage = new QWidget(this);
mBooleanFunctionTab = new GateLibraryTabBooleanFunction(this);


//buttons
Expand All @@ -49,7 +47,7 @@ namespace hal
mTabWidget->addTab(mGeneralTab, "General");
mTabWidget->addTab(pinPage, "Pins");
mTabWidget->addTab(mFlipFlopTab, "Flip Flops");
mTabWidget->addTab(booleanFunctionPage, "Boolean Functions");
mTabWidget->addTab(mBooleanFunctionTab, "Boolean Functions");


// Add widgets to the layout
Expand Down Expand Up @@ -136,6 +134,7 @@ namespace hal
//update tabs
mFlipFlopTab->update(gate);
mGeneralTab->update(gate);
mBooleanFunctionTab->update(gate);
}

void GateLibraryManager::handleCancelClicked()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

#include "gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_boolean_function.h"

#include "gui/gui_globals.h"


namespace hal
{

GateLibraryTabBooleanFunction::GateLibraryTabBooleanFunction(QWidget* parent) : QWidget(parent)
{
mGridLayout = new QGridLayout(parent);

mPlaceholderLabel1 = new QLabel("Func 1", parent);
mPlaceholderLabel2 = new QLabel("Func 2", parent);
mPlaceholderLabel3 = new QLabel("Func 3", parent);
mPlaceholderLabel4 = new QLabel("Func 4", parent);
mPlaceholderLabel5 = new QLabel("Func 5", parent);

mPlaceholderPropertyLabel1 = new QLabel(" - ", parent);
mPlaceholderPropertyLabel2 = new QLabel(" - ", parent);
mPlaceholderPropertyLabel3 = new QLabel(" - ", parent);
mPlaceholderPropertyLabel4 = new QLabel(" - ", parent);
mPlaceholderPropertyLabel5 = new QLabel(" - ", parent);

mGridLayout->addWidget(mPlaceholderLabel2, 0, 0);
mGridLayout->addWidget(mPlaceholderPropertyLabel2, 0, 1, Qt::AlignLeft);
mGridLayout->addWidget(mPlaceholderLabel1, 1, 0);
mGridLayout->addWidget(mPlaceholderPropertyLabel1, 1, 1, Qt::AlignLeft);
mGridLayout->addWidget(mPlaceholderLabel3, 2, 0);
mGridLayout->addWidget(mPlaceholderPropertyLabel3, 2, 1, Qt::AlignLeft);
mGridLayout->addWidget(mPlaceholderLabel4, 3, 0);
mGridLayout->addWidget(mPlaceholderPropertyLabel4, 3, 1, Qt::AlignLeft);
mGridLayout->addWidget(mPlaceholderLabel5, 4, 0);
mGridLayout->addWidget(mPlaceholderPropertyLabel5, 4, 1, Qt::AlignLeft);

setLayout(mGridLayout);

}

void GateLibraryTabBooleanFunction::update(GateType* gate)
{

if(!gate){
//TODO make default look
mPlaceholderPropertyLabel1->setText("-");
mPlaceholderPropertyLabel2->setText("-");
mPlaceholderPropertyLabel3->setText("-");
mPlaceholderPropertyLabel4->setText("-");
mPlaceholderPropertyLabel5->setText("-");

return;
}

QString str = "";
for(auto pair : gate->get_boolean_functions()){
str.append(QString::fromStdString(pair.first) + " " + QString::fromStdString(pair.second.to_string()) + "\n");
}
mPlaceholderPropertyLabel1->setText(str);


}


}

0 comments on commit 59d9114

Please sign in to comment.