Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
da36f66e
Commit
da36f66e
authored
5 years ago
by
Jacob Wahlman
Browse files
Options
Downloads
Patches
Plain Diff
added load operation from custom namespace and fixed artifacts when dragging
parent
9dd40c97
No related branches found
No related tags found
1 merge request
!57
Resolve "Load/Save SFG to file"
Pipeline
#15939
failed
5 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/GUI/drag_button.py
+2
-1
2 additions, 1 deletion
b_asic/GUI/drag_button.py
b_asic/GUI/gui_interface.py
+18
-3
18 additions, 3 deletions
b_asic/GUI/gui_interface.py
b_asic/GUI/main_window.py
+29
-1
29 additions, 1 deletion
b_asic/GUI/main_window.py
with
49 additions
and
5 deletions
b_asic/GUI/drag_button.py
+
2
−
1
View file @
da36f66e
...
...
@@ -70,7 +70,8 @@ class DragButton(QPushButton):
button
.
move
(
button
.
mapToParent
(
event
.
pos
()
-
self
.
_mouse_press_pos
))
self
.
_window
.
update
()
self
.
_window
.
scene
.
update
()
self
.
_window
.
graphic_view
.
update
()
super
(
DragButton
,
self
).
mouseMoveEvent
(
event
)
def
mouseReleaseEvent
(
self
,
event
):
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/gui_interface.py
+
18
−
3
View file @
da36f66e
...
...
@@ -64,9 +64,16 @@ class Ui_main_window(object):
self
.
special_operations_page
.
setGeometry
(
QtCore
.
QRect
(
0
,
0
,
171
,
217
))
self
.
special_operations_page
.
setObjectName
(
"
special_operations_page
"
)
self
.
special_operations_list
=
QtWidgets
.
QListWidget
(
self
.
special_operations_page
)
self
.
special_operations_list
.
setGeometry
(
QtCore
.
QRect
(
10
,
0
,
141
,
8
1
))
self
.
special_operations_list
.
setGeometry
(
QtCore
.
QRect
(
10
,
0
,
141
,
21
1
))
self
.
special_operations_list
.
setObjectName
(
"
special_operations_list
"
)
self
.
operation_list
.
addItem
(
self
.
special_operations_page
,
""
)
self
.
custom_operations_page
=
QtWidgets
.
QWidget
()
self
.
custom_operations_page
.
setGeometry
(
QtCore
.
QRect
(
0
,
0
,
171
,
217
))
self
.
custom_operations_page
.
setObjectName
(
"
custom_operations_page
"
)
self
.
custom_operations_list
=
QtWidgets
.
QListWidget
(
self
.
custom_operations_page
)
self
.
custom_operations_list
.
setGeometry
(
QtCore
.
QRect
(
10
,
0
,
141
,
211
))
self
.
custom_operations_list
.
setObjectName
(
"
custom_operations_list
"
)
self
.
operation_list
.
addItem
(
self
.
custom_operations_page
,
""
)
main_window
.
setCentralWidget
(
self
.
centralwidget
)
self
.
menu_bar
=
QtWidgets
.
QMenuBar
(
main_window
)
self
.
menu_bar
.
setGeometry
(
QtCore
.
QRect
(
0
,
0
,
897
,
21
))
...
...
@@ -235,6 +242,8 @@ class Ui_main_window(object):
self
.
load_menu
.
setObjectName
(
"
load_menu
"
)
self
.
save_menu
=
QtWidgets
.
QAction
(
main_window
)
self
.
save_menu
.
setObjectName
(
"
save_menu
"
)
self
.
load_operations
=
QtWidgets
.
QAction
(
main_window
)
self
.
load_operations
.
setObjectName
(
"
load_operations
"
)
self
.
exit_menu
=
QtWidgets
.
QAction
(
main_window
)
self
.
exit_menu
.
setObjectName
(
"
exit_menu
"
)
self
.
actionUndo
=
QtWidgets
.
QAction
(
main_window
)
...
...
@@ -256,6 +265,7 @@ class Ui_main_window(object):
self
.
actionToolbar
.
setObjectName
(
"
actionToolbar
"
)
self
.
file_menu
.
addAction
(
self
.
load_menu
)
self
.
file_menu
.
addAction
(
self
.
save_menu
)
self
.
file_menu
.
addAction
(
self
.
load_operations
)
self
.
file_menu
.
addSeparator
()
self
.
file_menu
.
addAction
(
self
.
exit_menu
)
self
.
edit_menu
.
addAction
(
self
.
actionUndo
)
...
...
@@ -290,6 +300,10 @@ class Ui_main_window(object):
self
.
special_operations_list
.
setSortingEnabled
(
False
)
self
.
special_operations_list
.
setSortingEnabled
(
__sortingEnabled
)
self
.
operation_list
.
setItemText
(
self
.
operation_list
.
indexOf
(
self
.
special_operations_page
),
_translate
(
"
main_window
"
,
"
Special operations
"
))
__sortingEnabled
=
self
.
special_operations_list
.
isSortingEnabled
()
self
.
custom_operations_list
.
setSortingEnabled
(
False
)
self
.
custom_operations_list
.
setSortingEnabled
(
__sortingEnabled
)
self
.
operation_list
.
setItemText
(
self
.
operation_list
.
indexOf
(
self
.
custom_operations_page
),
_translate
(
"
main_window
"
,
"
Custom operation
"
))
self
.
file_menu
.
setTitle
(
_translate
(
"
main_window
"
,
"
File
"
))
self
.
edit_menu
.
setTitle
(
_translate
(
"
main_window
"
,
"
Edit
"
))
self
.
view_menu
.
setTitle
(
_translate
(
"
main_window
"
,
"
View
"
))
...
...
@@ -300,8 +314,9 @@ class Ui_main_window(object):
self
.
aboutBASIC
.
setText
(
_translate
(
"
main_window
"
,
"
About B-ASIC
"
))
self
.
faqBASIC
.
setText
(
_translate
(
"
main_window
"
,
"
FAQ
"
))
self
.
keybindsBASIC
.
setText
(
_translate
(
"
main_window
"
,
"
Keybinds
"
))
self
.
load_menu
.
setText
(
_translate
(
"
main_window
"
,
"
Load
"
))
self
.
save_menu
.
setText
(
_translate
(
"
main_window
"
,
"
Save
"
))
self
.
load_menu
.
setText
(
_translate
(
"
main_window
"
,
"
Load SFG
"
))
self
.
save_menu
.
setText
(
_translate
(
"
main_window
"
,
"
Save SFG
"
))
self
.
load_operations
.
setText
(
_translate
(
"
main_window
"
,
"
Load Operations
"
))
self
.
exit_menu
.
setText
(
_translate
(
"
main_window
"
,
"
Exit
"
))
self
.
exit_menu
.
setShortcut
(
_translate
(
"
main_window
"
,
"
Ctrl+Q
"
))
self
.
actionUndo
.
setText
(
_translate
(
"
main_window
"
,
"
Undo
"
))
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/main_window.py
+
29
−
1
View file @
da36f66e
...
...
@@ -33,7 +33,7 @@ QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,
QHBoxLayout
,
QDockWidget
,
QToolBar
,
QMenu
,
QLayout
,
QSizePolicy
,
QListWidget
,
\
QListWidgetItem
,
QGraphicsView
,
QGraphicsScene
,
QShortcut
,
QGraphicsTextItem
,
\
QGraphicsProxyWidget
,
QInputDialog
,
QTextEdit
,
QFileDialog
from
PySide2.QtCore
import
Qt
,
QSize
,
Q
Url
from
PySide2.QtCore
import
Qt
,
QSize
,
Q
FileInfo
from
PySide2.QtGui
import
QIcon
,
QFont
,
QPainter
,
QPen
,
QBrush
,
QKeySequence
from
tkinter
import
Tk
...
...
@@ -91,8 +91,10 @@ class MainWindow(QMainWindow):
self
.
ui
.
keybindsBASIC
.
triggered
.
connect
(
self
.
display_keybinds_page
)
self
.
ui
.
core_operations_list
.
itemClicked
.
connect
(
self
.
on_list_widget_item_clicked
)
self
.
ui
.
special_operations_list
.
itemClicked
.
connect
(
self
.
on_list_widget_item_clicked
)
self
.
ui
.
custom_operations_list
.
itemClicked
.
connect
(
self
.
on_list_widget_item_clicked
)
self
.
ui
.
save_menu
.
triggered
.
connect
(
self
.
save_work
)
self
.
ui
.
load_menu
.
triggered
.
connect
(
self
.
load_work
)
self
.
ui
.
load_operations
.
triggered
.
connect
(
self
.
add_namespace
)
self
.
ui
.
exit_menu
.
triggered
.
connect
(
self
.
exit_app
)
self
.
shortcut_open
=
QShortcut
(
QKeySequence
(
"
Ctrl+O
"
),
self
)
self
.
shortcut_open
.
activated
.
connect
(
self
.
load_work
)
...
...
@@ -118,6 +120,7 @@ class MainWindow(QMainWindow):
def
create_toolbar_view
(
self
):
self
.
toolbar
=
self
.
addToolBar
(
"
Toolbar
"
)
self
.
toolbar
.
addAction
(
"
Create SFG
"
,
self
.
create_SFG_from_toolbar
)
self
.
toolbar
.
addAction
(
"
Clear Workspace
"
,
self
.
clear_workspace
)
def
resizeEvent
(
self
,
event
):
self
.
ui
.
operation_box
.
setGeometry
(
10
,
10
,
self
.
ui
.
operation_box
.
width
(),
self
.
height
())
...
...
@@ -219,6 +222,20 @@ class MainWindow(QMainWindow):
self
.
logger
.
info
(
"
Exiting the application.
"
)
QApplication
.
quit
()
def
clear_workspace
(
self
):
self
.
logger
.
info
(
"
Clearing workspace from operations and sfgs.
"
)
self
.
pressed_operations
.
clear
()
self
.
pressed_ports
.
clear
()
self
.
operationItemSceneList
.
clear
()
self
.
operationDragDict
.
clear
()
self
.
dragOperationSceneDict
.
clear
()
self
.
signalList
.
clear
()
self
.
portDict
.
clear
()
self
.
signalPortDict
.
clear
()
self
.
sfg_dict
.
clear
()
self
.
scene
.
clear
()
self
.
logger
.
info
(
"
Workspace cleared.
"
)
def
create_SFG_from_toolbar
(
self
):
inputs
=
[]
outputs
=
[]
...
...
@@ -299,6 +316,17 @@ class MainWindow(QMainWindow):
self
.
logger
.
info
(
f
"
Added operations from namespace:
{
namespace
.
__name__
}
.
"
)
def
add_namespace
(
self
):
module
,
accepted
=
QFileDialog
().
getOpenFileName
()
if
not
accepted
:
return
spec
=
importlib
.
util
.
spec_from_file_location
(
f
"
{
QFileInfo
(
module
).
fileName
()
}
"
,
module
)
namespace
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
namespace
)
self
.
add_operations_from_namespace
(
namespace
,
self
.
ui
.
custom_operations_list
)
def
create_operation
(
self
,
op
,
position
=
None
):
self
.
logger
.
info
(
f
"
Creating operation of type:
{
op
.
type_name
()
}
.
"
)
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment