diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/frontEnd/Application.py | 5 | ||||
-rw-r--r-- | src/frontEnd/ProjectExplorer.py | 143 | ||||
-rw-r--r-- | src/ngspiceSimulation/pythonPlotting.py | 2 | ||||
-rw-r--r-- | src/projManagement/newProject.py | 8 | ||||
-rw-r--r-- | src/projManagement/openProject.py | 1 | ||||
-rw-r--r-- | src/subcircuit/Subcircuit.py | 11 | ||||
-rw-r--r-- | src/subcircuit/convertSub.py | 8 | ||||
-rw-r--r-- | src/subcircuit/newSub.py | 5 | ||||
-rw-r--r-- | src/subcircuit/openSub.py | 6 |
9 files changed, 125 insertions, 64 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index ef8a4a7d..7478264a 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -31,15 +31,15 @@ from PyQt4.Qt import QSize import sys import os -# Its our main window of application. - +# Its our main window of application. class Application(QtGui.QMainWindow): """This class initializes all objects used in this file(Application.py).""" global project_name def __init__(self, *args): """Initialize main Application window.""" + # Calling __init__ of super class QtGui.QMainWindow.__init__(self, *args) @@ -349,6 +349,7 @@ class Application(QtGui.QMainWindow): "ngspice taking too long, check netlist file") # Calling Python Plotting + try: self.obj_Mainview.obj_dockarea.plottingEditor() except Exception as e: diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 638b3147..dfe68e58 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -2,6 +2,8 @@ from PyQt4 import QtGui, QtCore import os import json from configuration.Appconfig import Appconfig +from projManagement.newProject import NewProjectInfo +from projManagement.Validation import Validation # This is main class for Project Explorer Area. @@ -25,6 +27,7 @@ class ProjectExplorer(QtGui.QWidget): """ QtGui.QWidget.__init__(self) self.obj_appconfig = Appconfig() + self.obj_validation = Validation() self.treewidget = QtGui.QTreeWidget() self.window = QtGui.QVBoxLayout() header = QtGui.QTreeWidgetItem(["Projects", "path"]) @@ -226,51 +229,101 @@ class ProjectExplorer(QtGui.QWidget): json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath, 'w')) - '''def renameProject(self): - indexItem = self.treewidget.currentIndex() - baseFileName = str(indexItem.data()) - newBaseFileName, ok = QtGui.QInputDialog.getText( - self, 'Rename Project', 'Project Name:', - QtGui.QLineEdit.Normal, baseFileName - ) - if ok and newBaseFileName: - newBaseFileName = str(newBaseFileName) - projectPath, projectFiles = list( - self.obj_appconfig.project_explorer.items())[indexItem.row()] - updatedProjectFiles = [] + #""" + def renameProject(self): + """ + This function renames the project present in project explorer area + it validates first: - # rename files matching project name - for projectFile in projectFiles: - if baseFileName in projectFile: - oldFilePath = os.path.join(projectPath, projectFile) - projectFile = projectFile.replace( - baseFileName, newBaseFileName, 1) - newFilePath = os.path.join(projectPath, projectFile) - print ("Renaming " + oldFilePath + " to " + newFilePath) - os.rename(oldFilePath, newFilePath) - - updatedProjectFiles.append(projectFile) - - # rename project folder - updatedProjectPath = newBaseFileName.join( - projectPath.rsplit(baseFileName, 1)) - print ("Renaming " + projectPath + " to " + updatedProjectPath) - os.rename(projectPath, updatedProjectPath) - - # update project_explorer dictionary - del self.obj_appconfig.project_explorer[projectPath] - self.obj_appconfig.project_explorer[updatedProjectPath] = ( - updatedProjectFiles - ) + - If project names is not empty. + - Project name does not contain spaces between them. + - Project name is different between what it was earlier. + - Project name should not exist. + + And after project name is changed it recreates the project explorer tree. + """ + self.indexItem = self.treewidget.currentIndex() + self.baseFileName = str(self.indexItem.data()) + self.newBaseFileName, ok = QtGui.QInputDialog.getText(self, 'Rename Project', 'Project Name:', + QtGui.QLineEdit.Normal, self.baseFileName) + if ok and self.newBaseFileName: + print("=================") + print(self.newBaseFileName) + print("=================") + self.newBaseFileName = str(self.newBaseFileName) + projectPath, projectFiles = list(self.obj_appconfig.project_explorer.items())[self.indexItem.row()] + updatedProjectFiles = [] - # save project_explorer dictionary on disk - json.dump(self.obj_appconfig.project_explorer, - open(self.obj_appconfig.dictPath, 'w')) + self.workspace = self.obj_appconfig.default_workspace['workspace'] + self.newBaseFileName = str(self.newBaseFileName).rstrip().lstrip() + self.projDir = os.path.join(self.workspace, str(self.newBaseFileName)) + + if self.newBaseFileName == "": + print("Project name can not be empty") + print("==================") + msg = QtGui.QErrorMessage(self) + msg.showMessage('The project name cannot be empty') + msg.setWindowTitle("Error Message") + + elif self.baseFileName == self.newBaseFileName: + print("Project name has to be different") + print("==================") + msg = QtGui.QErrorMessage(self) + msg.showMessage('The project name has to be different') + msg.setWindowTitle("Error Message") + + else: + self.reply = self.obj_validation.validateNewproj(str(self.projDir)) + print(self.reply) + print("==================") - # recreate project explorer tree - self.treewidget.clear() - for parent, children in ( - self.obj_appconfig.project_explorer.items() - ): - self.addTreeNode(parent, children) - ''' + # rename files matching project name + if self.reply == "VALID": + for projectFile in projectFiles: + if self.baseFileName in projectFile: + oldFilePath = os.path.join(projectPath, projectFile) + projectFile = projectFile.replace(self.baseFileName, self.newBaseFileName, 1) + newFilePath = os.path.join(projectPath, projectFile) + print(oldFilePath) + print("==================") + print(newFilePath) + print("==================") + print ("Renaming " + oldFilePath + " to " + newFilePath) + #os.rename(oldFilePath, newFilePath) + updatedProjectFiles.append(projectFile) + + # rename project folder + updatedProjectPath = self.newBaseFileName.join(projectPath.rsplit(self.baseFileName, 1)) + print ("Renaming " + projectPath + " to " + updatedProjectPath) + os.rename(projectPath, updatedProjectPath) + + # update project_explorer dictionary + del self.obj_appconfig.project_explorer[projectPath] + self.obj_appconfig.project_explorer[updatedProjectPath] = updatedProjectFiles + + # save project_explorer dictionary on disk + json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w')) + + # recreate project explorer tree + self.treewidget.clear() + for parent, children in self.obj_appconfig.project_explorer.items(): + self.addTreeNode(parent, children) + + elif self.reply == "CHECKEXIST": + print("Project name already exists.") + print("==========================") + msg = QtGui.QErrorMessage(self) + msg.showMessage( + 'The project "' + + self.newBaseFileName + + '" already exist.Please select the different name or' + + ' delete existing project') + msg.setWindowTitle("Error Message") + + elif self.reply == "CHECKNAME": + print("Name can not contain space between them") + print("===========================") + msg = QtGui.QErrorMessage(self) + msg.showMessage( + 'The project name should not contain space between them') + msg.setWindowTitle("Error Message") diff --git a/src/ngspiceSimulation/pythonPlotting.py b/src/ngspiceSimulation/pythonPlotting.py index b9474403..d36a42cf 100644 --- a/src/ngspiceSimulation/pythonPlotting.py +++ b/src/ngspiceSimulation/pythonPlotting.py @@ -381,6 +381,7 @@ class plotWindow(QtGui.QMainWindow): self.axes.set_ylabel('Voltage(V)-->') else: self.axes.set_ylabel('Current(I)-->') + self.axes.grid(True) self.canvas.draw() self.combo = [] @@ -697,6 +698,7 @@ class DataExtraction: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage('Error in Analysis File.') self.msg.setWindowTitle("Error Message:openFile") + d = self.numberFinder(fpath) d1 = int(d[0] + 1) d2 = int(d[1]) diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index 44a7a69a..e7fd6548 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -45,14 +45,6 @@ class NewProjectInfo(QtGui.QWidget): - CHECKNAME - NONE - @params - :projName => name of the project created passed from - frontEnd/Application new_project() - - @return - :dirs => The directories inside the project folder - :filelist => The files inside the project folder - """ # print "Create Project Called" self.projName = projName diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index 9c31bf31..23e2c361 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -1,4 +1,3 @@ - # ========================================================================= # # FILE: openProject.py diff --git a/src/subcircuit/Subcircuit.py b/src/subcircuit/Subcircuit.py index d2e7ec5a..9f161b97 100644 --- a/src/subcircuit/Subcircuit.py +++ b/src/subcircuit/Subcircuit.py @@ -4,6 +4,7 @@ from projManagement.Validation import Validation from subcircuit.newSub import NewSub from subcircuit.openSub import openSub from subcircuit.convertSub import convertSub +from subcircuit.uploadSub import UploadSub # This class creates Subcircuit GUI. @@ -41,11 +42,17 @@ class Subcircuit(QtGui.QWidget): '<b>To convert Subcircuit Kicad Netlist to Ngspice Netlist</b>') self.convertbtn.setFixedSize(200, 40) self.convertbtn.clicked.connect(self.convertsch) + self.uploadbtn = QtGui.QPushButton('Upload a Subcircuit') + self.uploadbtn.setToolTip( + '<b>To Upload a subcircuit</b>') + self.uploadbtn.setFixedSize(180, 38) + self.uploadbtn.clicked.connect(self.uploadSub) self.hbox = QtGui.QHBoxLayout() self.hbox.addWidget(self.newbtn) self.hbox.addWidget(self.editbtn) self.hbox.addWidget(self.convertbtn) + self.hbox.addWidget(self.uploadbtn) self.hbox.addStretch(1) self.vbox = QtGui.QVBoxLayout() @@ -73,3 +80,7 @@ class Subcircuit(QtGui.QWidget): def convertsch(self): self.obj_convertsubcircuit = convertSub(self.obj_dockarea) self.obj_convertsubcircuit.createSub() + + def uploadSub(self): + self.obj_uploadsubcircuit = UploadSub() + self.obj_uploadsubcircuit.upload() diff --git a/src/subcircuit/convertSub.py b/src/subcircuit/convertSub.py index 49f5a54f..3e32f9b2 100644 --- a/src/subcircuit/convertSub.py +++ b/src/subcircuit/convertSub.py @@ -44,12 +44,12 @@ class convertSub(QtGui.QWidget): else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage( - 'The subcircuit does not contain any Kicad netlist\ - file for conversion.') + 'The subcircuit does not contain any Kicad netlist file' + + 'for conversion.') self.msg.setWindowTitle("Error Message") else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage( - 'Please select the subcircuit first. You can either create \ - new subcircuit or open existing subcircuit') + 'Please select the subcircuit first. You can either create' + + 'new subcircuit or open existing subcircuit') self.msg.setWindowTitle("Error Message") diff --git a/src/subcircuit/newSub.py b/src/subcircuit/newSub.py index 678b023d..b44e71ca 100644 --- a/src/subcircuit/newSub.py +++ b/src/subcircuit/newSub.py @@ -8,7 +8,10 @@ import os # This class is called when User create new Project. class NewSub(QtGui.QWidget): """ - Contains functions to create directory and validate file names. + Contains funstions to check : + - Name of project should not be blank. + - Name should not contain space between them. + - Name does not match with existing project. """ def __init__(self): diff --git a/src/subcircuit/openSub.py b/src/subcircuit/openSub.py index bebd28a1..dd6e31ac 100644 --- a/src/subcircuit/openSub.py +++ b/src/subcircuit/openSub.py @@ -21,9 +21,9 @@ class openSub(QtGui.QWidget): None, "Open File", "../SubcircuitLibrary")) if self.editfile: self.obj_Appconfig = Appconfig() - self.obj_Appconfig.current_subcircuit['SubcircuitName'] = ( - self.editfile - ) + self.obj_Appconfig.current_subcircuit['SubcircuitName'] \ + = self.editfile + self.schname = os.path.basename(self.editfile) self.editfile = os.path.join(self.editfile, self.schname) self.cmd = "eeschema " + self.editfile + ".sch " |