graphics/ToolTipProducer.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Mon, 26 Dec 2016 14:01:54 +0300
changeset 1615 af9b0ccb418e
parent 1571 486f94a8032c
child 1730 64d8f52bc8c8
permissions -rw-r--r--
replace '-' with '.' in resource tab and transition/action SFC code


This makes tab names consistent with the way the same information is shown in variable panel.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     3
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
     9
# See COPYING file for copyrights details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    10
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    11
# This program is free software; you can redistribute it and/or
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    12
# modify it under the terms of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    13
# as published by the Free Software Foundation; either version 2
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    14
# of the License, or (at your option) any later version.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    15
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    16
# This program is distributed in the hope that it will be useful,
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    19
# GNU General Public License for more details.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    20
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    21
# You should have received a copy of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    22
# along with this program; if not, write to the Free Software
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1177
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    25
import wx
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    26
1169
53e4a2b775a7 Move CustomToolTip from GraphicCommons to controls
Laurent Bessard
parents: 1166
diff changeset
    27
from controls.CustomToolTip import CustomToolTip, TOOLTIP_WAIT_PERIOD
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    28
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    29
#-------------------------------------------------------------------------------
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    30
#                           Tool Tip Producer class
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    31
#-------------------------------------------------------------------------------
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    32
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    33
"""
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    34
Class that implements an element that generate Tool Tip
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    35
"""
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    36
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    37
class ToolTipProducer:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    38
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    39
    def __init__(self, parent):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    40
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    41
        Constructor
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    42
        @param parent: Parent Viewer
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    43
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    44
        self.Parent = parent
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    45
        
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    46
        self.ToolTip = None
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    47
        self.ToolTipPos = None
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    48
        
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    49
        # Timer for firing Tool tip display
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    50
        self.ToolTipTimer = wx.Timer(self.Parent, -1)
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    51
        self.Parent.Bind(wx.EVT_TIMER, 
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    52
            self.OnToolTipTimer, 
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    53
            self.ToolTipTimer)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    54
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    55
    def __del__(self):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    56
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    57
        Destructor
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    58
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    59
        self.DestroyToolTip()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    60
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    61
    def OnToolTipTimer(self, event):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    62
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    63
        Callback for Tool Tip firing timer Event
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    64
        @param event: Tool tip text
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    65
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    66
        # Get Tool Tip text
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    67
        value = self.GetToolTipValue()
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    68
        
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    69
        if value is not None and self.ToolTipPos is not None:
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    70
            # Create Tool Tip
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    71
            self.ToolTip = CustomToolTip(self.Parent, value)
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    72
            self.ToolTip.SetToolTipPosition(self.ToolTipPos)
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    73
            self.ToolTip.Show()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    74
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    75
    def GetToolTipValue(self):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    76
        """
1177
4cbbc58b91b4 Fixed typo
Laurent Bessard
parents: 1170
diff changeset
    77
        Return tool tip text
4cbbc58b91b4 Fixed typo
Laurent Bessard
parents: 1170
diff changeset
    78
        Have to be overridden by inherited classes 
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    79
        @return: Tool tip text (None if not overridden) 
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    80
        """
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    81
        return None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    82
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    83
    def DisplayToolTip(self, pos):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    84
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    85
        Display Tool tip
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    86
        @param pos: Tool tip position
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    87
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    88
        # Destroy current displayed Tool tip
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    89
        self.DestroyToolTip()
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    90
        
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    91
        # Save Tool Tip position
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    92
        self.ToolTipPos = pos
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    93
        # Start Tool tip firing timer
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    94
        self.ToolTipTimer.Start(
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    95
            int(TOOLTIP_WAIT_PERIOD * 1000), 
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    96
            oneShot=True)
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 880
diff changeset
    97
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    98
    def SetToolTipText(self, text):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
    99
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   100
        Set current Tool tip text
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   101
        @param text: Tool tip Text
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   102
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   103
        if self.ToolTip is not None:
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   104
            self.ToolTip.SetTip(text)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   105
    
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   106
    def DestroyToolTip(self):
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   107
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   108
        Destroy current displayed Tool Tip
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   109
        """
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   110
        # Stop Tool tip firing timer
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   111
        self.ToolTipTimer.Stop()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   112
        self.ToolTipPos = None
1170
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   113
        
074e46cdedbc Added support for displaying ToolTip, starting drag'n drop and Double click on Block connectors when debugging
Laurent Bessard
parents: 1169
diff changeset
   114
        # Destroy Tool Tip
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   115
        if self.ToolTip is not None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   116
            self.ToolTip.Destroy()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   117
            self.ToolTip = None