Commit 1f27ed79 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fixed rendering of process at block level

parent 4849819c
...@@ -236,11 +236,29 @@ class CommentConnection(Connection): ...@@ -236,11 +236,29 @@ class CommentConnection(Connection):
class Channel(Connection): class Channel(Connection):
''' Subclass of Connection used to draw channels between processes ''' ''' Subclass of Connection used to draw channels between processes '''
in_sig = out_sig = None
def __init__(self, process): def __init__(self, process):
''' Set generic parameters from Connection class ''' ''' Set generic parameters from Connection class '''
super(Channel, self).__init__(process, process) super(Channel, self).__init__(process, process)
self.text_label = None self.label_in = QGraphicsTextItem('[]', parent=self)
self.label_out = QGraphicsTextItem('[]', parent=self)
if not Channel.in_sig:
# keep at class level as long as only one process is supported
# when copy-pasting a process the challel in/out signal lists
# are not parsed. Workaround is to keep the list "global"
# to allow a copy of both process and channel
# Needed for the image exporter, that copies the scene to a
# temporary one
Channel.in_sig = '[{}]'.format(',\n'.join(sig['name']
for sig in process.input_signals))
Channel.out_sig = '[{}]'.format(',\n'.join(sig['name']
for sig in process.output_signals))
font = QFont('Ubuntu', pointSize=8)
for each in (self.label_in, self.label_out):
each.setFont(font)
each.show()
self.process = process self.process = process
self.reshape()
@property @property
def start_point(self): def start_point(self):
...@@ -258,9 +276,23 @@ class Channel(Connection): ...@@ -258,9 +276,23 @@ class Channel(Connection):
view.viewport().geometry()).boundingRect().topLeft() view.viewport().geometry()).boundingRect().topLeft()
scene_pos_x = self.mapFromScene(view_pos).x() scene_pos_x = self.mapFromScene(view_pos).x()
return QPointF(scene_pos_x, self.start_point.y()) return QPointF(scene_pos_x, self.start_point.y())
except IndexError: except (IndexError, AttributeError):
# In case there is no view (e.g. Export PNG from cmd line) # In case there is no view (e.g. Export PNG from cmd line)
return QPointF(self.start_point.x() - 50, self.start_point.y()) return QPointF(self.start_point.x() - 250, self.start_point.y())
def reshape(self):
''' Redefine shape function to add the text areas '''
super(Channel, self).reshape()
self.label_in.setPlainText(self.in_sig)
self.label_out.setPlainText(self.out_sig)
width_in = self.label_in.boundingRect().width()
self.label_in.setX(self.start_point.x() - width_in)
self.label_in.setY(self.start_point.y() + 5)
self.label_out.setX(self.end_point.x() + 10)
self.label_out.setY(self.end_point.y() + 5)
class Controlpoint(QGraphicsPathItem, object): class Controlpoint(QGraphicsPathItem, object):
......
...@@ -782,7 +782,8 @@ class Process(object): ...@@ -782,7 +782,8 @@ class Process(object):
self.global_variables = {} self.global_variables = {}
self.global_timers = [] self.global_timers = []
# Set default coordinates and width/height # Set default coordinates and width/height
self.pos_x = self.pos_y = 150 self.pos_x = 250
self.pos_y = 150
self.width = 150 self.width = 150
self.height = 75 self.height = 75
# Optional hyperlink # Optional hyperlink
......
...@@ -28,6 +28,8 @@ __author__ = 'Maxime Perrotin' ...@@ -28,6 +28,8 @@ __author__ = 'Maxime Perrotin'
import sys import sys
import os import os
import re
import fnmatch
import logging import logging
import traceback import traceback
from itertools import chain, permutations from itertools import chain, permutations
...@@ -3243,12 +3245,20 @@ def pr_file(root): ...@@ -3243,12 +3245,20 @@ def pr_file(root):
LOG.debug('USE clause') LOG.debug('USE clause')
# USE clauses can contain a CIF comment with the ASN.1 filename # USE clauses can contain a CIF comment with the ASN.1 filename
use_clause_subs = child.getChildren() use_clause_subs = child.getChildren()
asn1_filename = None
for clause in use_clause_subs: for clause in use_clause_subs:
if clause.type == lexer.ASN1: if clause.type == lexer.ASN1:
asn1_filename = clause.getChild(0).text[1:-1] asn1_filename = clause.getChild(0).text[1:-1]
ast.asn1_filenames.append(asn1_filename) ast.asn1_filenames.append(asn1_filename)
else: else:
ast.use_clauses.append(clause.text) ast.use_clauses.append(clause.text)
# if not asn1_filename:
# # Look for case insentitive pr file and add it to AST
# search = fnmatch.translate(clause.text + '.pr')
# searchobj = re.compile(search, re.IGNORECASE)
# for each in os.listdir('.'):
# if searchobj.match(each):
# print 'found', each
try: try:
DV = parse_asn1(tuple(ast.asn1_filenames), DV = parse_asn1(tuple(ast.asn1_filenames),
ast_version=ASN1.UniqueEnumeratedNames, ast_version=ASN1.UniqueEnumeratedNames,
...@@ -3261,6 +3271,7 @@ def pr_file(root): ...@@ -3261,6 +3271,7 @@ def pr_file(root):
# Can happen if DataView.py is not there # Can happen if DataView.py is not there
LOG.info('USE Clause did not contain ASN.1 filename') LOG.info('USE Clause did not contain ASN.1 filename')
LOG.debug(str(err)) LOG.debug(str(err))
for child in systems: for child in systems:
LOG.debug('found SYSTEM') LOG.debug('found SYSTEM')
system, err, warn = system_definition(child, parent=ast) system, err, warn = system_definition(child, parent=ast)
......
...@@ -30,6 +30,7 @@ from itertools import chain ...@@ -30,6 +30,7 @@ from itertools import chain
# Added to please py2exe - NOQA makes flake8 ignore the following lines: # Added to please py2exe - NOQA makes flake8 ignore the following lines:
# pylint: disable=W0611 # pylint: disable=W0611
import enum # NOQA import enum # NOQA
import fnmatch # NOQA
import operator # NOQA import operator # NOQA
import subprocess # NOQA import subprocess # NOQA
import distutils # NOQA import distutils # NOQA
...@@ -1649,7 +1650,11 @@ class OG_MainWindow(QtGui.QMainWindow, object): ...@@ -1649,7 +1650,11 @@ class OG_MainWindow(QtGui.QMainWindow, object):
types.append(file_handler.read()) types.append(file_handler.read())
if types: if types:
self.asn1_area.text.setPlainText('\n'.join(types)) self.asn1_area.text.setPlainText('\n'.join(types))
# ASN.1 text area is read-only:
self.asn1_area.text.setTextInteractionFlags(
QtCore.Qt.TextBrowserInteraction)
self.asn1_area.text.try_resize() self.asn1_area.text.try_resize()
except IOError as err: except IOError as err:
LOG.warning('ASN.1 file(s) could not be loaded : ' + str(err)) LOG.warning('ASN.1 file(s) could not be loaded : ' + str(err))
except AttributeError: except AttributeError:
......
...@@ -723,6 +723,9 @@ class Process(HorizontalSymbol): ...@@ -723,6 +723,9 @@ class Process(HorizontalSymbol):
if ast.comment: if ast.comment:
Comment(parent=self, ast=ast.comment) Comment(parent=self, ast=ast.comment)
self.nested_scene = subscene self.nested_scene = subscene
self.input_signals = ast.input_signals
self.output_signals = ast.output_signals
self.insert_symbol(None, self.x(), self.y())
def insert_symbol(self, parent, x, y): def insert_symbol(self, parent, x, y):
''' Redefinition - adds connection line to env ''' ''' Redefinition - adds connection line to env '''
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment