示例#1
0
def setmodel(width, height, gravity=0, stiffness=20):
    userData = current_app.config[session.sid]
    userData['model'] = sbnw.loadsbml(userData['sbml'])
    if not userData['model'].network.haslayout():
        userData['model'].network.randomize(5, 10, width - 5, height - 10)
        userData['model'].network.autolayout(k=stiffness, grav=gravity)
    userData['model'].network.fitwindow(5, 10, width - 5, height - 10)
示例#2
0
 def openfile(self, filepath):
     self.openfilepath = filepath
     try:
         self.model = sbnw.loadsbml(filepath)
     except:
         msg = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical, 'Open File Dialog', 
         'Failed to open file ' + filepath + ' (check spelling)', QtWidgets.QMessageBox.Ok, self, 
         QtCore.Qt.Dialog or QtCore.Qt.MSWindowsFixedSizeDialogHint or QtCore.Qt.Sheet)
         #msg.exec()
         return
     self.layout = self.model.layout
     self.network = self.layout.network
     self.canvas = self.layout.canvas
     for node in self.network.nodes:
         node.custom = NodeData()
     if not self.network.haslayout():
         self.autolayout()
     self.fitLayoutToWindow()
     self.mainframe.network = self.network
     self.mainframe.resetTransform()
示例#3
0
 def openfile(self, filepath):
     self.openfilepath = filepath
     try:
         self.model = sbnw.loadsbml(filepath)
     except:
         msg = QtWidgets.QMessageBox(
             QtWidgets.QMessageBox.Critical, 'Open File Dialog',
             'Failed to open file ' + filepath + ' (check spelling)',
             QtWidgets.QMessageBox.Ok, self, QtCore.Qt.Dialog
             or QtCore.Qt.MSWindowsFixedSizeDialogHint or QtCore.Qt.Sheet)
         #msg.exec()
         return
     self.layout = self.model.layout
     self.network = self.layout.network
     self.canvas = self.layout.canvas
     for node in self.network.nodes:
         node.custom = NodeData()
     if not self.network.haslayout():
         self.autolayout()
     self.fitLayoutToWindow()
     self.mainframe.network = self.network
     self.mainframe.resetTransform()
示例#4
0
#!/usr/bin/python

# pyqt_layout.py
print('hi')
import sbnw
# load the model
model = sbnw.loadsbml(
    '/home/sagrada/myhome/code/sbnw-trunk/testcases/twocompsys-ex.xml')
print('loading model')
#model = sbnw.loadsbml(r'C:\Users\user\Documents\layout\twocompsys-ex.xml')
print('getting layout')
layout = model.layout
print('got layout')
# access api
network = layout.network
canvas = layout.canvas
#print(dir(network))
print('pre-randomize')
network.randomize(canvas)
print('randomized')
network.autolayout()

wndwidth, wndheight = 640, 380
pad = 30
if pad > wndwidth or pad > wndheight:
    raise RuntimeError('Padding exceeds dimension')

layout.fitwindow(0, 0, wndwidth - pad, wndheight - pad)

import sys
import random
示例#5
0
import sbnw
# load the model
model = sbnw.loadsbml('../testcases/BorisEJB.xml')

# retrieve layout information
layout = model.layout
# access the api
network = layout.network
canvas = layout.canvas

# seed node coordinates randomly
network.randomize(canvas)
# apply the FR-algorithm
network.autolayout()

# remove a node
network.removenode(network.nodes[0])

# fit to a window
layout.fitwindow(0, 0, 300, 300)
示例#6
0
#!/usr/bin/python

# pyqt_layout.py
print('hi')
import sbnw
# load the model
model = sbnw.loadsbml('/home/sagrada/myhome/code/sbnw-trunk/testcases/twocompsys-ex.xml')
print('loading model')
#model = sbnw.loadsbml(r'C:\Users\user\Documents\layout\twocompsys-ex.xml')
print('getting layout')
layout = model.layout
print('got layout')
# access api
network = layout.network
canvas = layout.canvas
#print(dir(network))
print('pre-randomize')
network.randomize(canvas)
print('randomized')
network.autolayout()

wndwidth, wndheight = 640,380
pad = 30
if pad > wndwidth or pad > wndheight:
    raise RuntimeError('Padding exceeds dimension')

layout.fitwindow(0,0,wndwidth - pad,wndheight - pad)

import sys
import random
from PyQt4 import QtCore, QtGui
示例#7
0
import sbnw

# load the model
model = sbnw.loadsbml("../testcases/BorisEJB.xml")

# retrieve layout information
layout = model.layout
# access the api
network = layout.network
canvas = layout.canvas

# seed node coordinates randomly
network.randomize(canvas)
# apply the FR-algorithm
network.autolayout()

# remove a node
network.removenode(network.nodes[0])

# fit to a window
layout.fitwindow(0, 0, 300, 300)