summaryrefslogtreecommitdiff
path: root/src/frontEnd
diff options
context:
space:
mode:
authorSunil Shetye2019-06-13 13:11:14 +0530
committerGitHub2019-06-13 13:11:14 +0530
commitcfc34bb19977e738582620802415ccde27a03039 (patch)
treedaaace10133835956619b401aca9c252e3e789bc /src/frontEnd
parent25c6eddcea3c8a62d9750a78435454544d8c7b14 (diff)
parent20b23a7934f7cf01cd5b4353ddd2e008b40e5ffd (diff)
downloadeSim-cfc34bb19977e738582620802415ccde27a03039.tar.gz
eSim-cfc34bb19977e738582620802415ccde27a03039.tar.bz2
eSim-cfc34bb19977e738582620802415ccde27a03039.zip
Merge pull request #86 from nilshah98/documentation
Documentation added and minor fixes
Diffstat (limited to 'src/frontEnd')
-rwxr-xr-xsrc/frontEnd/Application.py123
-rw-r--r--src/frontEnd/DockArea.py66
-rw-r--r--src/frontEnd/ProjectExplorer.py42
-rw-r--r--src/frontEnd/ProjectExplorer.py.bak147
-rw-r--r--src/frontEnd/Workspace.py4
5 files changed, 142 insertions, 240 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py
index 19fe17ef..c2790a80 100755
--- a/src/frontEnd/Application.py
+++ b/src/frontEnd/Application.py
@@ -32,16 +32,14 @@ import sys
import os
+# Its our main window of application.
class Application(QtGui.QMainWindow):
+ """This class initializes all objects used in this file(Application.py)."""
global project_name
- """
- Its our main window of application
- """
def __init__(self, *args):
- """
- Initialize main Application window
- """
+ """Initialize main Application window."""
+
# Calling __init__ of super class
QtGui.QMainWindow.__init__(self, *args)
@@ -67,9 +65,16 @@ class Application(QtGui.QMainWindow):
self.systemTrayIcon.setIcon(QtGui.QIcon('../../images/logo.png'))
self.systemTrayIcon.setVisible(True)
+ # This function initializes Tool Bars
def initToolBar(self):
"""
- This function initialize Tool Bar
+ In this function we are setting icons, short-cuts,and
+ defining functonality for:.
+ a)Top-tool-bar (New project, Open project, Close
+ project, Help option )
+ b)Left-tool-bar (Open Schematic, Convert KiCad to
+ NgSpice, Simuation, Model Editor, Subcircuit, NGHDL,
+ Modelica Converter, OM Optimisation )
"""
# Top Tool bar
self.newproj = QtGui.QAction(
@@ -106,6 +111,8 @@ class Application(QtGui.QMainWindow):
self.topToolbar.addAction(self.closeproj)
self.topToolbar.addAction(self.helpfile)
+ # This part is setting fossee logo to the right
+ # corner in the application window.
self.spacer = QtGui.QWidget()
self.spacer.setSizePolicy(
QtGui.QSizePolicy.Expanding,
@@ -186,7 +193,23 @@ class Application(QtGui.QMainWindow):
self.lefttoolbar.setOrientation(QtCore.Qt.Vertical)
self.lefttoolbar.setIconSize(QSize(40, 40))
+ # This function closes the ongoing program(process).
def closeEvent(self, event):
+ '''
+ When exit button is pressed a Message box pops out with
+ exit message and buttons 'Yes', 'No'.
+
+ 1. If 'Yes' is pressed:.
+ a)it checks that program(process) in procThread_list
+ (list made in Appconfig.py):
+ a.1) if available it terminates that program
+ a.2) if the program(process) is not available,
+ it checks for it in process_obj (list made in
+ Appconfig.py) if found it closes the program.
+
+ 2. If 'No' is pressed:
+ a)the program just continues as it was doing earlier.
+ '''
exit_msg = "Are you sure you want to exit the program\
? All unsaved data will be lost."
reply = QtGui.QMessageBox.question(
@@ -219,7 +242,16 @@ class Application(QtGui.QMainWindow):
elif reply == QtGui.QMessageBox.No:
event.ignore()
+ # This function closes the saved project.
def close_project(self):
+ """
+ This function first checks whether project(file) is present in list.
+ a)If present:
+ :-it first kills that process-id.
+ :-closes that file.
+ :-Shows message "Current project <path of file> is closed"
+ b)If not present:- pass
+ """
print("Function : Close Project")
current_project = self.obj_appconfig.current_project['ProjectName']
if current_project is None:
@@ -239,10 +271,8 @@ class Application(QtGui.QMainWindow):
os.path.basename(current_project) +
' is Closed.')
+ # This function call New Project Info class.
def new_project(self):
- """
- This function call New Project Info class.
- """
text, ok = QtGui.QInputDialog.getText(
self, 'New Project Info', 'Enter Project Name:')
if ok:
@@ -263,10 +293,8 @@ class Application(QtGui.QMainWindow):
except BaseException:
pass
+ # This project call Open Project Info class
def open_project(self):
- """
- This project call Open Project Info class
- """
print("Function : Open Project")
self.project = OpenProjectInfo()
@@ -277,17 +305,21 @@ class Application(QtGui.QMainWindow):
except BaseException:
pass
+ # This page opens usermanual in dockarea.
def help_project(self):
+ """
+ 1)It prints the message ""Function : Help""
+ 2)Uses print_info() method of class Appconfig
+ form Configuration/Appconfig.py file.
+ 3)Call method usermanual() from ./DockArea.py.
+ """
print("Function : Help")
self.obj_appconfig.print_info('Help is called')
print("Current Project is : ", self.obj_appconfig.current_project)
self.obj_Mainview.obj_dockarea.usermanual()
+ # This Function execute ngspice on current project.
def open_ngspice(self):
- """
- This Function execute ngspice on current project
- """
-
self.projDir = self.obj_appconfig.current_project["ProjectName"]
if self.projDir is not None:
@@ -311,12 +343,29 @@ class Application(QtGui.QMainWindow):
create new project or open existing project')
self.msg.setWindowTitle("Error Message")
+ # This function opens 'subcircuit' option in left-tool-bar.
def open_subcircuit(self):
+ """
+ When 'subcircuit' icon is clicked wich is present in
+ left-tool-bar of main page:
+ a) Meassge shown on screen "Subcircuit editor is called".
+ b) 'subcircuiteditor()'' function is called using object
+ 'obj_dockarea' of class 'Mainview'.
+ """
print("Function : Subcircuit editor")
self.obj_appconfig.print_info('Subcircuit editor is called')
self.obj_Mainview.obj_dockarea.subcircuiteditor()
+ # This function calls NGHDl option in left-tool-bar.
def open_nghdl(self):
+ """
+ This function uses validateTool() method from
+ Validation.py:
+ a) If 'nghdl' is present in executables list then
+ it adds passes command 'nghdl -e' to WorkerThread class of
+ Worker.py.
+ b) If 'nghdl' not present then it shows error message.
+ """
print("Function : Nghdl")
self.obj_appconfig.print_info('Nghdl is called')
@@ -333,16 +382,22 @@ class Application(QtGui.QMainWindow):
Please make sure nghdl is installed')
self.msg.setWindowTitle('nghdl Error Message')
+ # This function opens model editor option in left-tool-bar.
def open_modelEditor(self):
+ """
+ When model editor icon is clicked wich is present in
+ left-tool-bar of main page:
+ a) Meassge shown on screen "Model editor is called".
+ b) 'modeleditor()'' function is called using object
+ 'obj_dockarea' of class 'Mainview'.
+ """
print("Function : Model editor")
self.obj_appconfig.print_info('Model editor is called')
self.obj_Mainview.obj_dockarea.modelEditor()
+ # This function call ngspice to OM edit converter
+ # and then launch OM edit.
def open_OMedit(self):
- """
- This function call ngspice to OM edit converter
- and then launch OM edit.
- """
self.obj_appconfig.print_info('OM edit is called')
self.projDir = self.obj_appconfig.current_project["ProjectName"]
@@ -358,7 +413,7 @@ class Application(QtGui.QMainWindow):
try:
# Creating a command for Ngspice to Modelica converter
self.cmd1 = "
- python ../ngspicetoModelica/NgspicetoModelica.py "\
+ python3 ../ngspicetoModelica/NgspicetoModelica.py "\
+self.ngspiceNetlist
self.obj_workThread1 = Worker.WorkerThread(self.cmd1)
self.obj_workThread1.start()
@@ -415,7 +470,17 @@ class Application(QtGui.QMainWindow):
or open existing project')
self.msg.setWindowTitle("Error Message")
+ # sdf
def open_OMoptim(self):
+ """
+ This function uses validateTool() method from
+ Validation.py:
+ a) If 'OMOptim' is present in executables list then
+ it adds passes command 'OMOptim' to WorkerThread class of
+ Worker.py.
+ b) If 'OMOptim' not present then it shows error message with
+ link to download it on Linux and Windows.
+ """
print("Function : OM Optim")
self.obj_appconfig.print_info('OM Optim is called')
# Check if OMOptim is installed
@@ -441,9 +506,17 @@ class Application(QtGui.QMainWindow):
self.msg.exec_()
+# This class initialize the Main View of Application
class MainView(QtGui.QWidget):
"""
- This class initialize the Main View of Application
+ This class defines whole view and style of main page:
+ a)Position of tool bars:
+ :-Top tool bar.
+ :-Left tool bar.
+ b) Project explorer Area.
+ c) Dock area.
+ d)Console area.
+
"""
def __init__(self, *args):
@@ -497,9 +570,11 @@ class MainView(QtGui.QWidget):
self.setLayout(self.mainLayout)
+# It is main function of the module.It starts the application
def main(args):
"""
- It is main function of the module.It starts the application
+ The splash screen opened at the starting of screen is performed
+ by this function.
"""
print("Starting eSim......")
app = QtGui.QApplication(args)
diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py
index b44a87e6..2c605272 100644
--- a/src/frontEnd/DockArea.py
+++ b/src/frontEnd/DockArea.py
@@ -14,9 +14,9 @@ dockList = ['Welcome']
count = 1
dock = {}
-
+#
class DockArea(QtGui.QMainWindow):
-
+ """ """
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.obj_appconfig = Appconfig()
@@ -39,32 +39,10 @@ class DockArea(QtGui.QMainWindow):
# self.tabifyDockWidget(dock['Notes'],dock['Blank'])
self.show()
-
- '''
- def __init__(self):
- QtGui.QMainWindow.__init__(self)
- self.obj_appconfig = Appconfig()
-
- for dockName in dockList:
- dock[dockName] = QtGui.QDockWidget(dockName)
- self.welcome = QtGui.QTextEdit()
- self.welcome.setReadOnly(True)
- dock[dockName].setWidget(self.welcome)
- #CSS
- dock[dockName].setStyleSheet(" \
- QWidget { border-radius: 15px; border: 1px solid gray;\
- padding: 5px; width: 200px; height: 150px; } \
- ")
- self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock[dockName])
- #self.tabifyDockWidget(dock['Notes'],dock['Blank'])
- self.show()
- '''
-
+ # This function create widget for Library Editor
def createTestEditor(self):
- """
- This function create widget for Library Editor
- """
+ """ """
global count
self.testWidget = QtGui.QWidget()
@@ -81,32 +59,19 @@ class DockArea(QtGui.QMainWindow):
self.tabifyDockWidget(
dock['Welcome'], dock['Tips-' + str(count)])
- """
- #CSS
- dock['Tips-'+str(count)].setStyleSheet(" \
- .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px;\
- width: 200px; height: 150px; } \
- ")
- """
-
dock['Tips-' + str(count)].setVisible(True)
dock['Tips-' + str(count)].setFocus()
- """
- dock['Tips-'+str(count)].setStyleSheet(" \
- :hover { background-color: yellow; } \
- ")
- """
+
dock['Tips-' + str(count)].raise_()
temp = self.obj_appconfig.current_project['ProjectName']
self.obj_appconfig.dock_dict[temp].append(
dock['Tips-' + str(count)])
count = count + 1
-
+
+ # This function create widget for interactive PythonPlotting
def plottingEditor(self):
- """
- This function create widget for interactive PythonPlotting
- """
+ """ """
self.projDir = self.obj_appconfig.current_project["ProjectName"]
self.projName = os.path.basename(self.projDir)
# self.project = os.path.join(self.projDir,self.projName)
@@ -126,13 +91,6 @@ class DockArea(QtGui.QMainWindow):
dock['Plotting-' + str(count)])
self.tabifyDockWidget(dock['Welcome'], dock['Plotting-' + str(count)])
- """
- #CSS
- dock['Plotting-'+str(count)].setStyleSheet(" \
- .QWidget { border-radius: 15px; border: 1px solid gray; padding: 5px;\
- width: 200px; height: 150px; } \
- ")
- """
dock['Plotting-' + str(count)].setVisible(True)
dock['Plotting-' + str(count)].setFocus()
dock['Plotting-' + str(count)].raise_()
@@ -143,9 +101,7 @@ class DockArea(QtGui.QMainWindow):
count = count + 1
def ngspiceEditor(self, projDir):
- """
- This function creates widget for NgSpice window
- """
+ """This function creates widget for NgSpice window."""
self.projDir = projDir
self.projName = os.path.basename(self.projDir)
@@ -314,9 +270,7 @@ class DockArea(QtGui.QMainWindow):
count = count + 1
def modelicaEditor(self, projDir):
- """
- This function sets up the UI for ngspice to modelica conversion
- """
+ """This function sets up the UI for ngspice to modelica conversion."""
global count
self.modelicaWidget = QtGui.QWidget()
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py
index 77b3f124..d84f41e0 100644
--- a/src/frontEnd/ProjectExplorer.py
+++ b/src/frontEnd/ProjectExplorer.py
@@ -4,8 +4,16 @@ import json
from configuration.Appconfig import Appconfig
+# This is main class for Project Explorer Area.
class ProjectExplorer(QtGui.QWidget):
+ """ """
+
def __init__(self):
+ """
+ This method is doing following tasks:
+ a)initializing objects used in full program.
+ b)view of project explorer area.
+ """
QtGui.QWidget.__init__(self)
self.obj_appconfig = Appconfig()
self.treewidget = QtGui.QTreeWidget()
@@ -37,8 +45,8 @@ class ProjectExplorer(QtGui.QWidget):
os.path.join(parents)
if os.path.exists(parents):
pathlist = parents.split(os.sep)
- parentnode = QtGui.QTreeWidgetItem(
- self.treewidget, [pathlist[-1], parents])
+ parentnode = QtGui.QTreeWidgetItem(self.treewidget,
+ [pathlist[-1], parents])
for files in children:
QtGui.QTreeWidgetItem(
parentnode, [files, os.path.join(parents, files)])
@@ -73,7 +81,6 @@ class ProjectExplorer(QtGui.QWidget):
indexes = self.treewidget.selectedIndexes()
if len(indexes) > 0:
-
level = 0
index = indexes[0]
while index.parent().isValid():
@@ -132,25 +139,35 @@ class ProjectExplorer(QtGui.QWidget):
else:
self.obj_appconfig.current_project["ProjectName"] = str(
self.filePath)
- self.obj_appconfig.proc_dict
- [self.obj_appconfig.current_project['ProjectName']] = [
- ]
- if self.obj_appconfig.current_project['ProjectName'] \
- not in self.obj_appconfig.dock_dict:
+ (
+ self.obj_appconfig.
+ proc_dict[self.obj_appconfig.current_project['ProjectName']]
+ ) = []
+ if (
+ self.obj_appconfig.current_project['ProjectName'] not in
self.obj_appconfig.dock_dict
- [self.obj_appconfig.current_project['ProjectName']] = [
- ]
-
+ ):
+ (
+ self.obj_appconfig.
+ dock_dict[
+ self.obj_appconfig.current_project['ProjectName']]
+ ) = []
+
+ # This function is enabling save button option.
def enable_save(self):
self.save.setEnabled(True)
+ # This function is saving data before it closes the given file.
def save_data(self):
self.fopen = open(self.filePath, 'w')
self.fopen.write(self.text.toPlainText())
self.fopen.close()
self.textwindow.close()
+ # This function removes the project in explorer area by right
+ # clicking on project and selecting remove option.
def removeProject(self):
+ """ """
self.indexItem = self.treewidget.currentIndex()
self.filePath = str(
self.indexItem.sibling(
@@ -166,7 +183,10 @@ class ProjectExplorer(QtGui.QWidget):
json.dump(self.obj_appconfig.project_explorer,
open(self.obj_appconfig.dictPath, 'w'))
+ # This function refresh the project in explorer area by right
+ # clicking on project and selecting refresh option.
def refreshProject(self):
+ """ """
self.indexItem = self.treewidget.currentIndex()
self.filePath = str(
self.indexItem.sibling(
diff --git a/src/frontEnd/ProjectExplorer.py.bak b/src/frontEnd/ProjectExplorer.py.bak
deleted file mode 100644
index 8c75398e..00000000
--- a/src/frontEnd/ProjectExplorer.py.bak
+++ /dev/null
@@ -1,147 +0,0 @@
-from PyQt4 import QtGui,QtCore
-import os
-import json
-from configuration.Appconfig import Appconfig
-
-
-class ProjectExplorer(QtGui.QWidget):
- def __init__(self):
- QtGui.QWidget.__init__(self)
- self.obj_appconfig = Appconfig()
- self.treewidget = QtGui.QTreeWidget()
- self.window= QtGui.QVBoxLayout()
- header = QtGui.QTreeWidgetItem(["Projects","path"])
- self.treewidget.setHeaderItem(header)
- self.treewidget.setColumnHidden(1,True)
-
- #CSS
- self.treewidget.setStyleSheet(" \
- QTreeView { border-radius: 15px; border: 1px solid gray; padding: 5px; width: 200px; height: 150px; } \
- QTreeView::branch:has-siblings:!adjoins-item { border-image: url(../../images/vline.png) 0; } \
- QTreeView::branch:has-siblings:adjoins-item { border-image: url(../../images/branch-more.png) 0; } \
- QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(../../images/branch-end.png) 0; } \
- QTreeView::branch:has-children:!has-siblings:closed, \
- QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(../../images/branch-closed.png); } \
- QTreeView::branch:open:has-children:!has-siblings, \
- QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(../../images/branch-open.png); } \
- ")
-
- for parents, children in list(self.obj_appconfig.project_explorer.items()):
- os.path.join(parents)
- if os.path.exists(parents):
- pathlist= parents.split(os.sep)
- parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1],parents])
- for files in children:
- childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
- self.window.addWidget(self.treewidget)
-
- self.treewidget.doubleClicked.connect(self.openProject)
- self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
- self.treewidget.customContextMenuRequested.connect(self.openMenu)
- self.setLayout(self.window)
- self.show()
-
- def addTreeNode(self, parents, children):
- os.path.join(parents)
- pathlist= parents.split(os.sep)
- parentnode = QtGui.QTreeWidgetItem(self.treewidget, [pathlist[-1], parents])
- for files in children:
- childnode = QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(parents,files)])
- self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
- self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
-
- def openMenu(self, position):
-
- indexes = self.treewidget.selectedIndexes()
- if len(indexes) > 0:
-
- level = 0
- index = indexes[0]
- while index.parent().isValid():
- index = index.parent()
- level += 1
-
- menu = QtGui.QMenu()
- if level == 0:
- deleteproject = menu.addAction(self.tr("Remove Project"))
- deleteproject.triggered.connect(self.removeProject)
- refreshproject= menu.addAction(self.tr("Refresh"))
- refreshproject.triggered.connect(self.refreshProject)
- elif level == 1:
- openfile = menu.addAction(self.tr("Open"))
- openfile.triggered.connect(self.openProject)
-
- menu.exec_(self.treewidget.viewport().mapToGlobal(position))
-
- def openProject(self):
- self.indexItem =self.treewidget.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
- self.obj_appconfig.print_info('The current project is ' + self.filePath)
-
- self.textwindow = QtGui.QWidget()
- self.textwindow.setMinimumSize(600, 500)
- self.textwindow.setGeometry(QtCore.QRect(400,150,400,400))
- self.textwindow.setWindowTitle(filename)
-
- self.text = QtGui.QTextEdit()
- self.save = QtGui.QPushButton('Save and Exit')
- self.save.setDisabled(True)
- self.windowgrid = QtGui.QGridLayout()
- if (os.path.isfile(str(self.filePath)))== True:
- self.fopen = open(str(self.filePath), 'r')
- lines = self.fopen.read()
- self.text.setText(lines)
-
- QtCore.QObject.connect(self.text,QtCore.SIGNAL("textChanged()"), self.enable_save)
-
- vbox_main = QtGui.QVBoxLayout(self.textwindow)
- vbox_main.addWidget(self.text)
- vbox_main.addWidget(self.save)
- self.save.clicked.connect(self.save_data)
- #self.connect(exit,QtCore.SIGNAL('close()'), self.onQuit)
-
- self.textwindow.show()
- else:
- self.obj_appconfig.current_project["ProjectName"]= str(self.filePath)
- self.obj_appconfig.proc_dict[self.obj_appconfig.current_project['ProjectName']] = []
- if self.obj_appconfig.current_project['ProjectName'] not in self.obj_appconfig.dock_dict:
- self.obj_appconfig.dock_dict[self.obj_appconfig.current_project['ProjectName']] = []
-
- def enable_save(self):
- self.save.setEnabled(True)
-
- def save_data(self):
- self.fopen=open(self.filePath, 'w')
- self.fopen.write(self.text.toPlainText())
- self.fopen.close()
- self.textwindow.close()
-
- def removeProject(self):
- self.indexItem =self.treewidget.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= self.indexItem.sibling(self.indexItem.row(), 1).data().toString()
- self.int = self.indexItem.row()
- self.treewidget.takeTopLevelItem(self.int)
-
- if self.obj_appconfig.current_project["ProjectName"] == self.filePath:
- self.obj_appconfig.current_project["ProjectName"] = None
-
- del self.obj_appconfig.project_explorer[str(self.filePath)]
- json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
-
- def refreshProject(self):
- self.indexItem =self.treewidget.currentIndex()
- filename= self.indexItem.data().toString()
- self.filePath= str(self.indexItem.sibling(self.indexItem.row(), 1).data().toString())
- filelistnew= os.listdir(os.path.join(self.filePath))
- parentnode = self.treewidget.currentItem()
- count = parentnode.childCount()
- for i in range(count):
- for items in self.treewidget.selectedItems():
- items.removeChild(items.child(0))
- for files in filelistnew:
- childnode= QtGui.QTreeWidgetItem(parentnode, [files, os.path.join(self.filePath,files)])
-
- self.obj_appconfig.project_explorer[self.filePath]= filelistnew
- json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w'))
diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py
index 7bc74deb..62833064 100644
--- a/src/frontEnd/Workspace.py
+++ b/src/frontEnd/Workspace.py
@@ -20,10 +20,10 @@ from configuration.Appconfig import Appconfig
import time
import os
-
+# This class creates Workspace GUI.
class Workspace(QtGui.QWidget):
"""
- This class creates Workspace GUI.
+
"""
def __init__(self, parent=None):