[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: geda_manager.git: branch: master updated (003c1a0e29b8709af45db6291e343945440bc7d1)



The branch, master has been updated
       via  003c1a0e29b8709af45db6291e343945440bc7d1 (commit)
      from  3785ccdb511b0dd37e65f3575510e4071cde8e52 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/gedamanager.py |  103 +++++++++++++++++++++----------
 src/gsch2pcb.py    |  175 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/utils.py       |   31 +++++++---
 3 files changed, 268 insertions(+), 41 deletions(-)
 create mode 100644 src/gsch2pcb.py


=================
 Commit Messages
=================

commit 003c1a0e29b8709af45db6291e343945440bc7d1
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Sun Aug 24 02:56:21 2008 -0700

    New file for helping with the workflow of gsch2pcb so that the user
    can select multiple schematics.  Still a work in progress but almost done.

:100644 100644 1c567ca... 7a3c1a5... M	src/gedamanager.py
:000000 100644 0000000... aad0f48... A	src/gsch2pcb.py
:100644 100644 d96a2b3... 5f6c536... M	src/utils.py

=========
 Changes
=========

commit 003c1a0e29b8709af45db6291e343945440bc7d1
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Sun Aug 24 02:56:21 2008 -0700

    New file for helping with the workflow of gsch2pcb so that the user
    can select multiple schematics.  Still a work in progress but almost done.

diff --git a/src/gedamanager.py b/src/gedamanager.py
index 1c567ca..7a3c1a5 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -241,7 +241,7 @@ class gEDAManager:
         # Dependencies Tree View
         self.dependencies_tree = gtk.TreeView(self.dependencies)
         self.dependencies_tree.show()
-        self.dependencies_tree.connect('columns-changed', self.cb_columns_changed)
+##         self.dependencies_tree.connect('columns-changed', self.cb_columns_changed)
 ##         # we'll add some data now - 4 rows with 3 child rows each
 ##         for parent in range(4):
 ##             piter = self.dependencies.append(None, ['parent %i' % parent])
@@ -459,10 +459,14 @@ class gEDAManager:
     def set_dependencies_tree_to_project(self):
         """ Method to set the tree to current project object. """
 
-        self.dependencies.clear()
-        if self.project.dependency_dict != None:
-            self.load_dependencies_tree(self.project.dependency_dict)
-            self.dependencies_tree.expand_all()        
+##         self.dependencies.clear()
+##         if self.project.dependency_dict != None:
+##             self.depnum = 0
+##             self.load_dependencies_tree(self.project.dependency_dict)
+##             self.dependencies_tree.expand_all()        
+
+##         # Connect to the 'columns-changed' signal
+##         self.dependencies.connect('row-changed', self.cb_row_changed)
 
 
     def set_sources_tree_to_new_project(self):
@@ -490,17 +494,20 @@ class gEDAManager:
     def set_dependencies_tree_to_new_project(self):
         """ Method to set the tree to newly created project object. """
 
-        self.dependencies.clear()
-        # Parent Folder
-        project_path = self.project.directory + '/' + self.project.name        
-        project_file_path = project_path + '.gm'        
-        output_file_path = self.project.directory + '/output.log'
-        error_file_path = self.project.directory + '/error.log'
-        self.dependencies.append(None, [self.project.name + '.gm', project_file_path])
-        self.dependencies.append(None, ['output.log', output_file_path])
-        self.dependencies.append(None, ['error.log', error_file_path])
-        self.dependencies_tree.expand_all()
-
+ ##        self.dependencies.clear()
+##         # Parent Folder
+##         project_path = self.project.directory + '/' + self.project.name        
+##         project_file_path = project_path + '.gm'        
+##         output_file_path = self.project.directory + '/output.log'
+##         error_file_path = self.project.directory + '/error.log'
+##         self.dependencies.append(None, [self.project.name + '.gm', project_file_path])
+##         self.dependencies.append(None, ['output.log', output_file_path])
+##         self.dependencies.append(None, ['error.log', error_file_path])
+##         self.dependencies_tree.expand_all()
+
+##         # Connect to the 'columns-changed' signal
+##         self.dependencies.connect('row-changed', self.cb_row_changed)
+##         self.depnum = 3
 
     def load_sources_tree(self, file_list, parent=None, parent_path=None):
         """!
@@ -540,7 +547,7 @@ class gEDAManager:
                 n_parent = self.sources.append(parent, [image, f, file_path])
 
 
-    def load_dependencies_tree(self, dep_dict, parent=None, parent_path=None):
+    def load_dependencies_tree(self, dep_dict, parent=None, parent_path=None, number=None):
         """!
         Method to the load the dependencies tree
         @param dependency_dict of the project's dependencies
@@ -549,6 +556,9 @@ class gEDAManager:
         to the self.sources gtk.TreeStore object
         """
         print 'Loading Dependencies'
+        print 'dep_dict:',dep_dict
+        print 'parent_path:',parent_path
+        print 'parent:',parent
         for key, value in dep_dict.iteritems():
             # filepath
             if parent_path != None:
@@ -558,12 +568,14 @@ class gEDAManager:
             # parent
             if parent != None:
                 n_parent = self.dependencies.append(parent, [key, filepath])
+                self.depnum += 1
             else:
                 n_parent = self.dependencies.append(None, [key, filepath])
+                self.depnum += 1
             # recurse
             if isinstance(value, dict):
-                self.load_dependencies_tree(value, n_parent, filepath)
-                
+                self.load_dependencies_tree(value, n_parent, filepath, self.depnum)
+
 
     def save_settings(self):
         """ Method to save current settings to .gmrc file. """
@@ -1346,25 +1358,50 @@ class gEDAManager:
                 self.processes.clear()
 
 
-    def cb_columns_changed(self, widget):
+    def cb_row_changed(self, model, path, _iter):
         """!
         Event occurs when the columns change in the dependencies treeview.
         @param widget that threw the event
         """
-#        self.update_dependency_dict(self, 
-        # Start a new dictionary
-        self.project.dependency_dict = {}
-        # Iterate over the whole tree and create the project.depedency_dict
-        for row in self.dependencies:
-            print 'row:',row
-            row_iter = row.iterchildren()
-            if row_iter != None:
-                # We have children for this row so we need to nest
-                print 'row_iter:',row_iter
-            else:
-                # Add key, value pair to the dictionary
-                self.project.dependency_dict[row[0]] = None
+##         print 'model:',model
+##         print 'path:',path
+##         print '_iter:',_iter
+##         if len(self.dependencies) != self.depnum:
+##             print 'Not equal'
+##         # Iterate over the whole tree and create the project.depedency_dict
+##         for i, row in enumerate(self.dependencies):
+##             print 'i:',i
+##             print 'row[0]:',row[0]
+##             if i < self.depnum: 
+##                 for r in row:
+##                     print 'r:',r
+##             row_iter = row.iterchildren()
+##             print 'row_iter for row:',row_iter
+##             try:
+##                 for z in row_iter.next():
+##                     print 'z:',z
+##             except:
+##                 pass
+#                self.project.dependency_dict[row[0]] = lst.append(self.update_dependency_dict(row_iter))
+#        print 'self.project.dependency_dict:',self.project.dependency_dict
 
+        
+    def update_dependency_dict(self, row_iter):
+        """!
+        Method to update the dependency_dict ... this is really a helper
+        """
+        lst = []
+        try:
+            for row in row_iter.next():
+                baby_row_iter = row.iterchildren()
+                if baby_row_iter != None:
+                    self.project.dependency_dict[row[0]] = lst.append(self.update_dependency_dict(baby_row_iter))
+                else:
+                    self.project.dependency_dict[row[0]] = lst
+            return lst
+        except:
+            pass # Don't want the StopIteration exception to be raised
+        
 
     def cb_popup_deactivate(self, popup_menu, merge_id):
         """!
diff --git a/src/gsch2pcb.py b/src/gsch2pcb.py
new file mode 100644
index 0000000..aad0f48
--- /dev/null
+++ b/src/gsch2pcb.py
@@ -0,0 +1,175 @@
+#! /usr/bin/env python
+
+# gEDA Manager
+# Copyright (C) 2008 Newell Jensen
+# Copyright (C) 2008 gEDA Contributors (see ChangeLog for details)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+##@package src.gsch2pcb
+#Gui for gsch2pcb workflow
+#@author Newell Jensen
+
+import os, pygtk, gtk
+pygtk.require('2.0')
+from lib.decorators import exceptions
+
+class Gsch2pcb:
+    """
+    Message Dialog for the gsch2pcb workflow.
+    This class allows the user to select multiple schematics
+    to be used in the gsch2pcb workflow to produce a PCB file.
+    """
+    @exceptions
+    def __init__(self, gedamanager, filepath):
+        """!
+        Gsch2pcb Constructor.
+        @param filepath of the file to be automatically included
+        in the checklist of schematics.
+        """
+        self.g = gedamanager            
+        def response_to_dialog_directory(entry, dialog, response):
+            dialog.response(response)
+
+        def response_to_dialog_name(entry, dialog, response):
+            dialog.response(response)
+
+        directory_entry = gtk.Entry()
+        directory_entry.set_text(os.getcwd())
+        directory_entry.show()
+
+        def cb_filebutton_selection_changed(filechooser, directory_entry):
+            self.directory = self.filebutton.get_filename()
+            directory_entry.set_text(self.directory)
+
+        self.dialog = gtk.MessageDialog(self.g.window,
+                                   (gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
+                                   gtk.MESSAGE_OTHER,
+                                   gtk.BUTTONS_OK_CANCEL,
+                                   gtk.STOCK_DIRECTORY)
+        self.dialog.set_markup('<b>Select all the schematics from the project that\nyou would like to include in creating the target PCB.\nChoose PCB name and the target directory.\nIf there is a PCB with the same name in the target\ndirectory it will create a *.new.pcb file.</b>')
+        self.dialog.set_title('gsch2pcb workflow')
+
+        # Target Directory
+        hbox = gtk.HBox()
+        hbox.show()
+        self.filebutton = gtk.FileChooserButton('Target Directory')
+        self.filebutton.show()
+        self.filebutton.connect('selection-changed',
+                                cb_filebutton_selection_changed, directory_entry)
+        self.filebutton.set_local_only(True)
+        self.filebutton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+        hbox.pack_end(self.filebutton)
+        directory_entry.connect('activate', response_to_dialog_directory, self.dialog, gtk.RESPONSE_OK)
+        hbox.pack_end(directory_entry)
+        label = gtk.Label('Target Directory:')
+        label.show()
+        hbox.pack_end(label)
+        self.dialog.vbox.pack_end(hbox, True, True, 0)
+
+        # PCB name
+        hbox = gtk.HBox()
+        hbox.show()
+        name_entry = gtk.Entry()
+        name_entry.show()
+        name_entry.connect('activate', response_to_dialog_name, self.dialog, gtk.RESPONSE_OK)        
+        hbox.pack_end(name_entry)
+        label = gtk.Label('PCB Name (extension will be provided):')
+        label.show()
+        hbox.pack_end(label)
+        self.dialog.vbox.pack_end(hbox, True, True, 0)
+
+        # Schematic selections
+        scrolled_window = gtk.ScrolledWindow()
+        scrolled_window.show()
+        scrolled_window.set_shadow_type(gtk.SHADOW_IN)
+        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        # Get schematics in project no matter what directory
+        # They must be listed in the sources tree view though
+        self.schematics = self.get_schematics()
+        print 'self.schematics:',self.schematics
+        print 'len of self.schematics:', len(self.schematics)
+        self.schematics_tree = gtk.TreeView(self.schematics)
+        self.schematics_tree.show()
+        column = gtk.TreeViewColumn('File', gtk.CellRendererText(), text=0)
+        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
+        self.schematics_tree.append_column(column)
+        toggle = gtk.CellRendererToggle()
+        toggle.set_property('activatable', True)
+        toggle.connect('toggled', self.cb_toggled, self.schematics)
+        column = gtk.TreeViewColumn('Include', toggle)
+        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
+        self.schematics_tree.append_column(column)        
+        scrolled_window.add(self.schematics_tree)
+        self.dialog.vbox.pack_end(scrolled_window, True, True, 0)
+        
+        self.dialog.show()
+        self.dialog.run()
+        self.dialog.destroy()
+
+        # If the target directory is in the project, update tree view
+        # else do nothing but still write to disk
+    def cb_toggled(self, cell, path, model):
+        model[path][1] = not model[path][1]
+        print "Toggle '%s' to: %s" % (model[path][0], model[path][1],)
+        return
+
+
+    def get_schematics(self):
+        # Iterate over the 'Sources' tree view
+        # and return a gtk.TreeStore with the schematics
+        # that we want to display
+        self.schematics = gtk.TreeStore(str, str)
+        lst = []
+        lst = self.search(self.g.sources, self.match_func, (1, '.sch'))
+        if lst != None:
+            for f in lst:
+                print f
+                self.schematics.append(None, [f[1], f[2]])
+
+        print 'self.schematics:',self.schematics
+        print 'len of self.schematics:', len(self.schematics)        
+        return self.schematics
+
+        
+    def match_func(self, row, data):
+        column, key = data # data is a tuple containing column number, key
+        return row[column].endswith(key)
+
+
+    def search(self, rows, func, data, lst=None):
+        print 'in search'
+        if lst == None:
+            lst = []
+        else:
+            print 'hhehreh'
+        if not rows:
+            return None
+        for row in rows:
+            print 'in in search'
+            if func(row, data):
+                print 'in in in search'
+                print 'lst:',lst
+                if lst != None:
+                    lst.append(row)
+                    return lst
+            lst = self.search(row.iterchildren(), func, data, lst)
+            if lst:
+                return lst
+        return None
+
+
+        
diff --git a/src/utils.py b/src/utils.py
index d96a2b3..5f6c536 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -26,6 +26,7 @@
 import os, pygtk, gtk, dbus, time
 pygtk.require('2.0')
 from lib.decorators import exceptions
+from gsch2pcb import Gsch2pcb
 from project import *
 from settings import *
 from subprocess import *
@@ -53,7 +54,7 @@ class Utils:
         """ Method to load the icon look up table and netlists list. """
         self.configfiles = ['gschemrc','.gschemrc','gafrc','.gafrc','gnetlistrc','.gnetlistrc','gattribrc','.gattribrc','attribs','.attribs']
 
-        self.netlists = ['bom2','calay','mathematica','vipec','geda','systemc','allegro','redac','drc2','cascade','pads','bae','pcbpins','vams','drc','gsch2pcb','partslist2','partslist3','partslist-common','gossip','maxascii','PCB','vhdl','tango','spice-sdb','partstlist1','PCBboard','switchcap','osmond','spice','verilog','bom','eagle','protelII','futurenet2','gnetlist']
+        self.netlists = ['bom2','calay','mathematica','vipec','geda','systemc','allegro','redac','drc2','cascade','pads','bae','pcbpins','vams','drc','gsch2pcb','partslist2','partslist3','partslist-common','gossip','maxascii','PCB','vhdl','tango','spice-sdb','partstlist1','PCBboard','switchcap','osmond','spice','verilog','bom','eagle','protelII','futurenet2']
 
         # Images to import for later use
         image = gtk.gdk.pixbuf_new_from_file('../images/icons/geda-xgsch2pcb-48.png')
@@ -266,6 +267,11 @@ class Utils:
                 g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Added copy of source:' + filepath + ' to ' + selected_node + '.\n')
                 if filename not in g.project.dependency_dict:
                     g.project.dependency_dict[filename] = []
+            elif filepath == selected_node + '/' + filename:
+                g.sources.append(selection_iter, [image, filename, path])
+                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Added copy of source:' + filepath + ' to project.\n')
+                if filename not in g.project.dependency_dict:
+                    g.project.dependency_dict[filename] = []
             else:
                 g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + filename + ' is already present in the directory: ' + selected_node + '.\n')
         elif index == 1:
@@ -389,7 +395,7 @@ class Utils:
             # PCB
             image = icon.load_icon(self.icon_lut['g2p'], 22, 0)
             status_image = self.get_status_image(g, selected_node, 'pcb')
-            g.processes.append(create_pcb, ['gsch2pcb', image, status_image])
+            g.processes.append(create_pcb, ['gsch2pcb workflow', image, status_image])
 
             # Netlists
             image = icon.load_icon(self.icon_lut['net'], 22, 0)
@@ -518,9 +524,11 @@ class Utils:
         @param ext is the extension of the selected file
         """
         g = gedamanager
+        print 'filepath:',filepath
         files = ['net','log','bom','bom1','bom2','v','vhd','gm','txt']
         # Sources
         if ext != None:
+            os.chdir(filepath.rpartition('/')[0])            
             if ext == 'sch' or ext == 'sym':
                 if g.tools['sch'] == None or g.tools['sch'].poll() == 0:
                     g.tools['sch'] = Popen(['gschem', filepath], stdin=PIPE)
@@ -561,6 +569,7 @@ class Utils:
                     dialog.destroy()
 
         else: # Processes
+            os.chdir(highlighted_source.rpartition('/')[0])
             # The filepath in this case is actually the program to run
             # so we will make the substitution to make it clearer
             program = filepath            
@@ -569,11 +578,9 @@ class Utils:
             # and whether or not it is currently running (GUI only)
 
             # Netlists
+            print 'program:',program
             if program in self.netlists: # use gnetlist
-                if program == 'gnetlist':
-                    return
-                arg = '-v -g ' + program + ' ' + highlighted_source
-                subproc = Popen(['gnetlist', arg])
+                subproc = Popen(['gnetlist', '-v','-g',program,highlighted_source])
             elif program == 'ghdl-compile':
                 pass
             elif program == 'ghdl-compile->gtkwave-simulate':
@@ -591,6 +598,10 @@ class Utils:
             elif program == 'gsymcheck':
                 arg = '-v ' + highlighted_source
                 subproc = Popen([program, arg])
+            elif program == 'gsch2pcb workflow':
+                # Call new class logic to go through the workflow
+                self.gsch2pcb = Gsch2pcb(g, highlighted_source)
+                pass
             else:
                 print 'program:',program
                 subproc = Popen([program, highlighted_source])                
@@ -614,8 +625,12 @@ class Utils:
         # Now set the new_list as the value for filename
         print 'new_list:', new_list
         gedamanager.project.dependency_dict[filename] = new_list
-        # Update the project by saving it
-        gedamanager.project.save()
+
+        # Below is commented out because it was causing an infinite loop
+        # since saving the project updates the project.gm file
+
+##         # Update the project by saving it
+##         gedamanager.project.save()
             
         
     def add_to_dependency_dict(self, gedamanager, filename):




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs