diff options
author | fahim | 2015-02-25 12:28:36 +0530 |
---|---|---|
committer | fahim | 2015-02-25 12:28:36 +0530 |
commit | b8a87cdb785471005e96234782287528e3edc39c (patch) | |
tree | a4fb514bd17255b67514c3546ced9dce9e769197 | |
parent | 22254c4024c72f71de4d4fc0b71bbb22fac8a747 (diff) | |
download | eSim-b8a87cdb785471005e96234782287528e3edc39c.tar.gz eSim-b8a87cdb785471005e96234782287528e3edc39c.tar.bz2 eSim-b8a87cdb785471005e96234782287528e3edc39c.zip |
Subject: Kicad Module modified along with some other minor changes
Description: Added openschematic,openlayout,openpcb in the kicad module.
20 files changed, 193 insertions, 94 deletions
diff --git a/src/configuration/Appconfig.py b/src/configuration/Appconfig.py index 550670cf..d1b82166 100644 --- a/src/configuration/Appconfig.py +++ b/src/configuration/Appconfig.py @@ -30,7 +30,7 @@ class Appconfig(QtGui.QWidget): home = os.path.join(os.path.expanduser("~"),"ecSim-Workspace") default_workspace = {"workspace":home} #Current Project detail - current_project = {"ProjectName":"None"} + current_project = {"ProjectName":None} #Workspace detail workspace_text = '''ecSim stores your project in a folder called a workspace. You can choose a different workspace folder to use for this session.''' diff --git a/src/configuration/Appconfig.pyc b/src/configuration/Appconfig.pyc Binary files differindex b68d43c9..b4cbb31a 100644 --- a/src/configuration/Appconfig.pyc +++ b/src/configuration/Appconfig.pyc diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index c454f6cc..ff1ffb2a 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -20,7 +20,7 @@ from PyQt4 import QtGui, QtCore from configuration.Appconfig import Appconfig -from projManagement.openProject import ProjectInfo +from projManagement.openProject import OpenProjectInfo from projManagement.newProject import NewProjectInfo import os import ViewManagement @@ -42,14 +42,14 @@ class Application(QtGui.QMainWindow): #Creating Application configuration object - self.confObj = Appconfig() - self.setGeometry(self.confObj._app_xpos, - self.confObj._app_ypos, - self.confObj._app_width, - self.confObj._app_heigth) - self.setWindowTitle(self.confObj._APPLICATION) + self.obj_appconfig = Appconfig() + self.setGeometry(self.obj_appconfig._app_xpos, + self.obj_appconfig._app_ypos, + self.obj_appconfig._app_width, + self.obj_appconfig._app_heigth) + self.setWindowTitle(self.obj_appconfig._APPLICATION) #Init Workspace - self.work_space = Workspace.Workspace() + self.obj_workspace = Workspace.Workspace() #Init necessary components in sequence self.initActions() @@ -96,7 +96,7 @@ class Application(QtGui.QMainWindow): def open_project(self): print "Open Project called" - self.project = ProjectInfo() + self.project = OpenProjectInfo() self.project.body() def exit_project(self): @@ -105,6 +105,7 @@ class Application(QtGui.QMainWindow): def help_project(self): print "Help is called" + print "Current Project : ",self.obj_appconfig.current_project def testing(self): print "Sucess hit kicad button" diff --git a/src/frontEnd/ViewManagement.py b/src/frontEnd/ViewManagement.py index 5b7dc262..e1d91d21 100755 --- a/src/frontEnd/ViewManagement.py +++ b/src/frontEnd/ViewManagement.py @@ -21,7 +21,7 @@ from PyQt4 import QtCore from PyQt4 import QtGui -from projManagement.openKicad import Kicad +from projManagement.Kicad import Kicad class ViewManagement(QtGui.QSplitter): @@ -32,8 +32,7 @@ class ViewManagement(QtGui.QSplitter): # Creating dictionary which hold all the views self.views = {} - #Creating object of openKicad.py - + #Creating object of Kicad.py self.obj_kicad = Kicad() # define the basic framework of view areas for the @@ -57,7 +56,7 @@ class ViewManagement(QtGui.QSplitter): self.grid = QtGui.QGridLayout() - #Button for QFrame + #Button for Project Tool Bar self.kicad_btn = QtGui.QPushButton() self.kicad_btn.setIcon(QtGui.QIcon('../images/default.png')) self.kicad_btn.setIconSize(QtCore.QSize(50,50)) diff --git a/src/frontEnd/ViewManagement.pyc b/src/frontEnd/ViewManagement.pyc Binary files differindex cec8f36d..7e3b4a15 100644 --- a/src/frontEnd/ViewManagement.pyc +++ b/src/frontEnd/ViewManagement.pyc diff --git a/src/frontEnd/Workspace.py b/src/frontEnd/Workspace.py index e52801e7..3b3ef37d 100644 --- a/src/frontEnd/Workspace.py +++ b/src/frontEnd/Workspace.py @@ -28,7 +28,7 @@ class Workspace(QtGui.QWidget): def __init__(self): super(Workspace, self).__init__() - self.obj = Appconfig() + self.obj_appconfig = Appconfig() #Initializing Workspace directory for project self.initWorkspace() @@ -41,9 +41,9 @@ class Workspace(QtGui.QWidget): self.worspace_loc = QtGui.QLineEdit(self) #Add text to text edit,label and line edit - self.note.append(self.obj.workspace_text) + self.note.append(self.obj_appconfig.workspace_text) self.workspace_label.setText("Workspace:") - self.worspace_loc.setText(self.obj.home) + self.worspace_loc.setText(self.obj_appconfig.home) #Buttons self.browsebtn = QtGui.QPushButton('Browse') @@ -94,14 +94,14 @@ class Workspace(QtGui.QWidget): def createWorkspace(self): print "Create workspace is called" self.create_workspace = str(self.worspace_loc.text()) - + #Checking if Workspace already exist or not if os.path.isdir(self.create_workspace): print "Already present" - self.obj.default_workspace["workspace"] = self.create_workspace + self.obj_appconfig.default_workspace["workspace"] = self.create_workspace else: os.mkdir(self.create_workspace) - self.obj.default_workspace["workspace"] = self.create_workspace + self.obj_appconfig.default_workspace["workspace"] = self.create_workspace self.close() diff --git a/src/frontEnd/Workspace.pyc b/src/frontEnd/Workspace.pyc Binary files differindex a1d59398..72024da5 100644 --- a/src/frontEnd/Workspace.pyc +++ b/src/frontEnd/Workspace.pyc diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py new file mode 100644 index 00000000..bbd7664b --- /dev/null +++ b/src/projManagement/Kicad.py @@ -0,0 +1,93 @@ +#=============================================================================== +# +# FILE: openKicad.py +# +# USAGE: --- +# +# DESCRIPTION: It call kicad schematic +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Fahim Khan, fahim.elex@gmail.com +# ORGANIZATION: ecSim team at FOSSEE, IIT Bombay. +# CREATED: Tuesday 17 Feb 2015 +# REVISION: --- +#=============================================================================== + +import os +import Validation +from configuration.Appconfig import Appconfig +import Worker +from PyQt4 import QtGui + +class Kicad: + """ + Class Kicad open Schematic,PCB and Layout + """ + def __init__(self): + self.obj_validation = Validation.Validation() + self.obj_appconfig = Appconfig() + + + def openSchematic(self): + print "Kicad Schematic is called" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #Validating if current project is available or not + + if self.obj_validation.validateKicad(self.projDir): + print "calling Kicad schematic ",self.projDir + self.projName = os.path.basename(self.projDir) + self.project = os.path.join(self.projDir,self.projName) + + #Creating a command to run + self.cmd = "eeschema "+self.project+".sch " + self.obj_workThread = Worker.WorkerThread(self.cmd) + self.obj_workThread.start() + + else: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message") + + + + def openFootprint(self): + print "Kicad Foot print Editor called" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #Validating if current project is available or not + + if self.obj_validation.validateKicad(self.projDir): + print "calling Kicad FootPrint Editor ",self.projDir + self.projName = os.path.basename(self.projDir) + self.project = os.path.join(self.projDir,self.projName) + + #Creating a command to run + self.cmd = "cvpcb "+self.project+".net " + self.obj_workThread = Worker.WorkerThread(self.cmd) + self.obj_workThread.start() + + else: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message") + + def openLayout(self): + print "Kicad Layout is called" + self.projDir = self.obj_appconfig.current_project["ProjectName"] + #Validating if current project is available or not + if self.obj_validation.validateKicad(self.projDir): + print "calling Kicad schematic ",self.projDir + self.projName = os.path.basename(self.projDir) + self.project = os.path.join(self.projDir,self.projName) + + #Creating a command to run + self.cmd = "pcbnew "+self.project+".net " + self.obj_workThread = Worker.WorkerThread(self.cmd) + self.obj_workThread.start() + + else: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message")
\ No newline at end of file diff --git a/src/projManagement/Kicad.pyc b/src/projManagement/Kicad.pyc Binary files differnew file mode 100644 index 00000000..89aabd2d --- /dev/null +++ b/src/projManagement/Kicad.pyc diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index 864ac448..a9da3101 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -24,10 +24,10 @@ class Validation: def __init__(self): pass - def validateOpenproj(self,proj_directory): + def validateOpenproj(self,projDir): print "Validate openProj called" - projName = os.path.basename(str(proj_directory)) - lookProj = os.path.join(str(proj_directory),projName+".proj") + projName = os.path.basename(str(projDir)) + lookProj = os.path.join(str(projDir),projName+".proj") #Check existence of project if os.path.exists(lookProj): return True @@ -37,21 +37,28 @@ class Validation: - def validateNewproj(self,project_dir): + def validateNewproj(self,projDir): print "Validate newProj called" - print "Project Directory : ",project_dir + print "Project Directory : ",projDir #Checking existence of project with same name - if os.path.exists(project_dir): + if os.path.exists(projDir): return "CHECKEXIST" #Project with name already exist else: #Check Proper name for project. It should not have space - if re.search(r"\s",project_dir ): + if re.search(r"\s",projDir ): return "CHECKNAME" else: return "VALID" + + def validateKicad(self,projDir): + print "Validation for Kicad components" + if projDir == None: + return False + else: + return True diff --git a/src/projManagement/Validation.pyc b/src/projManagement/Validation.pyc Binary files differnew file mode 100644 index 00000000..42291553 --- /dev/null +++ b/src/projManagement/Validation.pyc diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py new file mode 100644 index 00000000..be7f323e --- /dev/null +++ b/src/projManagement/Worker.py @@ -0,0 +1,38 @@ +#=============================================================================== +# +# FILE: WorkerThread.py +# +# USAGE: --- +# +# DESCRIPTION: This class open all third party application using QT Thread +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Fahim Khan, fahim.elex@gmail.com +# ORGANIZATION: ecSim team at FOSSEE, IIT Bombay. +# CREATED: Tuesday 24 Feb 2015 +# REVISION: --- +#=============================================================================== +from PyQt4 import QtCore +import os + + +class WorkerThread(QtCore.QThread): + def __init__(self,args): + QtCore.QThread.__init__(self) + self.args = args + + def __del__(self): + self.wait() + + def run(self): + print "Calling :",self.args + self.call_system(self.args) + + def call_system(self,command): + print "System called" + os.system(command) + +
\ No newline at end of file diff --git a/src/projManagement/Worker.pyc b/src/projManagement/Worker.pyc Binary files differnew file mode 100644 index 00000000..3751f2cc --- /dev/null +++ b/src/projManagement/Worker.pyc diff --git a/src/projManagement/__init__.pyc b/src/projManagement/__init__.pyc Binary files differnew file mode 100644 index 00000000..f50153e3 --- /dev/null +++ b/src/projManagement/__init__.pyc diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index 146b0080..f496b490 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -57,29 +57,7 @@ class NewProjectInfo(QtGui.QWidget): self.setWindowTitle("New Project") self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.show() - - - ''' - self.LEGroup = QtGui.QGroupBox() - self.LElayout = QtGui.QHBoxLayout() - self.LElayout.addWidget(self.projLabel) - self.LElayout.addWidget(self.projEdit) - self.LEGroup.setLayout(self.LElayout) - - self.BtnGroup = QtGui.QGroupBox() - self.Btnlayout = QtGui.QVBoxLayout() - self.Btnlayout.addWidget(self.okbtn) - self.Btnlayout.addWidget(self.cancelbtn) - self.BtnGroup.setLayout(self.Btnlayout) - - self.mainlayout = QtGui.QHBoxLayout() - self.mainlayout.addWidget(self.LEGroup) - self.mainlayout.addWidget(self.BtnGroup) - self.mainlayout.addStretch(1) - - self.setLayout(self.mainlayout) - ''' - self.show() + def createProject(self): print "Create Project Called" @@ -87,25 +65,43 @@ class NewProjectInfo(QtGui.QWidget): self.projName = self.projEdit.text() self.projName = str(self.projName).rstrip().lstrip() #Remove leading and trailing space - self.project_dir = os.path.join(self.workspace,str(self.projName)) + self.projDir = os.path.join(self.workspace,str(self.projName)) - self.reply = self.obj_validation.validateNewproj(str(self.project_dir)) + + #Validation for newProject + self.reply = self.obj_validation.validateNewproj(str(self.projDir)) if self.reply == "VALID": print "Validated : Creating project directory" #create project directory - print "Check : ",self.project_dir try: - os.mkdir(self.project_dir) + os.mkdir(self.projDir) self.close() + self.projFile = os.path.join(self.projDir,self.projName+".proj") + f = open(self.projFile,"w") except: print "Some Thing Wrong" + self.msg = QtGui.QErrorMessage(self) + self.msg.showMessage('Unable to create project. Please make sure you have write permission on '+self.workspace) + self.msg.setWindowTitle("Error Message") + f.write("schematicFile " + self.projName+".sch\n") + f.close() + + #Now Change the current working project + self.obj_appconfig.current_project['ProjectName'] = self.projDir elif self.reply == "CHECKEXIST": print "Project already exist" + self.msg = QtGui.QErrorMessage(self) + self.msg.showMessage('The project "'+self.projName+'" already exist.Please select the different name or delete existing project') + self.msg.setWindowTitle("Error Message") + elif self.reply == "CHECKNAME": print "Name is not proper" + self.msg = QtGui.QErrorMessage(self) + self.msg.showMessage('The project name should not contain space between them') + self.msg.setWindowTitle("Error Message") def cancelProject(self): self.close() diff --git a/src/projManagement/newProject.pyc b/src/projManagement/newProject.pyc Binary files differnew file mode 100644 index 00000000..16e13e75 --- /dev/null +++ b/src/projManagement/newProject.pyc diff --git a/src/projManagement/openKicad.py b/src/projManagement/openKicad.py deleted file mode 100644 index 9376589f..00000000 --- a/src/projManagement/openKicad.py +++ /dev/null @@ -1,35 +0,0 @@ -#=============================================================================== -# -# FILE: openKicad.py -# -# USAGE: --- -# -# DESCRIPTION: It call kicad schematic -# -# OPTIONS: --- -# REQUIREMENTS: --- -# BUGS: --- -# NOTES: --- -# AUTHOR: Fahim Khan, fahim.elex@gmail.com -# ORGANIZATION: ecSim team at FOSSEE, IIT Bombay. -# CREATED: Tuesday 17 Feb 2015 -# REVISION: --- -#=============================================================================== - -class Kicad: - """ - Class Kicad open Schematic,PCB and Layout - """ - def __init__(self): - pass - - def openSchematic(self): - print "Kicad Schematic is called" - - def openFootprint(self): - print "Kicad Foot print Editor called" - - def openLayout(self): - print "Kicad Layout is called" - -
\ No newline at end of file diff --git a/src/projManagement/openKicad.pyc b/src/projManagement/openKicad.pyc Binary files differnew file mode 100644 index 00000000..04f934d3 --- /dev/null +++ b/src/projManagement/openKicad.pyc diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index 3bbdfc37..2949da45 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -23,22 +23,22 @@ from configuration.Appconfig import Appconfig -class ProjectInfo(QtGui.QWidget): +class OpenProjectInfo(QtGui.QWidget): """ Class ProjectInfo accept model information from user """ def __init__(self): - super(ProjectInfo, self).__init__() + super(OpenProjectInfo, self).__init__() self.obj_validation = Validation() def body(self): - self.proj_directory = QtGui.QFileDialog.getExistingDirectory() + self.projDir = QtGui.QFileDialog.getExistingDirectory() - if self.obj_validation.validateOpenproj(self.proj_directory) == True: + if self.obj_validation.validateOpenproj(self.projDir) == True: print "Pass open project test" self.obj_Appconfig = Appconfig() - self.obj_Appconfig.current_project['ProjectName'] = self.proj_directory + self.obj_Appconfig.current_project['ProjectName'] = str(self.projDir) else: diff --git a/src/projManagement/openProject.pyc b/src/projManagement/openProject.pyc Binary files differnew file mode 100644 index 00000000..c97b7919 --- /dev/null +++ b/src/projManagement/openProject.pyc |