-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8571ea9
commit 9e361dc
Showing
4 changed files
with
162 additions
and
13 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
plugins/gui/include/gui/gatelibrary_management/gatelibrary_manager.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,65 @@ | ||
// 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 "hal_core/netlist/gate_library/gate_library.h" | ||
|
||
#include <QFrame> | ||
#include <QGridLayout> | ||
#include <QTableView> | ||
|
||
namespace hal | ||
{ | ||
|
||
|
||
class GateLibraryManager : public QFrame | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
/** | ||
* Constructor. | ||
* | ||
* @param parent - the parent widget | ||
*/ | ||
explicit GateLibraryManager(QWidget* parent = nullptr); | ||
|
||
/** | ||
* Reinitializes the appearance of the widget and its children. | ||
*/ | ||
void repolish(); | ||
|
||
bool initialize(GateLibrary* gateLibrary = nullptr); | ||
|
||
|
||
private: | ||
QGridLayout* mLayout; | ||
|
||
QTableView* mTableView; | ||
|
||
GateLibrary* mGateLibrary; | ||
}; | ||
} |
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
67 changes: 67 additions & 0 deletions
67
plugins/gui/src/gatelibrary_management/gatelibrary_manager.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,67 @@ | ||
#include "gui/gatelibrary_management/gatelibrary_manager.h" | ||
|
||
#include "gui/frames/labeled_frame.h" | ||
#include "gui/graphics_effects/shadow_effect.h" | ||
#include "gui/plugin_relay/gui_plugin_manager.h" | ||
#include "gui/welcome_screen/open_file_widget.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 <gui/gui_globals.h> | ||
|
||
#include <QTableWidget> | ||
namespace hal | ||
{ | ||
GateLibraryManager::GateLibraryManager(QWidget* parent) | ||
: QFrame(parent), mLayout(new QGridLayout()), mTableView(new QTableView()) | ||
{ | ||
//TODO create layout and widgets | ||
|
||
|
||
|
||
|
||
repolish(); // CALL FROM PARENT | ||
} | ||
|
||
void GateLibraryManager::repolish() | ||
{ | ||
QStyle* s = style(); | ||
|
||
s->unpolish(this); | ||
s->polish(this); | ||
} | ||
bool GateLibraryManager::initialize(GateLibrary* gateLibrary) | ||
{ | ||
if(!gateLibrary) | ||
{ | ||
//TODO Check if a gate library is already in use | ||
// if yes then open it in read-only mode | ||
// else open file dialog and select one to parse | ||
|
||
QString title = "Load gate library"; | ||
QString text = "HAL Gate Library (*.hgl *.lib)"; | ||
QString path = QDir::currentPath(); | ||
|
||
//TODO fileDialog throws bad window error | ||
QString fileName = QFileDialog::getOpenFileName(nullptr, title, path, text, nullptr); | ||
if(fileName == nullptr) | ||
return false; | ||
|
||
if (gPluginRelay->mGuiPluginTable) | ||
gPluginRelay->mGuiPluginTable->loadFeature(FacExtensionInterface::FacGatelibParser); | ||
qInfo() << "selected file: " << fileName; | ||
|
||
auto gateLibrary = gate_library_manager::load(std::filesystem::path(fileName.toStdString())); | ||
for (auto elem : gateLibrary->get_gate_types()) | ||
{ | ||
qInfo() << QString::fromStdString(elem.second->get_name()); | ||
} | ||
} | ||
mGateLibrary = gateLibrary; | ||
return true; | ||
} | ||
} |
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