Skip to content

Commit

Permalink
Fixed minor bugs, started implementing Boolean Functions Wizardpage
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed Jun 4, 2024
1 parent 0450a26 commit 5c13b82
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,27 @@

#pragma once

#include "gui/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.h"

#include <QWizardPage>
#include <QGridLayout>
#include <QTabWidget>
#include <QLineEdit>
#include <QTextEdit>
#include <QLabel>

namespace hal {
class GateLibraryWizard;
class BoolWizardPage:public QWizardPage
{
public:
BoolWizardPage(QWidget* parent = nullptr);
//int nextId() const override;
void initializePage() override;
void setData(GateType* gate);

private:
QGridLayout* mLayout;
GateLibraryWizard* mWizard;
GateType* mGate = nullptr;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace hal
{
friend class RAMPortWizardPage;
friend class PinsWizardPage;
friend class BoolWizardPage;
public:
enum PAGE
{
Expand All @@ -62,8 +63,7 @@ namespace hal
BooleanFunction
};

GateLibraryWizard(const GateLibrary* gateLibrary, GateType* gateType, QWidget* parent = nullptr);
GateLibraryWizard(const GateLibrary* gateLibrary, QWidget* parent = nullptr);
GateLibraryWizard(const GateLibrary* gateLibrary, GateType* gateType = nullptr, QWidget* parent = nullptr);

void editGate(GateType* gt);
void addGate();
Expand All @@ -83,12 +83,11 @@ namespace hal
InitWizardPage* initPage;
RAMWizardPage* ramPage;
RAMPortWizardPage* ramportPage;
BoolWizardPage* boolPage;
StateWizardPage* statePage;
BoolWizardPage* boolPage;

QString mName;
QStringList mProperties;
//QList<PinItem*> mPingroups;
PinModel* mPinModel;
GateLibraryTabPin* mPinTab;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace hal
connect(mContentWidget, &GatelibraryContentWidget::triggerDeleteType, this, &GateLibraryManager::handleDeleteType);
connect(mContentWidget, &GatelibraryContentWidget::triggerDoubleClicked, this, &GateLibraryManager::handleEditWizard);

setLayout(mLayout);
setLayout(mLayout);GateLibraryTabGeneral
repolish(); // CALL FROM PARENT
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "gui/gatelibrary_management/gatelibrary_pages/bool_wizardpage.h"

#include <gui/gatelibrary_management/gatelibrary_wizard.h>
#include "gui/gatelibrary_management/gatelibrary_wizard.h"
#include "gui/pin_model/pin_item.h"

namespace hal
{
Expand All @@ -10,11 +10,53 @@ namespace hal
setSubTitle("TODO: subtitle");
mLayout = new QGridLayout(this);
}
// int BoolWizardPage::nextId() const
// {
// auto parentWizard = wizard();
// if(!parentWizard)
// return -1;
// return static_cast<GateLibraryWizard*>(parentWizard)->getNextPageId(GateLibraryWizard::BooleanFunction);
// }

void BoolWizardPage::initializePage(){
mWizard = static_cast<GateLibraryWizard*>(wizard());
QList<PinItem*> pinGroups = mWizard->getPingroups();

if(mGate != nullptr){
auto boolFunctions = mGate->get_boolean_functions();
auto list = QList<QPair<QString, BooleanFunction>>();
int boolFuncCnt = 0;

for(std::pair<const std::basic_string<char>, BooleanFunction> bf : boolFunctions){
QLabel* label = new QLabel(QString::fromStdString(bf.first));
QLineEdit* lineEdit = new QLineEdit(this);
mLayout->addWidget(label, boolFuncCnt, 0);
mLayout->addWidget(lineEdit, boolFuncCnt, 1);
lineEdit->setText(QString::fromStdString(bf.second.to_string()));
boolFuncCnt++;
}
}
else{
if(!pinGroups.empty())
{
int rowCount = 0;
for(PinItem* pinGroup : pinGroups){
if(pinGroup->getItemType() != PinItem::TreeItemType::GroupCreator && pinGroup->getDirection() == "output"){
for(auto item : pinGroup->getChildren())
{
PinItem* pin = static_cast<PinItem*>(item);
if(pin->getItemType() != PinItem::TreeItemType::PinCreator){
QLabel* label = new QLabel(pin->getName());
QString name = label->text();
QLineEdit* lineEdit = new QLineEdit(this);
mLayout->addWidget(label, rowCount, 0);
mLayout->addWidget(lineEdit, rowCount, 1);
rowCount++;
}
}

}
}
}
}

setLayout(mLayout);
}

void BoolWizardPage::setData(GateType *gate){
mGate = gate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,10 @@ namespace hal

void FlipFlopWizardPage::initializePage()
{
qInfo() << field("name").toString();
qInfo() << field("properties").toInt();
//qInfo() << field("name").toString();
//qInfo() << field("properties").toInt();
}

// int FlipFlopWizardPage::nextId() const
// {
// auto parentWizard = wizard();
// if(!parentWizard)
// return -1;
// return static_cast<GateLibraryWizard*>(parentWizard)->getNextPageId(GateLibraryWizard::FlipFlop);
// }

void FlipFlopWizardPage::setData(GateType *gate){
if (gate != nullptr && gate->has_component_of_type(GateTypeComponent::ComponentType::ff))
{
Expand Down
43 changes: 4 additions & 39 deletions plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,11 @@ namespace hal
ramPage->setData(mGateType);
ramportPage->setData(mGateType);
statePage->setData(mGateType);
boolPage->setData(mGateType);
//pinsPage->setGateType(mGateType);
}
}

GateLibraryWizard::GateLibraryWizard(const GateLibrary *gateLibrary, QWidget* parent): QWizard(parent)
{
generalInfoPage = new GeneralInfoWizardPage(gateLibrary, this);
pinsPage = new PinsWizardPage(this);
ffPage = new FlipFlopWizardPage(this);
boolPage = new BoolWizardPage(this);

latchPage = new LatchWizardPage(this);
lutPage = new LUTWizardPage(this);
initPage = new InitWizardPage(this);
ramPage = new RAMWizardPage(this);
ramportPage = new RAMPortWizardPage(this);
statePage = new StateWizardPage(this);

setPage(GeneralInfo, generalInfoPage);
setPage(Pin, pinsPage);
setPage(FlipFlop, ffPage);
setPage(Latch, latchPage);
setPage(LUT, lutPage);
setPage(RAM, ramPage);
setPage(RAMPort, ramportPage);
setPage(Init, initPage);
setPage(State, statePage);
setPage(BooleanFunction, boolPage);
//pinsPage->setGateType(nullptr);
generalInfoPage->setMode(false);
ffPage->setData(nullptr);
mGateLibrary = gateLibrary;

mPinTab = new GateLibraryTabPin(this, true);
mPinModel = new PinModel(this, true);
}

void GateLibraryWizard::editGate(GateType* gt)
{

Expand Down Expand Up @@ -137,12 +105,7 @@ namespace hal
else if(properties.contains("latch")) return Latch;
else if(properties.contains("c_lut")) return LUT;
else if(properties.contains("ram")) return RAM;*/
return BooleanFunction;
case BooleanFunction:
if(properties.contains("ff")) return FlipFlop;
else if(properties.contains("latch")) return Latch;
else if(properties.contains("c_lut")) return LUT;
else if(properties.contains("ram")) return RAM;
return FlipFlop;
case FlipFlop:
if(properties.contains("latch")) return Latch;
else if(properties.contains("c_lut")) return LUT;
Expand All @@ -164,6 +127,8 @@ namespace hal
if(properties.contains("ff") || properties.contains("latch") || properties.contains("c_lut") || properties.contains("ram")) return Init;
else return -1;
case Init:
return BooleanFunction;
case BooleanFunction:
default:
return -1;
}
Expand Down
12 changes: 9 additions & 3 deletions plugins/gui/src/pin_model/pin_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ namespace hal
// creates a new pin which is not valid until now nor created via gate->create_pin()
if(!renamePin(pinItem, input))
break;
pinItem->setFields(input, getNextId(PinItem::TreeItemType::Pin), PinDirection::none, PinType::none);
pinItem->setItemType(PinItem::TreeItemType::InvalidPin);
PinItem* parentGroup = static_cast<PinItem*>(pinItem->getParent());
PinDirection pdir = enum_from_string<PinDirection>(parentGroup->getDirection().toStdString());
PinType ptype = enum_from_string<PinType>(parentGroup->getType().toStdString());
pinItem->setFields(input, getNextId(PinItem::TreeItemType::Pin), pdir, ptype);
if(pdir != PinDirection::none) pinItem->setItemType(PinItem::TreeItemType::Pin);
else pinItem->setItemType(PinItem::TreeItemType::InvalidPin);
mInvalidPins.append(pinItem);

beginInsertRows(index.parent(),0,0);
Expand All @@ -233,6 +237,7 @@ namespace hal
break;
}
}
Q_EMIT dataChanged(index, index);
}

void PinModel::handleEditDirection(QModelIndex index, const QString& direction)
Expand Down Expand Up @@ -305,7 +310,7 @@ namespace hal
break;
}
}
//printGateMember();
Q_EMIT dataChanged(index, index);
}

void PinModel::handleEditType(QModelIndex index, const QString& type)
Expand Down Expand Up @@ -361,6 +366,7 @@ namespace hal
}
}
}
Q_EMIT dataChanged(index, index);
}


Expand Down

0 comments on commit 5c13b82

Please sign in to comment.