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