User Tools

Site Tools


rania_assab:rania_assab

Bordeaux roadmap 2014-2015 / Rania Assab's corner

Please, check your email: rania.assab@hotmail.fr Je suis en binôme avec Marjorie Mersch et Jérôme Bouzillard. Le détail de notre programme est sur le dépôt de Marjorie Mersch.

If this is incorrect, please email us so we can fix it.

  • This is where you'll keep private access to your course related stuff.
  • This is your own private area where homework can be uploaded/edited.

# Powered by Python 2.7

# To cancel the modifications performed by the script # on the current graph, click on the undo button.

# Some useful keyboards shortcuts : # * Ctrl + D : comment selected lines. # * Ctrl + Shift + D : uncomment selected lines. # * Ctrl + I : indent selected lines. # * Ctrl + Shift + I : unindent selected lines. # * Ctrl + Return : run script. # * Ctrl + F : find selected text. # * Ctrl + R : replace selected text. # * Ctrl + Space : show auto-completion dialog.

from tulip import *

# the updateVisualization(centerViews = True) function can be called # during script execution to update the opened views

# the pauseScript() function can be called to pause the script execution. # To resume the script execution, you will have to click on the “Run script ” button.

# the runGraphScript(scriptFile, graph) function can be called to launch another edited script on a tlp.Graph object. # The scriptFile parameter defines the script name to call (in the form [a-zA-Z0-9_]+.py)

# the main(graph) function must be defined # to run the script on the current graph

def main(graph):

viewBorderColor =  graph.getColorProperty("viewBorderColor")
viewBorderWidth =  graph.getDoubleProperty("viewBorderWidth")
viewColor =  graph.getColorProperty("viewColor")
viewFont =  graph.getStringProperty("viewFont")
viewFontSize =  graph.getIntegerProperty("viewFontSize")
viewLabel =  graph.getStringProperty("viewLabel")
viewLabelBorderColor =  graph.getColorProperty("viewLabelBorderColor")
viewLabelBorderWidth =  graph.getDoubleProperty("viewLabelBorderWidth")
viewLabelColor =  graph.getColorProperty("viewLabelColor")
viewLabelPosition =  graph.getIntegerProperty("viewLabelPosition")
viewLayout =  graph.getLayoutProperty("viewLayout")
viewMetaGraph =  graph.getGraphProperty("viewMetaGraph")
viewMetric =  graph.getDoubleProperty("viewMetric")
viewRotation =  graph.getDoubleProperty("viewRotation")
viewSelection =  graph.getBooleanProperty("viewSelection")
viewShape =  graph.getIntegerProperty("viewShape")
viewSize =  graph.getSizeProperty("viewSize")
viewSrcAnchorShape =  graph.getIntegerProperty("viewSrcAnchorShape")
viewSrcAnchorSize =  graph.getSizeProperty("viewSrcAnchorSize")
viewTexture =  graph.getStringProperty("viewTexture")
viewTgtAnchorShape =  graph.getIntegerProperty("viewTgtAnchorShape")
viewTgtAnchorSize =  graph.getSizeProperty("viewTgtAnchorSize")


viewShape.setAllNodeValue(tlp.NodeShape.Square) # Affiche des carres

	
def successeur(allNodes,x,y,minS, i): # Recursive : dans tous les noeuds du graphe on parcourt chaque noeud
	size = 0
	i += 40 # Incremente les couleurs du noeud
	son_size = viewSize[allNodes]/graph.outdeg(allNodes) # La taille du noeud fils = taille du noeud pere / nb descendants
	for node in graph.getOutNodes(allNodes): # Pour tous les successeurs 
		viewSize[node] = tlp.Size(son_size.getW(), minS) # Taille du noeud fils en fonction de la valeur trouvee par la def determineRootSize
		viewColor[node] = tlp.Color(i+30,0,0) # Couleur du noeud fils
		viewBorderWidth[node] = 2
		viewBorderColor[node] = tlp.Color.Black
		
		# Modification des coordonnees x et y des noeuds fils			
		# Les coordonnees des noeuds fils, etant au centre du noeud pere, il faut donc les repositionner a gauche et dessous
		viewLayout[node] = tlp.Coord(x - viewSize[allNodes].getW()/2 + viewSize[node].getW()/2 + size,y - minS)
		# Puis les aligner :
		size = size + viewSize[node].getW()
		x1 = viewLayout[node].getX() # Recuperation de la nouvelle coordonnee x du fils
		y1 = viewLayout[node].getY() # Recuperation de la nouvelle coordonnee y du fils			
		successeur(node,x1,y1, minS,i)	# Appel de la recursive		
	# Masque les aretes
	for edge in graph.getEdges(): 
		viewColor[edge] = tlp.Color(255,255,255)
		viewBorderColor[edge] = tlp.Color(255,255,255)

# Trouve la feuille dont les dimensions sont les plus petites pour normaliser l'arbre
def determineRootSize(n):
	maxi = 0
	nbFils = graph.outdeg(n) # Nombre de descendants	
	for node in graph.getOutNodes(n): # Pour tous les successeurs			
		maxi = max(maxi, nbFils * determineRootSize(node)) # Recursif : 
		return maxi
	return 1
	
	

# Pour le noeud racine		
i=0
n = graph.getOneNode()  # Choisit un noeud
maxi = determineRootSize(n)	
viewColor[n] = tlp.Color(10,0,0) # Couleur du noeud racine
viewSize[n] = tlp.Size(100, 100/maxi)  # Taille du noeud choisi
viewBorderWidth[n] = 2
viewBorderColor[n] = tlp.Color.Black
x = viewLayout[n].getX()
y = viewLayout[n].getY()	
successeur(n,x,y,100/maxi, i) # Traitement de tous les noeuds
/net/html/perso/melancon/Visual_Analytics_Course/data/pages/rania_assab/rania_assab.txt · Last modified: 2014/10/20 19:32 by assab