diff options
author | fahim | 2015-05-19 18:16:17 +0530 |
---|---|---|
committer | fahim | 2015-05-19 18:16:17 +0530 |
commit | 7e471c072b18c3969ed5573dbe24923c2f678b5f (patch) | |
tree | c94a4e57b769140ea841add43b32b04d8f5d573e /src/frontEnd | |
parent | 07e43f9abbf5e369543f090ccf89f565038241cb (diff) | |
download | eSim-7e471c072b18c3969ed5573dbe24923c2f678b5f.tar.gz eSim-7e471c072b18c3969ed5573dbe24923c2f678b5f.tar.bz2 eSim-7e471c072b18c3969ed5573dbe24923c2f678b5f.zip |
Subject: Added NgSpice window inside dock area.
Description: Added NgSpice window inside dock area.
Diffstat (limited to 'src/frontEnd')
-rwxr-xr-x | src/frontEnd/Application.py | 71 | ||||
-rw-r--r-- | src/frontEnd/DockArea.py | 40 | ||||
-rwxr-xr-x | src/frontEnd/ViewManagement.py | 119 | ||||
-rw-r--r-- | src/frontEnd/ViewManagement.pyc | bin | 2841 -> 0 bytes |
4 files changed, 76 insertions, 154 deletions
diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index e15c71b1..97e07a17 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -23,14 +23,15 @@ from configuration.Appconfig import Appconfig from projManagement.openProject import OpenProjectInfo from projManagement.newProject import NewProjectInfo from projManagement.Kicad import Kicad -import os -import ViewManagement +from frontEnd import ProjectExplorer import Workspace +import DockArea + +import os import sys import time -import subprocess -import DockArea -from frontEnd import ProjectExplorer +import shutil + class Application(QtGui.QMainWindow): """ @@ -49,7 +50,6 @@ class Application(QtGui.QMainWindow): self.obj_Mainview = MainView() self.obj_appconfig = Appconfig() - #Initialize all widget self.setCentralWidget(self.obj_Mainview) self.initToolBar() @@ -64,12 +64,13 @@ class Application(QtGui.QMainWindow): def initToolBar(self): - + """ + This function initialize Tool Bar + """ #Top Tool bar self.newproj = QtGui.QAction(QtGui.QIcon('../images/newProject.png'),'<b>New Project</b>',self) self.newproj.setShortcut('Ctrl+N') self.newproj.triggered.connect(self.new_project) - #self.newproj.connect(self.newproj,QtCore.SIGNAL('triggered()'),self,QtCore.SLOT(self.new_project())) self.openproj = QtGui.QAction(QtGui.QIcon('../images/openProject.png'),'<b>Open Project</b>',self) @@ -90,7 +91,7 @@ class Application(QtGui.QMainWindow): self.topToolbar.addAction(self.exitproj) self.topToolbar.addAction(self.helpfile) - #Left Tool bar + #Left Tool bar Action Widget self.kicad = QtGui.QAction(QtGui.QIcon('../images/default.png'),'<b>Open Schematic</b>',self) self.kicad.triggered.connect(self.obj_kicad.openSchematic) @@ -105,8 +106,8 @@ class Application(QtGui.QMainWindow): self.pcb = QtGui.QAction(QtGui.QIcon('../images/default.png'),'<b>PCB Layout</b>',self) self.pcb.triggered.connect(self.obj_kicad.openLayout) - + #Adding Action Widget to tool bar self.lefttoolbar = QtGui.QToolBar('Left ToolBar') self.addToolBar(QtCore.Qt.LeftToolBarArea, self.lefttoolbar) self.lefttoolbar.addAction(self.kicad) @@ -115,14 +116,7 @@ class Application(QtGui.QMainWindow): self.lefttoolbar.addAction(self.footprint) self.lefttoolbar.addAction(self.pcb) self.lefttoolbar.setOrientation(QtCore.Qt.Vertical) - - def initView(self): - """ - Create GUI from the class Views and initialize it - """ - self.view = ViewManagement.ViewManagement() - self.setCentralWidget(self.view) - + def new_project(self): """ This function call New Project Info class. @@ -157,15 +151,32 @@ class Application(QtGui.QMainWindow): This Function execute ngspice on current project """ - ret_val = self.obj_kicad.openNgspice() + self.projDir = self.obj_appconfig.current_project["ProjectName"] - if ret_val: - self.obj_Mainview.obj_dockarea.plottingEditor() + if self.projDir != None: + self.obj_Mainview.obj_dockarea.ngspiceEditor(self.projDir) + time.sleep(2) #Need permanent solution + try: + #Moving plot_data_i.txt and plot_data_v.txt to project directory + shutil.copy2("plot_data_i.txt", self.projDir) + shutil.copy2("plot_data_v.txt", self.projDir) + #Deleting this file from current directory + os.remove("plot_data_i.txt") + os.remove("plot_data_v.txt") + #Calling Python Plotting + self.obj_Mainview.obj_dockarea.plottingEditor() + except Exception as e: + self.msg = QtGui.QErrorMessage(None) + self.msg.showMessage('Unable to copy plot data file to project directory.') + print "Exception:",str(e) + self.msg.setWindowTitle("Error Message") + else: - print "Unable to open NgSpice" - - + self.msg = QtGui.QErrorMessage() + self.msg.showMessage('Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message") + def exit_project(self): print "Exit Project called" @@ -185,14 +196,13 @@ class Application(QtGui.QMainWindow): def help_project(self): print "Help is called" print "Current Project : ",self.obj_appconfig.current_project - self.obj_Mainview.obj_dockarea.plottingEditor() + #self.obj_Mainview.obj_dockarea.plottingEditor() - - def testing(self): - print "Success hit kicad button" - class MainView(QtGui.QWidget): + """ + This class initialize the Main View of Application + """ def __init__(self, *args): # call init method of superclass QtGui.QWidget.__init__(self, *args) @@ -209,8 +219,7 @@ class MainView(QtGui.QWidget): self.noteArea = QtGui.QTextEdit() self.obj_dockarea = DockArea.DockArea() self.obj_projectExplorer = ProjectExplorer.ProjectExplorer() - - + #Adding content to vertical middle Split. self.middleSplit.setOrientation(QtCore.Qt.Vertical) self.middleSplit.addWidget(self.obj_dockarea) diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 88fecbcf..875b3b90 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -1,9 +1,10 @@ from PyQt4 import QtGui,QtCore from ngspiceSimulation.pythonPlotting import plotWindow +from ngspiceSimulation.NgspiceWidget import NgspiceWidget from configuration.Appconfig import Appconfig import os -dockList = ['Blank'] +dockList = ['Welcome'] count = 1 dock = {} @@ -40,7 +41,7 @@ class DockArea(QtGui.QMainWindow): dock['Tips-'+str(count)] = QtGui.QDockWidget('Tips-'+str(count)) dock['Tips-'+str(count)].setWidget(self.testWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Tips-'+str(count)]) - self.tabifyDockWidget(dock['Blank'],dock['Tips-'+str(count)]) + self.tabifyDockWidget(dock['Welcome'],dock['Tips-'+str(count)]) dock['Tips-'+str(count)].setVisible(True) dock['Tips-'+str(count)].setFocus() @@ -50,7 +51,7 @@ class DockArea(QtGui.QMainWindow): def plottingEditor(self): """ - This function create widget for Library Editor + This function create widget for interactive PythonPlotting """ self.projDir = self.obj_appconfig.current_project["ProjectName"] self.projName = os.path.basename(self.projDir) @@ -68,7 +69,7 @@ class DockArea(QtGui.QMainWindow): dock['Plotting-'+str(count)] = QtGui.QDockWidget('Plotting-'+str(count)) dock['Plotting-'+str(count)].setWidget(self.plottingWidget) self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['Plotting-'+str(count)]) - self.tabifyDockWidget(dock['Blank'],dock['Plotting-'+str(count)]) + self.tabifyDockWidget(dock['Welcome'],dock['Plotting-'+str(count)]) dock['Plotting-'+str(count)].setVisible(True) dock['Plotting-'+str(count)].setFocus() @@ -76,6 +77,37 @@ class DockArea(QtGui.QMainWindow): count = count + 1 + def ngspiceEditor(self,projDir): + """ + This function creates widget for NgSpice window + """ + + + self.projDir = projDir + self.projName = os.path.basename(self.projDir) + self.ngspiceNetlist = os.path.join(self.projDir,self.projName+".cir.out") + + + + global count + self.ngspiceWidget = QtGui.QWidget() + + self.ngspiceLayout = QtGui.QVBoxLayout() + self.ngspiceLayout.addWidget(NgspiceWidget(self.ngspiceNetlist)) + + #Adding to main Layout + self.ngspiceWidget.setLayout(self.ngspiceLayout) + dock['NgSpice-'+str(count)] = QtGui.QDockWidget('NgSpice-'+str(count)) + dock['NgSpice-'+str(count)].setWidget(self.ngspiceWidget) + self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock['NgSpice-'+str(count)]) + self.tabifyDockWidget(dock['Welcome'],dock['NgSpice-'+str(count)]) + + dock['NgSpice-'+str(count)].setVisible(True) + dock['NgSpice-'+str(count)].setFocus() + dock['NgSpice-'+str(count)].raise_() + + count = count + 1 + diff --git a/src/frontEnd/ViewManagement.py b/src/frontEnd/ViewManagement.py deleted file mode 100755 index 2b770387..00000000 --- a/src/frontEnd/ViewManagement.py +++ /dev/null @@ -1,119 +0,0 @@ - -#=============================================================================== -# -# FILE: ViewManagement.py -# -# USAGE: --- -# -# DESCRIPTION: It contain all the view for main Application -# -# OPTIONS: --- -# REQUIREMENTS: --- -# BUGS: --- -# NOTES: --- -# AUTHOR: Fahim Khan, fahim.elex@gmail.com -# ORGANIZATION: eSim team at FOSSEE, IIT Bombay. -# CREATED: Wednesday 27 January 2015 -# REVISION: --- -#=============================================================================== - - - -from PyQt4 import QtCore -from PyQt4 import QtGui -from projManagement.Kicad import Kicad -from ProjectExplorer import ProjectExplorer - - - -class ViewManagement(QtGui.QSplitter): - """ - This class creates View on FrontWindow - """ - - def __init__(self, *args): - # call init method of superclass - QtGui.QSplitter.__init__(self, *args) - # Creating dictionary which hold all the views - self.views = {} - - #Creating object of Kicad.py - self.obj_kicad = Kicad() - - # define the basic framework of view areas for the - # application - self.createView() - self.setupView() - - def createView(self): - #Adding view into views dictionary - self.addView(ProjectExplorer, 'ProjectExplorer') - self.addView(QtGui.QTextEdit, 'MainArea') - self.addView(QtGui.QTextEdit, 'Browser') - - - - def setupView(self): - #setup views to define various areas, such as placement of individual views - # the right segment also is a splitter, but with vertical orientation - self.right = QtGui.QSplitter() - self.right.setOrientation(QtCore.Qt.Vertical) - - - #Button for Project Tool Bar - self.kicad = QtGui.QAction(QtGui.QIcon('../images/default.png'),'<b>Open Schematic</b>',self) - self.kicad.triggered.connect(self.obj_kicad.openSchematic) - - self.conversion = QtGui.QAction(QtGui.QIcon('../images/default.png'),'<b>Convert Kicad to Ngspice</b>',self) - self.conversion.triggered.connect(self.obj_kicad.openKicadToNgspice) - - - self.ngspice = QtGui.QAction(QtGui.QIcon('../images/default.png'), '<b>Simulation</b>', self) - - self.footprint = QtGui.QAction(QtGui.QIcon('../images/default.png'),'<b>Footprint Editor</b>',self) - self.footprint.triggered.connect(self.obj_kicad.openFootprint) - - self.pcb = QtGui.QAction(QtGui.QIcon('../images/default.png'),'<b>PCB Layout</b>',self) - self.pcb.triggered.connect(self.obj_kicad.openLayout) - - self.lefttoolbar= QtGui.QToolBar() - self.lefttoolbar.addAction(self.kicad) - self.lefttoolbar.addAction(self.conversion) - self.lefttoolbar.addAction(self.ngspice) - self.lefttoolbar.addAction(self.footprint) - self.lefttoolbar.addAction(self.pcb) - #Adding one more splitter - self.browser = QtGui.QSplitter() - self.browser.setOrientation(QtCore.Qt.Vertical) - - # bind the top level views into the framework - - self.lefttoolbar.setParent(self) - self.lefttoolbar.setOrientation(QtCore.Qt.Vertical) - - self.views['ProjectExplorer'].setParent(self) - self.views['MainArea'].setParent(self.right) - self.views['Plotting'].setParent(self.right) - #self.views['Plotting'].setReadOnly(True) - self.views['Browser'].setParent(self.browser) - self.views['Browser'].setReadOnly(True) - - self.right.setParent(self) - self.browser.setParent(self) - self.right.setSizes([20, 5]) - #self.setSizes([5, 20]) - - def addView(self, settype, name): - - #Adding views to dictionary - #parameters: - #settype <class> - #name <string> - - self.views[name] = settype() - - - - - - diff --git a/src/frontEnd/ViewManagement.pyc b/src/frontEnd/ViewManagement.pyc Binary files differdeleted file mode 100644 index efc44372..00000000 --- a/src/frontEnd/ViewManagement.pyc +++ /dev/null |