Exemplo n.º 1
0
    def start(self, profile=None, skin=None):

        application = QtWidgets.QApplication(self.__sysarg)
        resolution = application.desktop().screenGeometry()
        resolution = min(resolution.width(), resolution.height())

        skin = skin or "autoware"
        with open(myutils.package("resources/skins/{}.css").format(skin)) as fp:
            stylesheet = fp.read()
        stylesheet += "* { font-size: " + str(resolution/100) + "px; }"
        application.setStyleSheet(stylesheet)

        self.__treeview   = AwTreeViewPanel(self) # ToDo: consider moving to guimgr
        self.__control    = AwControlPanel(self)  # ToDo: consider moving to guimgr
        self.__summary    = AwSummaryPanel(self)  # ToDo: consider moving to guimgr
        self.__process    = AwProcessPanel(self)  # ToDo: consider moving to guimgr
        self.__network    = AwTcpServerPanel()
        self.__quickstart = AwQuickStartPanel(self.__guimgr)
        self.__sim_rosbag = AwRosbagSimulatorWidget(self.__guimgr)
        self.__sim_lgsvl  = AwLgsvlSimulatorWidget (self.__guimgr)
        self.__sim_gazebo = AwGazeboSimulatorWidget(self.__guimgr)

        tabwidget = QtWidgets.QTabWidget()
        tabwidget.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
        tabwidget.addTab(self.__summary, "Summary")
        tabwidget.addTab(self.__process, "Process")

        #vsplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        vsplitter = QtWidgets.QWidget()
        vsplitter.setLayout(QtWidgets.QVBoxLayout())
        vsplitter.layout().setContentsMargins(0, 0, 0, 0)
        vsplitter.layout().setSpacing(0)
        vsplitter.layout().addWidget(self.__treeview)
        vsplitter.layout().addWidget(self.__control)

        self.__develop = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        self.__develop.addWidget(vsplitter)
        self.__develop.addWidget(tabwidget)

        #mainwidget = QtWidgets.QTabWidget()
        #mainwidget.addTab(hsplitter,         "Profile Edit")
        #mainwidget.addTab(self.__quickstart, "Quick Start")
        #mainwidget.addTab(self.__network,    "Server Debug")

        mainwidget = QtWidgets.QStackedWidget()
        mainwidget.addWidget(self.__quickstart)
        mainwidget.addWidget(self.__develop)
        mainwidget.addWidget(self.__network)

        simulations = QtWidgets.QTabWidget()
        simulations.addTab(self.__sim_rosbag, "Rosbag")
        simulations.addTab(self.__sim_lgsvl,  "LGSVL")
        simulations.addTab(self.__sim_gazebo, "Gazebo")

        mainsplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        mainsplitter.addWidget(mainwidget)
        mainsplitter.addWidget(simulations)

        #dock = QtWidgets.QDockWidget()
        #dock.setWidget( )
        #window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

        window = AwMainWindow(self)
        window.setCentralWidget(mainsplitter)
        window.show()

        simulations.hide()
        window.addViewMenu("Simulation", simulations.setVisible)

        def switch_develop_mode(checked):
            if checked:
                mainwidget.setCurrentWidget(self.__develop)
            else:
                mainwidget.setCurrentWidget(self.__quickstart)
        window.addViewMenu("Develop Mode", switch_develop_mode)

        # Debug
        #mainwidget.setCurrentWidget(self.__develop)
        simulations.hide()
        self.__sim_rosbag.rosbag_file.path.setText(myutils.userhome(".autoware/log/20150324.bag"))

        # connect objects
        self.__server.register_runner(self.__process)
        self.__process.register_server(self.__server)

        self.__server.register_client(self.__network)
        self.__network.register_server(self.__server)

        self.__panels.append(self.__treeview)
        self.__panels.append(self.__summary)
        self.__panels.append(self.__process)
        self.__panels.append(self.__quickstart)

        self.__treeview.register_select_listener(self.__summary)
        self.__treeview.register_select_listener(self.__process)
        self.__treeview.register_select_listener(self.__control)

        if profile:
            self.__server.load_profile(profile)
        else:
            self.__server.make_profile("root/default")

        return application.exec_()
Exemplo n.º 2
0
    def __init__(self, context):
        super(BehaviorTreePlugin, self).__init__(context)
        self.setObjectName('BehaviorTreePlugin')

        self.tree = None

        self.initialized_buttons = False
        self.prev_graphviz = ''
        
        self.behavior_tree_graphviz_sub = rospy.Subscriber('behavior_tree_graphviz', String, self.behavior_tree_graphviz_callback)
        self.timer = rospy.Timer(rospy.Duration(0.1), self.timer_callback)
        self.functions_mutex = Lock()
        self.functions = {}
        self.last_graphviz_string = ''
        
        self.widget = QWidget()
        self.vbox = qt.QVBoxLayout()
        self.widget.setLayout(self.vbox)
        context.add_widget(self.widget)
        #self.widget.setStyleSheet('QWidget{margin-left:-1px;}')

        self.top_widget = qt.QWidget()
        self.top_layout = qt.QVBoxLayout()
        self.top_widget.setLayout(self.top_layout)
        
        self.graph_widget = qt.QWidget()
        self.graph_layout = qt.QVBoxLayout()
        self.graph_widget.setLayout(self.graph_layout)
        self.image_label = qt.QLabel('asdfadsf')
        #self.graph_layout.addWidget(self.image_label)
        self.xdot_widget = DotWidget()
        self.graph_layout.addWidget(self.xdot_widget)
        self.top_layout.addWidget(self.graph_widget)
        self.graph_widget.setStyleSheet("background-color: rgb(255, 255, 255);")
        
        self.config_widget = qt.QWidget()
        self.config_widget.setStyleSheet('QWidget{margin-left:-1px;}')
        self.config_layout = qt.QHBoxLayout()
        self.config_widget.setLayout(self.config_layout)
        self.config_widget.setFixedHeight(50)
        
        self.config_button = qt.QPushButton('Open Config...')
        self.config_button.clicked.connect(self.select_config_file)
        self.config_layout.addWidget(self.config_button)

        self.tree_label = qt.QLabel('tree filename: ')
        self.config_layout.addWidget(self.tree_label)

        self.debug_checkbox = qt.QCheckBox('Debug Mode')
        self.config_layout.addWidget(self.debug_checkbox)
        self.debug_checkbox.stateChanged.connect(self.debug_mode_changed)

        #self.config_widget.setStyleSheet("background-color: rgb(255, 0, 0);")
        self.top_layout.addWidget(self.config_widget)

        #self.vbox.addWidget(self.top_widget)

        self.button_container_widget = qt.QWidget()
        self.button_container_layout = qt.QVBoxLayout()
        self.button_container_widget.setLayout(self.button_container_layout)
        #self.vbox.addWidget(self.button_container_widget)
        
        self.button_widget = qt.QWidget()
        self.button_layout = qt.QHBoxLayout()
        self.button_widget.setLayout(self.button_layout)
        #self.button_widget.setStyleSheet("background-color: rgb(0, 0, 255);")

        
        self.condition_widget = qt.QWidget()
        self.condition_layout = qt.QVBoxLayout()
        self.condition_widget.setLayout(self.condition_layout)
        self.button_layout.addWidget(self.condition_widget)
        
        self.condition_label = qt.QLabel()
        self.condition_label.setText('Conditions')
        self.condition_label.setAlignment(Qt.AlignCenter)
        self.condition_label.setFont(gui.QFont("SansSerif", 18, gui.QFont.Bold))
        self.condition_layout.addWidget(self.condition_label)
        
        self.action_widget = qt.QWidget()
        self.action_layout = qt.QVBoxLayout()
        self.action_widget.setLayout(self.action_layout)
        self.button_layout.addWidget(self.action_widget)
        
        self.action_label = qt.QLabel()
        self.action_label.setText('Actions')
        self.action_label.setAlignment(Qt.AlignCenter)
        self.action_label.setFont(gui.QFont("SansSerif", 18, gui.QFont.Bold))
        self.action_layout.addWidget(self.action_label)
        
        self.button_scroll_area = qt.QScrollArea()
        self.button_scroll_area.setWidget(self.button_widget)
        #self.button_scroll_area.setFixedHeight(200)
        #self.button_container_widget.setFixedHeight(200)
        self.button_container_layout.addWidget(self.button_scroll_area)
        self.button_widget.setMinimumWidth(self.button_scroll_area.sizeHint().width())
        self.button_scroll_area.setWidgetResizable(True)
        
        self.horizontal_splitter = qt.QSplitter(core.Qt.Vertical)
        self.horizontal_splitter.addWidget(self.top_widget)
        self.horizontal_splitter.addWidget(self.button_container_widget)
        self.vbox.addWidget(self.horizontal_splitter)

        self.button_container_widget.hide()