~ugocupcic/sr-ros-interface/manipulation

« back to all changes in this revision

Viewing changes to shadow_robot/sr_control_gui/src/sr_control_gui/main_window.py

  • Committer: Ugo Cupcic
  • Date: 2011-05-23 15:44:05 UTC
  • mfrom: (119.1.67 sr-ros-interface)
  • Revision ID: ugo@shadowrobot.com-20110523154405-kwvv543sy9wxehzi
Huge merge from trunk. Lots of changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright 2011 Shadow Robot Company Ltd.
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License as published by the Free
 
7
# Software Foundation, either version 2 of the License, or (at your option)
 
8
# any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful, but WITHOUT
 
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
13
# more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License along
 
16
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
#
2
18
 
3
19
import roslib; roslib.load_manifest('sr_control_gui')
4
20
 
5
21
import rospy
6
 
 
7
22
import subprocess
8
 
import logging
9
 
#enables the logging used by yapsy
10
 
logging.basicConfig(level=logging.ERROR)
11
 
 
12
 
from yapsy.PluginManager import PluginManager
13
23
from PyQt4 import QtCore, QtGui, Qt
14
24
import os, sys
15
25
 
29
39
    using the grasps subscribes to this signal and reload their grasps lists.
30
40
    """
31
41
    reloadGraspSig = QtCore.pyqtSignal(int)
32
 
    
 
42
 
33
43
    def __init__(self, parent=None):
34
44
        super(ReloadGraspSignalWidget, self).__init__(parent)
35
45
 
39
49
    using the grasps subscribes to this signal and reload their grasps lists.
40
50
    """
41
51
    reloadObjectSig = QtCore.pyqtSignal(int)
42
 
    
 
52
 
43
53
    def __init__(self, parent=None):
44
54
        super(ReloadObjectSignalWidget, self).__init__(parent)
45
55
 
50
60
    def __init__(self):
51
61
        QtGui.QMainWindow.__init__(self)
52
62
        rospy.init_node('sr_control_gui')
53
 
        
 
63
 
54
64
        # root path
55
65
        process = subprocess.Popen("rospack find sr_control_gui".split(), stdout=subprocess.PIPE)
56
66
        self.rootPath = process.communicate()[0]
58
68
        self.rootPath = self.rootPath[0]
59
69
        ####
60
70
        # BASIC PARAMETERS
61
 
        ##        
 
71
        ##
62
72
        self.setWindowTitle("Shadow Robot Controller")
63
73
        self.resize(1000, 600)
64
74
        self.setWindowIcon(QtGui.QIcon(self.rootPath + '/images/icons/app_icon.png'))
65
 
                
 
75
 
66
76
        ####
67
77
        # TOOLBAR
68
78
        ##
71
81
        self.connect(self.exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))
72
82
        self.toolbar = self.addToolBar('Exit')
73
83
        self.toolbar.addAction(self.exit)
74
 
        
 
84
 
75
85
        #Shortcuts
76
86
        self.exit.setShortcut('Ctrl+Q')
77
87
 
78
88
        ####
79
89
        # MENUBAR
80
 
        ##        
 
90
        ##
81
91
        self.menubar = self.menuBar()
82
92
        file = self.menubar.addMenu('&File')
83
93
        file.addAction(self.exit)
84
 
        
 
94
 
85
95
        tools = self.menubar.addMenu('&Tools')
86
96
        rxgraph = QtGui.QAction('RxGraph', self)
87
97
        self.connect(rxgraph, QtCore.SIGNAL('triggered()'), self.launch_rxgraph)
88
98
        robot_monitor = QtGui.QAction('Robot Monitor', self)
89
99
        self.connect(robot_monitor, QtCore.SIGNAL('triggered()'), self.launch_robot_monitor)
90
 
        
 
100
 
91
101
        tools.addAction(rxgraph)
92
102
        tools.addAction(robot_monitor)
93
103
 
94
104
        ###
95
105
        # SIGNALS
96
106
        ##
97
 
        self.reload_grasp_signal_widget = ReloadGraspSignalWidget()        
98
 
        self.reload_object_signal_widget = ReloadObjectSignalWidget()           
 
107
        self.reload_grasp_signal_widget = ReloadGraspSignalWidget()
 
108
        self.reload_object_signal_widget = ReloadObjectSignalWidget()
99
109
 
100
110
        ####
101
111
        # DOCKS
103
113
        self.show_robot_and_libraries = QtGui.QAction('Show Robot / Ros nodes', self)
104
114
        self.show_robot_and_libraries.setIcon(QtGui.QIcon(self.rootPath + '/images/icons/show.png'))
105
115
        self.show_robot_and_libraries.setStatusTip('Robot and libraries')
106
 
        
 
116
 
107
117
        self.robot_and_libraries_backend = RobotAndLibrariesBackend()
108
118
        self.robot_and_libraries_dock = RobotAndLibrariesDockWidget(self, self.robot_and_libraries_backend)
109
 
        
 
119
 
110
120
        self.connect(self.show_robot_and_libraries, QtCore.SIGNAL('triggered()'), self.robot_and_libraries_dock.show_hide)
111
 
        
 
121
 
112
122
        spacer = QtGui.QWidget()
113
123
        spacer.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding)
114
 
                
 
124
 
115
125
        self.toolbar_docks = self.addToolBar('Docks')
116
126
        self.toolbar_docks.addWidget(spacer)
117
127
        self.toolbar_docks.addAction(self.show_robot_and_libraries)
118
 
        
 
128
 
119
129
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.robot_and_libraries_dock)
120
130
 
121
131
        ####
122
132
        # LIBRARIES
123
133
        ##
124
134
        self.libraries = self.robot_and_libraries_backend.libraries
125
 
                
 
135
 
126
136
        ####
127
137
        # MAIN WIDGET
128
138
        ##
135
145
        self.statusBar().showMessage('Ready', 2000)
136
146
        self.connect(my_mdi_area, QtCore.SIGNAL("messageToStatusbar(QString)"),
137
147
                     self.statusBar(), QtCore.SLOT("showMessage(QString)"))
138
 
        
 
148
 
139
149
    def launch_rxgraph(self):
140
150
        subprocess.Popen("rxgraph".split())
141
151