Commit e70927b7 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Clean code

parent f5a48259
...@@ -195,7 +195,6 @@ class Symbol(QObject, QGraphicsPathItem, object): ...@@ -195,7 +195,6 @@ class Symbol(QObject, QGraphicsPathItem, object):
followers.append(item_type) followers.append(item_type)
if not self.next_aligned_symbol(): if not self.next_aligned_symbol():
followers.extend(self._terminal_followers) followers.extend(self._terminal_followers)
#LOG.debug(str(followers))
return followers return followers
@property @property
...@@ -924,8 +923,11 @@ class HorizontalSymbol(Symbol, object): ...@@ -924,8 +923,11 @@ class HorizontalSymbol(Symbol, object):
self.text = EditableText(parent=self, text=text, self.text = EditableText(parent=self, text=text,
hyperlink=hyperlink) hyperlink=hyperlink)
if parent: if parent:
local_pos = parent.mapFromScene(x, y) if x and y:
self.insert_symbol(parent, local_pos.x(), local_pos.y()) local_pos = parent.mapFromScene(x, y)
self.insert_symbol(parent, local_pos.x(), local_pos.y())
else:
self.insert_symbol(parent, None, None)
else: else:
self.position = QPointF(x or 0, y or 0) self.position = QPointF(x or 0, y or 0)
...@@ -984,8 +986,6 @@ class HorizontalSymbol(Symbol, object): ...@@ -984,8 +986,6 @@ class HorizontalSymbol(Symbol, object):
self.connection = self.connect_to_parent() self.connection = self.connect_to_parent()
self.updateConnectionPoints() self.updateConnectionPoints()
self.cam(self.position, self.position) self.cam(self.position, self.position)
LOG.debug('{} positionned at {}'.format(unicode(self),
unicode(self.scenePos())))
def update_connections(self): def update_connections(self):
''' '''
...@@ -1207,8 +1207,6 @@ class VerticalSymbol(Symbol, object): ...@@ -1207,8 +1207,6 @@ class VerticalSymbol(Symbol, object):
if y is not None: if y is not None:
self.pos_y = y self.pos_y = y
self.cam(self.position, self.position) self.cam(self.position, self.position)
LOG.debug('{} positionned at {}'.format(unicode(self),
unicode(self.scenePos())))
# def update_position(self): # def update_position(self):
# ''' # '''
......
...@@ -453,7 +453,6 @@ def signature(name, context): ...@@ -453,7 +453,6 @@ def signature(name, context):
def check_call(name, params, context): def check_call(name, params, context):
''' Check the parameter types of a procedure/output/operator call, ''' Check the parameter types of a procedure/output/operator call,
returning the type of its result ''' returning the type of its result '''
# LOG.debug('[check_call] ' + name + ' - ' + str(params))
# Special case for write/writeln functions # Special case for write/writeln functions
if name.lower() in ('write', 'writeln'): if name.lower() in ('write', 'writeln'):
...@@ -617,9 +616,6 @@ def check_type_compatibility(primary, type_ref, context): ...@@ -617,9 +616,6 @@ def check_type_compatibility(primary, type_ref, context):
raise TypeError('Type reference is unknown') raise TypeError('Type reference is unknown')
basic_type = find_basic_type(type_ref) basic_type = find_basic_type(type_ref)
# LOG.debug("[check_type_compatibility] "
# "checking if {value} is of type {typeref}"
# .format(value=primary.inputString, typeref=type_name(type_ref)))
if (isinstance(primary, ogAST.PrimEnumeratedValue) if (isinstance(primary, ogAST.PrimEnumeratedValue)
and basic_type.kind.endswith('EnumeratedType')): and basic_type.kind.endswith('EnumeratedType')):
...@@ -795,7 +791,6 @@ def compare_types(type_a, type_b): ...@@ -795,7 +791,6 @@ def compare_types(type_a, type_b):
Compare two types, return if they are semantically equivalent, Compare two types, return if they are semantically equivalent,
otherwise raise TypeError otherwise raise TypeError
''' '''
# LOG.debug('[compare_types]' + str(type_a) + ' and ' + str(type_b) + ': ')
type_a = find_basic_type(type_a) type_a = find_basic_type(type_a)
type_b = find_basic_type(type_b) type_b = find_basic_type(type_b)
...@@ -848,7 +843,6 @@ def compare_types(type_a, type_b): ...@@ -848,7 +843,6 @@ def compare_types(type_a, type_b):
def find_variable_type(var, context): def find_variable_type(var, context):
''' Look for a variable name in the context and return its type ''' ''' Look for a variable name in the context and return its type '''
# LOG.debug('[find_variable] checking if ' + str(var) + ' is defined')
# all DCL-variables # all DCL-variables
all_visible_variables = dict(context.global_variables) all_visible_variables = dict(context.global_variables)
...@@ -877,7 +871,6 @@ def find_variable_type(var, context): ...@@ -877,7 +871,6 @@ def find_variable_type(var, context):
if var.lower() == varname.lower().replace('-', '_'): if var.lower() == varname.lower().replace('-', '_'):
return vartype.type return vartype.type
# LOG.debug('[find_variable] result: not found, raising exception')
raise AttributeError('Variable {var} not defined'.format(var=var)) raise AttributeError('Variable {var} not defined'.format(var=var))
...@@ -895,8 +888,6 @@ def fix_enumerated_and_choice(expr_enum, context): ...@@ -895,8 +888,6 @@ def fix_enumerated_and_choice(expr_enum, context):
expr_enum.right.exprType = expr_enum.left.exprType expr_enum.right.exprType = expr_enum.left.exprType
except (UnboundLocalError, AttributeError, TypeError): except (UnboundLocalError, AttributeError, TypeError):
pass pass
# else:
# LOG.debug('Fixed enumerated/choice: {}'.format(expr_enum.inputString))
def fix_expression_types(expr, context): def fix_expression_types(expr, context):
...@@ -3928,7 +3919,6 @@ def pr_file(root): ...@@ -3928,7 +3919,6 @@ def pr_file(root):
else: else:
LOG.error('Unsupported construct in PR:' + str(child.type)) LOG.error('Unsupported construct in PR:' + str(child.type))
for child in uses: for child in uses:
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 asn1_filename = None
...@@ -3980,7 +3970,6 @@ def pr_file(root): ...@@ -3980,7 +3970,6 @@ def pr_file(root):
process.dv = DV process.dv = DV
errors.extend(err) errors.extend(err)
warnings.extend(warn) warnings.extend(warn)
LOG.debug('all files: ' + str(ast.pr_files))
# Since SDL type declarations are injected in ASN.1 ast, # Since SDL type declarations are injected in ASN.1 ast,
# The ASN.1 ASTs needs to be copied at the end of PR parsing process # The ASN.1 ASTs needs to be copied at the end of PR parsing process
......
...@@ -427,7 +427,6 @@ class DecisionAnswer(HorizontalSymbol): ...@@ -427,7 +427,6 @@ class DecisionAnswer(HorizontalSymbol):
y=ast.pos_y or 0, y=ast.pos_y or 0,
hyperlink=ast.hyperlink) hyperlink=ast.hyperlink)
self.set_shape(ast.width, ast.height) self.set_shape(ast.width, ast.height)
#self.setPen(QColor(0, 0, 0, 0))
self.branch_entrypoint = self self.branch_entrypoint = self
self.parser = ogParser self.parser = ogParser
...@@ -435,7 +434,7 @@ class DecisionAnswer(HorizontalSymbol): ...@@ -435,7 +434,7 @@ class DecisionAnswer(HorizontalSymbol):
''' ANSWER-specific insersion behaviour: link to connection point ''' ''' ANSWER-specific insersion behaviour: link to connection point '''
if not parent: if not parent:
return return
# Make sure that parent is a state, not a sibling input # Make sure that parent is not a sibling answer
item_parent = (parent if not isinstance(parent, DecisionAnswer) item_parent = (parent if not isinstance(parent, DecisionAnswer)
else parent.parentItem()) else parent.parentItem())
super(DecisionAnswer, self).insert_symbol(item_parent, x, y) super(DecisionAnswer, self).insert_symbol(item_parent, x, y)
......
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
OpenGEODE - A tiny SDL Editor for TASTE OpenGEODE - A tiny SDL Editor for TASTE - Support for Undo/Redo
Undo/Redo commands for generic symbols when used in a diagram editor. Undo/Redo commands for generic symbols when used in a diagram editor.
...@@ -10,7 +9,7 @@ ...@@ -10,7 +9,7 @@
the redo() function is *called* when the command is created. the redo() function is *called* when the command is created.
No need to perform the action before. No need to perform the action before.
Copyright (c) 2012 European Space Agency Copyright (c) 2012-2015 European Space Agency
Designed and implemented by Maxime Perrotin Designed and implemented by Maxime Perrotin
...@@ -35,12 +34,10 @@ class UndoMacro(object): ...@@ -35,12 +34,10 @@ class UndoMacro(object):
def __enter__(self): def __enter__(self):
''' Create macro for a set of undo commands ''' ''' Create macro for a set of undo commands '''
LOG.debug('New macro: {}'.format(self.text))
self.stack.beginMacro(self.text) self.stack.beginMacro(self.text)
def __exit__(self, atype, value, traceback): def __exit__(self, atype, value, traceback):
''' Stop the recording of undo commands ''' ''' Stop the recording of undo commands '''
LOG.debug('End macro: {}'.format(self.text))
self.stack.endMacro() self.stack.endMacro()
...@@ -48,7 +45,6 @@ class ReplaceText(QUndoCommand): ...@@ -48,7 +45,6 @@ class ReplaceText(QUndoCommand):
''' Undo/Redo command for updating the text in a symbol ''' ''' Undo/Redo command for updating the text in a symbol '''
def __init__(self, text_id, old_text, new_text): def __init__(self, text_id, old_text, new_text):
super(ReplaceText, self).__init__() super(ReplaceText, self).__init__()
LOG.debug('New Undo command: Replace text')
self.setText('Replace text') self.setText('Replace text')
self.text = text_id self.text = text_id
self.old_text = old_text self.old_text = old_text
...@@ -65,7 +61,6 @@ class ResizeSymbol(QUndoCommand): ...@@ -65,7 +61,6 @@ class ResizeSymbol(QUndoCommand):
''' Undo/Redo command for resizing a symbol ''' ''' Undo/Redo command for resizing a symbol '''
def __init__(self, symbol_id, old_rect, new_rect): def __init__(self, symbol_id, old_rect, new_rect):
super(ResizeSymbol, self).__init__() super(ResizeSymbol, self).__init__()
LOG.debug('New Undo command: Resize symbol')
self.setText('Resize symbol') self.setText('Resize symbol')
self.symbol = symbol_id self.symbol = symbol_id
self.old_rect = old_rect self.old_rect = old_rect
...@@ -94,7 +89,6 @@ class InsertSymbol(QUndoCommand): ...@@ -94,7 +89,6 @@ class InsertSymbol(QUndoCommand):
''' Undo/Redo command for inserting a new item ''' ''' Undo/Redo command for inserting a new item '''
def __init__(self, item, parent, pos): def __init__(self, item, parent, pos):
super(InsertSymbol, self).__init__() super(InsertSymbol, self).__init__()
LOG.debug('New Undo command: Insert symbol')
self.item = item self.item = item
self.parent = parent self.parent = parent
self.pos_x = pos.x() if pos else None self.pos_x = pos.x() if pos else None
...@@ -131,7 +125,6 @@ class DeleteSymbol(QUndoCommand): ...@@ -131,7 +125,6 @@ class DeleteSymbol(QUndoCommand):
''' Undo/Redo command for a symbol deletion ''' ''' Undo/Redo command for a symbol deletion '''
def __init__(self, item): def __init__(self, item):
super(DeleteSymbol, self).__init__() super(DeleteSymbol, self).__init__()
LOG.debug('New Undo command: Delete symbol')
self.item = item self.item = item
self.scene = item.scene() self.scene = item.scene()
self.parent = item.parentItem() if item.hasParent else None self.parent = item.parentItem() if item.hasParent else None
...@@ -159,7 +152,6 @@ class MoveSymbol(QUndoCommand): ...@@ -159,7 +152,6 @@ class MoveSymbol(QUndoCommand):
''' Undo/Redo command for moving symbols ''' ''' Undo/Redo command for moving symbols '''
def __init__(self, symbol_id, old_pos, new_pos, animate=False): def __init__(self, symbol_id, old_pos, new_pos, animate=False):
super(MoveSymbol, self).__init__() super(MoveSymbol, self).__init__()
LOG.debug('New Undo command: Move symbol')
self.setText('Move symbol') self.setText('Move symbol')
self.symbol = symbol_id self.symbol = symbol_id
self.old_pos = old_pos self.old_pos = old_pos
...@@ -171,7 +163,6 @@ class MoveSymbol(QUndoCommand): ...@@ -171,7 +163,6 @@ class MoveSymbol(QUndoCommand):
self.animation.setEndValue(self.new_pos) self.animation.setEndValue(self.new_pos)
self.animation.setEasingCurve(QEasingCurve.OutCirc) self.animation.setEasingCurve(QEasingCurve.OutCirc)
def undo(self): def undo(self):
''' Undo a symbol move ''' ''' Undo a symbol move '''
self.symbol.position = self.old_pos self.symbol.position = self.old_pos
......
...@@ -23,9 +23,6 @@ dcl choice Mychoice; ...@@ -23,9 +23,6 @@ dcl choice Mychoice;
dcl opt SeqOpt := { A TRUE, b FALSE }; -- test optional fields dcl opt SeqOpt := { A TRUE, b FALSE }; -- test optional fields
/* CIF ENDTEXT */ /* CIF ENDTEXT */
/* CIF PROCEDURE (1273, 175), (106, 35) */
PROCEDURE emptyproc;
ENDPROCEDURE;
/* CIF PROCEDURE (1306, 371), (91, 35) */ /* CIF PROCEDURE (1306, 371), (91, 35) */
PROCEDURE numProc; PROCEDURE numProc;
/* CIF START (161, 82), (70, 35) */ /* CIF START (161, 82), (70, 35) */
...@@ -43,6 +40,9 @@ dcl opt SeqOpt := { A TRUE, b FALSE }; -- test optional fields ...@@ -43,6 +40,9 @@ dcl opt SeqOpt := { A TRUE, b FALSE }; -- test optional fields
/* CIF RETURN (178, 348), (35, 35) */ /* CIF RETURN (178, 348), (35, 35) */
RETURN ; RETURN ;
ENDPROCEDURE; ENDPROCEDURE;
/* CIF PROCEDURE (1273, 175), (106, 35) */
PROCEDURE emptyproc;
ENDPROCEDURE;
/* CIF START (596, 224), (80, 36) */ /* CIF START (596, 224), (80, 36) */
START; START;
/* CIF TASK (564, 275), (144, 35) */ /* CIF TASK (564, 275), (144, 35) */
...@@ -129,15 +129,15 @@ endfor; ...@@ -129,15 +129,15 @@ endfor;
DECISION myenum DECISION myenum
/* CIF COMMENT (718, 1533), (183, 35) */ /* CIF COMMENT (718, 1533), (183, 35) */
COMMENT 'Check case insensitivity'; COMMENT 'Check case insensitivity';
/* CIF ANSWER (437, 1595), (70, 23) */ /* CIF ANSWER (528, 1595), (70, 23) */
(a): (a):
/* CIF ANSWER (517, 1595), (70, 23) */ /* CIF ANSWER (608, 1595), (70, 23) */
(B): (B):
/* CIF ANSWER (597, 1595), (70, 23) */ /* CIF ANSWER (688, 1595), (70, 23) */
(c): (c):
/* CIF ANSWER (677, 1595), (70, 23) */ /* CIF ANSWER (768, 1595), (70, 23) */
(d): (d):
/* CIF ANSWER (757, 1595), (70, 23) */ /* CIF ANSWER (848, 1595), (70, 23) */
(Ee): (Ee):
ENDDECISION; ENDDECISION;
/* CIF DECISION (567, 1633), (138, 50) */ /* CIF DECISION (567, 1633), (138, 50) */
...@@ -155,7 +155,7 @@ endfor; ...@@ -155,7 +155,7 @@ endfor;
STATE Third; STATE Third;
/* CIF INPUT (1054, 482), (130, 35) */ /* CIF INPUT (1054, 482), (130, 35) */
INPUT pulse(myenum); INPUT pulse(myenum);
/* CIF NEXTSTATE (1063, 532), (113, 35) */ /* CIF NEXTSTATE (1062, 532), (113, 35) */
NEXTSTATE Wait_for_gui; NEXTSTATE Wait_for_gui;
ENDSTATE; ENDSTATE;
/* CIF STATE (1059, 322), (123, 35) */ /* CIF STATE (1059, 322), (123, 35) */
......
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