Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
nils1603 committed Sep 15, 2023
2 parents fb68a73 + 81b8107 commit ff71bda
Show file tree
Hide file tree
Showing 31 changed files with 1,654 additions and 215 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ All notable changes to this project will be documented in this file.

## [Unreleased]
* miscellaneous
* added GUI PluginParameter type 'ComboBox' for parameters that can be requested from plugin
* added GUI PluginParameter types 'Module' and 'Gated' for parameters that can be requested from plugin
* added `Show content` button to `Groupings` widget to show content of grouping as a list
* added flag which python editor tab is active when serializing project
* added `GateType::delete_pin_group` and `GateType::assign_pin_to_group` to enable more operations on pin groups of gate pins
* added extended gate library picker when importing a netlist
* changed supported input file formats for import from hard coded list to list provided by loadable parser plugins
* changed behavior of import netlist dialog, suggest only non-existing directory names and loop until an acceptable name was entered
* changed appearance and behavior of import project dialog, make sure existing hal projects don't get overwritten
* bugfixes
* fixed colors in Python Console when switching between color schemes
* fixed pybind of `Module::get_gates`
Expand Down
2 changes: 1 addition & 1 deletion include/hal_core/plugin_system/plugin_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace hal
class PluginParameter
{
public:
enum ParameterType { Absent, Boolean, Color, Dictionary, ExistingDir, Float, Integer, NewFile, PushButton, String, TabName };
enum ParameterType { Absent, Boolean, Color, ComboBox, Dictionary, ExistingDir, Float, Gate, Integer, Module, NewFile, PushButton, String, TabName };
private:
ParameterType m_type;
std::string m_tagname;
Expand Down
9 changes: 7 additions & 2 deletions plugins/gui/include/gui/export/import_project_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ namespace hal
ImportStatus mStatus;
FileSelectWidget* mZippedFile;
FileSelectWidget* mTargetDirectory;
QLineEdit* mExtractProjectEdit;
QDialogButtonBox* mButtonBox;
QString mExtractedProjectDir;
QString mTargetProjectName;
QString mExtractedProjectAbsolutePath;
static void deleteFilesList(QStringList files);
static void deleteFilesRecursion(QString dir);
private Q_SLOTS:
void handleSelectionStatusChanged();
public:
ImportProjectDialog(QWidget* parent = nullptr);
bool importProject();
ImportStatus status() const { return mStatus; }
QString extractedProjectDir() const { return mExtractedProjectDir; }
QString extractedProjectAbsolutePath() const { return mExtractedProjectAbsolutePath; }
static QString suggestedProjectDir(const QString& filename);
};
}
10 changes: 4 additions & 6 deletions plugins/gui/include/gui/file_manager/import_netlist_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,29 @@
#include <QList>
#include <QMap>

class QComboBox;
class QCheckBox;
class QLineEdit;

namespace hal {

class GateLibrarySelection;

class ImportNetlistDialog : public QDialog
{
Q_OBJECT
Q_PROPERTY(QString saveIconPath READ saveIconPath WRITE setSaveIconPath)
Q_PROPERTY(QString saveIconStyle READ saveIconStyle WRITE setSaveIconStyle)
QString mProjectdir;
QLineEdit* mEditProjectdir;
QComboBox* mComboGatelib;
GateLibrarySelection* mGatelibSelection;
QCheckBox* mCheckMoveNetlist;
QCheckBox* mCheckCopyGatelib;

QStringList mGateLibraryPath;
QMap<QString,int> mGateLibraryMap;
QString mSaveIconPath;
QString mSaveIconStyle;
private Q_SLOTS:
void handleGateLibraryPathChanged(const QString& txt);
void handleGatelibSelected(bool singleFile);
void handleFileDialogTriggered();
void setSuggestedProjectDir(const QString& filename);
public:
ImportNetlistDialog(const QString& filename, QWidget* parent = nullptr);
QString projectDirectory() const;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// 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 <QFrame>
#include <QLabel>
#include <QAbstractTableModel>
#include <QModelIndex>

class QComboBox;
class QPushButton;
class QCheckBox;

namespace hal {
class GateLibrarySelectionEntry
{
QString mName;
QString mPath;
int mCount;
public:
GateLibrarySelectionEntry(const QString& name_, const QString& path_, int cnt)
: mName(name_), mPath(path_), mCount(cnt) {;}
QVariant data(int column, bool fullPath) const;
QString name() const {return mName; }
QString path() const {return mPath; }
};

class GateLibrarySelectionTable : public QAbstractTableModel
{
Q_OBJECT
QList<GateLibrarySelectionEntry> mEntries;
bool mShowFullPath;
bool mWarnSubstitute;
public:
GateLibrarySelectionTable(bool addAutoDetect, QObject* parent = nullptr);
int columnCount(const QModelIndex& index = QModelIndex()) const override;
int rowCount(const QModelIndex& index = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
void handleShowFullPath(bool checked);
int addGateLibrary(const QString& path);
QString gateLibraryPath(int inx) const;
int getIndexByPath(const QString& path);
bool isWarnSubstitute() const { return mWarnSubstitute; }
};

class GateLibrarySelection : public QFrame
{
Q_OBJECT
Q_PROPERTY(QString saveIconPath READ saveIconPath WRITE setSaveIconPath)
Q_PROPERTY(QString saveIconStyle READ saveIconStyle WRITE setSaveIconStyle)
QComboBox* mComboGatelib;
QPushButton* mInvokeFileDialog;
QLabel* mWarningMsg;
QCheckBox* mCheckFullPath;
QString mSaveIconPath;
QString mSaveIconStyle;
Q_SIGNALS:
void gatelibSelected(bool singleFile);
private Q_SLOTS:
void handleGatelibIndexChanged(int inx);
void handleInvokeFileDialog();
void handleShowFullPath(bool checked);
public:
GateLibrarySelection(const QString& defaultGl, QWidget* parent = nullptr);
QString gateLibraryPath() const;
void setCurrent(const QString& glPath);
QString saveIconPath() const { return mSaveIconPath; }
QString saveIconStyle() const { return mSaveIconStyle; }
void setSaveIconPath(const QString& path) { mSaveIconPath = path; }
void setSaveIconStyle(const QString& sty) { mSaveIconStyle = sty; }
};
}
7 changes: 7 additions & 0 deletions plugins/gui/include/gui/graph_widget/graph_context_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ namespace hal
*/
bool contextWithNameExists(const QString& name) const;

/**
* Generate next view with given prefix
* @param prefix
* @return the view name which does not exist so far
*/
QString nextViewName(const QString& prefix) const;

/**
* Handler to be called after a module has been created. Used to apply the changes in the affected contexts.<br>
*
Expand Down
40 changes: 36 additions & 4 deletions plugins/gui/include/gui/gui_api/gui_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,45 @@
#include "hal_core/netlist/gate.h"
#include "hal_core/netlist/net.h"
#include "hal_core/netlist/module.h"
#include "gui/include/gui/gui_def.h"


#include <vector>
#include <tuple>

#include <QObject>
#include <QSet>
#include <tuple>
#include <vector>

namespace hal
{
namespace GuiApiClasses {

class View{
public:
static int isolateInNew(const std::vector<Module*>, const std::vector<Gate*>);
static bool deleteView(int id);
static bool addTo(int id, const std::vector<Module*>, const std::vector<Gate*>);
static bool removeFrom(int id, const std::vector<Module*>, const std::vector<Gate*>);
static bool setName(int id, const std::string& name);
static int getId(const std::string& name);
static std::string getName(int id);
static std::vector<Module*> getModules(int id);
static std::vector<Gate*> getGates(int id);
static std::vector<u32> getIds(const std::vector<Module*> modules, const std::vector<Gate*> gates);
static bool foldModule(int view_id, Module* module);
static bool unfoldModule(int view_id, Module* module);

struct ModuleGateIdPair {
QSet<u32> moduleIds;
QSet<u32> gateIds;
};

static ModuleGateIdPair getValidObjects(int viewId, const std::vector<Module*>, const std::vector<Gate*>);
static GridPlacement* getGridPlacement(int viewId);
static bool setGridPlacement(int viewId, GridPlacement* gp);
};
}


/**
* @ingroup gui
* @brief Interface to interact with the gui itself.
Expand Down Expand Up @@ -531,10 +561,12 @@ namespace hal
*/
void deselect(const std::vector<Gate*>& gates, const std::vector<Net*>& nets, const std::vector<Module*>& modules);

int isolateInNewView(const std::vector<Module*>, const std::vector<Gate*>);

Q_SIGNALS:
/**
* Q_SIGNAL that is emitted whenever the view should be moved to a new selection.
*/
void navigationRequested();
};
};
}
60 changes: 58 additions & 2 deletions plugins/gui/include/gui/gui_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#pragma once

#include "hal_core/defines.h"
#include "hal_core/utilities/log.h"
#include <QDebug>
#include <QPoint>
#include <QHash>
#include <QSet>
Expand Down Expand Up @@ -135,6 +137,53 @@ namespace hal

uint qHash(const Node &n);

class GridPlacement : public QHash<Node,QPoint>
{
public:
GridPlacement() {;}
void setGatePosition(u32 gateId, std::pair<int,int>p, bool swap = false) {
QPoint pos = QPoint(gatePosition(gateId)->first, gatePosition(gateId)->second); //position of current gate to move
hal::Node nd = key(QPoint(p.first, p.second)); //find the node in the destination

if(!nd.isNull() && !swap) //if the destination placement is not available
log_warning("gui", "Target position is already occupied");
else if (!nd.isNull() && swap)
{
operator[](hal::Node(gateId,hal::Node::Gate)) = QPoint(p.first,p.second);//set the position of the first node to the destination
if(nd.isGate())
operator[](hal::Node(nd.id(), hal::Node::Gate)) = pos;//set the position of the destination node to the position of the first node
else operator[](hal::Node(nd.id(), hal::Node::Module)) = pos;
}
else
operator[](hal::Node(gateId,hal::Node::Gate)) = QPoint(p.first,p.second);
}
void setModulePosition(u32 moduleId, std::pair<int,int>p, bool swap = false){
QPoint pos = QPoint(modulePosition(moduleId)->first, modulePosition(moduleId)->second);
hal::Node nd = key(QPoint(p.first, p.second));

if(!nd.isNull() && !swap)
log_warning("gui", "Target position is already occupied");
else if (!nd.isNull() && swap)
{
operator[](hal::Node(moduleId,hal::Node::Module)) = QPoint(p.first,p.second);
if(nd.isGate())
operator[](hal::Node(nd.id(), hal::Node::Gate)) = pos;
else operator[](hal::Node(nd.id(), hal::Node::Module)) = pos;
}
else
operator[](hal::Node(moduleId,hal::Node::Module)) = QPoint(p.first,p.second);};
std::pair<int,int>* gatePosition(u32 gateId) const
{
auto it = constFind(hal::Node(gateId,hal::Node::Gate));
return (it == constEnd() ? nullptr : new std::pair<int,int>(it->x(),it->y()));
}
std::pair<int,int>* modulePosition(u32 moduleId) const
{
auto it = constFind(hal::Node(moduleId,hal::Node::Module));
return (it == constEnd() ? nullptr : new std::pair(it->x(),it->y()));
}
};

/**
* @brief The PlacementHint class object provides hints for the layouter how new box objects
* are placed on a view. In standard mode placement is done using the most compact squere-like
Expand All @@ -151,13 +200,20 @@ namespace hal
enum PlacementModeType {Standard = 0, PreferLeft = 1, PreferRight = 2, GridPosition = 3};

/**
* @brief PlacementHint constructor
* @brief PlacementHint standard constructor
* @param mod placement mode must be either Standard or PreferLeft or PreferRight
* @param orign node to start from when PreferLeft or PreferRight are set
*/
PlacementHint(PlacementModeType mod = Standard, const Node& orign=Node())
: mMode(mod), mPreferredOrigin(orign) {;}

/**
* @brief PlacementHint constructor for grid placement
* @param gridPlc Hash node to position
*/
PlacementHint(const GridPlacement& gridPlc)
: mMode(GridPosition), mPreferredOrigin(Node()), mGridPos(gridPlc) {;}

/**
* @brief mode getter for placement mode type
* @return either Standard or PreferLeft or PreferRight
Expand Down Expand Up @@ -216,7 +272,7 @@ namespace hal
private:
PlacementModeType mMode;
Node mPreferredOrigin;
QHash<Node,QPoint> mGridPos;
GridPlacement mGridPos;
};

/**
Expand Down
9 changes: 4 additions & 5 deletions plugins/gui/include/gui/main_window/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@

#pragma once

#include "hal_core/utilities/program_options.h"

#include "gui/content_layout_area/content_layout_area.h"
#include "hal_core/utilities/program_options.h"
#include "gui/action/action.h"
#include "gui/content_layout_area/content_layout_area.h"
#include "gui/settings/main_settings_widget.h"
#include "gui/splitter/splitter.h"
#include "hal_core/netlist/module.h"
#include "hal_core/utilities/program_options.h"

#include <QLayout>
#include <QMenuBar>
Expand Down Expand Up @@ -614,7 +613,7 @@ namespace hal
Action* mActionImportNetlist;
Action* mActionSave;
Action* mActionSaveAs;
Action* mActionGateLibraryManager;
// Action* mActionGateLibraryManager;
Action* mActionAbout;
Action* mActionStartRecording;
Action* mActionStopRecording;
Expand Down
Loading

0 comments on commit ff71bda

Please sign in to comment.