Esempio n. 1
0
	rows = int (len(bst) / math.sqrt(aw))
	if rows < 2 :
		rows = 2
	offsets = []
	for i in range(0, rows) : offsets.append(0)
	dx *= 1.4
	dy *= 1.8
	for t in bst :
		y = t[1] # t[1] = 0 :  start, noone uses it
		# correction to move further down
		c = rows - (rows * t[2] / aw)
		if t[1] : # the less users the far below
			if t[2] == 0 :
				y = rows - 1
			elif t[1] >= rows :
				# compensate for some of the weight, FIXME: better guess needed
				y = int(rows - 2 * aw / (t[2] + t[1]))
		print t[0].properties["name"].value, t[1], t[2], y, c
		# move the object to it's new place
		x = offsets[y]
		t[0].move (x * dx, y * dy)
		offsets[y] += 1
	data.update_extents ()

# this module is loaded by some other plug-ins but can also work on it's own
# if it is loaded first as Dia plug-in and later as Python module everything works
# fine due to Pythoninitializing the module only once
dia.register_callback ("Arrange Objects", 
                       "<Display>/Objects/Arrange", 
                       arrange_connected)
            fields = views['fields']
            for field in fields:
                default = sock.execute(db, uid, password, model, 'default_get',
                                       [field])
                if len(default) and default[field]:
                    if fields[field]['type'] == 'many2one':
                        val = sock.execute(db, uid, password,
                                           fields[field]['relation'], 'read',
                                           default[field], ['name'])['name']
                        default[field] = val
                    defaults.update(default)

            d = display(views, defaults)
            if draw:
                d.draw(data, flags, views['type'])


if __name__ == '__main__':
    main(draw=False)


def main2(data, flags):
    layer = data.active_layer
    oType = dia.get_object_type("shape - char")
    o, h1, h2 = oType.create(1.4, 7.95)
    layer.add_object(o)


dia.register_callback("Load Open ERP View",
                      "<Display>/Tools/Load Open ERP View", main)
Esempio n. 3
0
	dx *= 1.4
	dy *= 1.8
	for t in bst :
		y = t[1] # t[1] = 0 :  start, noone uses it
		# correction to move further down
		c = rows - (rows * t[2] / aw)
		if t[1] : # the less users the far below
			if t[2] == 0 :
				y = rows - 1
			elif t[1] >= rows :
				# compensate for some of the weight, FIXME: better guess needed
				y = int(rows - 2 * aw / (t[2] + t[1]))
		print t[0].properties["name"].value, t[1], t[2], y, c
		# move the object to it's new place
		x = offsets[y]
		t[0].move (x * dx, y * dy)
		offsets[y] += 1
	data.update_extents ()

##
# \file arrange.py \brief Arrange Objects Plugin
#
# this module is loaded by some other plug-ins but can also work on it's own
# if it is loaded first as Dia plug-in and later as Python module everything works
# fine due to Pythoninitializing the module only once
#
# \ingroup PyDia
dia.register_callback ("Arrange Objects", 
                       "<Display>/Objects/Arrange", 
                       arrange_connected)
            model, view_id, view_type = result
            views = sock.execute(db, uid, password, model, 'fields_view_get', view_id, view_type, {}, True)
            fields = views['fields']
            for field in fields:
                default = sock.execute(db, uid, password, model, 'default_get',[field])
                if len(default) and default[field]:
                    if fields[field]['type'] == 'many2one':
                        val = sock.execute(db, uid, password, fields[field]['relation'], 'read', default[field], ['name'])['name']
                        default[field] = val
                    defaults.update(default)
                        
            d = display(views, defaults)
            if draw:
                d.draw(data, flags,views['type'])

if __name__=='__main__':
    main(draw =False)


def main2(data, flags):
    layer = data.active_layer
    oType = dia.get_object_type ("shape - char") 
    o, h1, h2 = oType.create (1.4,7.95)
    layer.add_object(o)

dia.register_callback ("Load Open ERP View", 
                       "<Display>/Tools/Load Open ERP View", 
                       main)


Esempio n. 5
0
        r = o.bounding_box
        (x, y) = o.properties["obj_pos"].value
        dx = (r.right + r.left) / 2 - cx
        dy = (r.bottom + r.top) / 2 - cy
        o.move(x - dx, y - dy)


def dia_objects_center_cb(data, flags):
    grp = data.get_sorted_selected()
    if (len(grp) > 1):
        center_objects(grp)
        data.update_extents()
    dia.active_display().diagram.add_update_all()


dia.register_callback("Center Objects", "<Display>/Objects/Center",
                      dia_objects_center_cb)
"""

## wrong syntax (#A1) notes: 
#~ tline.properties["obj_pos"] = dia.Point(0,000000,1,000000) # cannot create 'dia.Point' instances
#~ tline.properties["obj_pos"] = (0,000000,1,000000) # TypeError: prop type mis-match.
#~ tline.properties["obj_pos"] = (0.000000,1.000000) # TypeError: 'dia.Object' object has only read-only attributes (assign to .obj_pos)
#~ tline.obj_pos = (0,000000,1,000000) #  'dia.Object' object has only read-only attributes (assign to .obj_pos)
#~ tline.obj_pos = (0.000000,1.000000) # ... read-only
#~ linepropsA.get('obj_pos').value = (0,000000,1,000000) # AttributeError: 'dia.Property' object has no attribute 'value' ???
# nope - "TypeError: 'dia.Property' object has only read-only attributes (assign to .value)"


## see wrong syntax (#A2) notes: 
#~ 'start_arrow':((0.500000,0.500000), 8),
#  dia.Arrow: length (dbl) type (int) width (dbl)
Esempio n. 6
0
import dia


def hello_callback(data, flags):
    dia.message(2, "Hello, World!\n")


dia.register_callback("Hello World", "<Display>/Tools/Hello", hello_callback)
Esempio n. 7
0
#! /usr/bin/python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------
# Author:   Fabien Marteau <*****@*****.**>
# Created:  20/11/2014
#-----------------------------------------------------------------------------
#    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., 675 Mass Ave, Cambridge, MA 02139, USA.
#-----------------------------------------------------------------------------

import dia

def hello_callback(data, flags):
    dia.message(2, "Hello1\n")


dia.register_callback("fpgarchitect", "<Display>/hello", hello_callback)
Esempio n. 8
0
            columns=','.join(columns),
            table_name=table_name,
            schema=schema,
            order_by=order_by)
    )
    # Transform resultset onto array of hashs, more clear for the rest of code
    return [dict(zip(columns, row)) for row in result]

def generate_diagram(connection, schema, tables_names, options):
    diagram = DiaSchema()
    for table_name in tables_names:
        columns_infos = get_columns_infos(connection, table_name, schema, options['sort_fields'])
        diagram.addTable(table_name, columns_infos, add_types=options['add_types'])
    diagram.finalize()

def import_callback(data, flags):
    try:
        Gui()
    except ImportError:
        dia.message(2, "Dialog creation failed. Missing pygtk ?")


if __name__ == "__main__":
    # Test gui outside of Dia
    pygtk.require('2.0')
    Gui()
    gtk.main()
else:
    import dia
    dia.register_callback("Sql Import", "<Display>/Tools/SqlImport", import_callback)