示例#1
0
 def _setup(self, widget_type):
     self.port = PORTS.pop()
     self.application = QtWidgets.QApplication(sys.argv)
     if widget_type == "hsec":
         self.view = HSecViewMockup()
     else:
         self.view = VSecViewMockup()
     self.tempdir = tempfile.mkdtemp()
     if not os.path.exists(self.tempdir):
         os.mkdir(self.tempdir)
     QtTest.QTest.qWait(3000)
     self.thread = multiprocessing.Process(
         target=application.run,
         args=("127.0.0.1", self.port))
     self.thread.start()
     if widget_type == "hsec":
         self.window = wc.HSecWMSControlWidget(view=self.view, wms_cache=self.tempdir)
     else:
         initial_waypoints = [ft.Waypoint(40., 25., 0), ft.Waypoint(60., -10., 0), ft.Waypoint(40., 10, 0)]
         waypoints_model = ft.WaypointsTableModel("")
         waypoints_model.insertRows(0, rows=len(initial_waypoints), waypoints=initial_waypoints)
         self.window = wc.VSecWMSControlWidget(
             view=self.view, wms_cache=self.tempdir, waypoints_model=waypoints_model)
     self.window.show()
     QtWidgets.QApplication.processEvents()
     QtTest.QTest.qWait(2000)
     QtTest.QTest.qWaitForWindowExposed(self.window)
     QtTest.QTest.mouseClick(self.window.cbCacheEnabled, QtCore.Qt.LeftButton)
     QtWidgets.QApplication.processEvents()
示例#2
0
    def _setup(self, widget_type):
        wc.WMS_SERVICE_CACHE = {}
        self.port = PORTS.pop()
        self.application = QtWidgets.QApplication(sys.argv)
        if widget_type == "hsec":
            self.view = HSecViewMockup()
        else:
            self.view = VSecViewMockup()
        self.tempdir = tempfile.mkdtemp()
        if not os.path.exists(self.tempdir):
            os.mkdir(self.tempdir)
        QtTest.QTest.qWait(3000)
        self.thread = multiprocessing.Process(target=application.run,
                                              args=("127.0.0.1", self.port))
        self.thread.start()
        if widget_type == "hsec":
            self.window = wc.HSecWMSControlWidget(view=self.view,
                                                  wms_cache=self.tempdir)
        else:
            initial_waypoints = [
                ft.Waypoint(40., 25., 0),
                ft.Waypoint(60., -10., 0),
                ft.Waypoint(40., 10, 0)
            ]
            waypoints_model = ft.WaypointsTableModel("")
            waypoints_model.insertRows(0,
                                       rows=len(initial_waypoints),
                                       waypoints=initial_waypoints)
            self.window = wc.VSecWMSControlWidget(
                view=self.view,
                wms_cache=self.tempdir,
                waypoints_model=waypoints_model)
        self.window.show()

        # Remove all previous cached URLs
        for url in self.window.multilayers.layers.copy():
            server = self.window.multilayers.listLayers.findItems(
                url, QtCore.Qt.MatchFixedString)[0]
            self.window.multilayers.delete_server(server)

        QtWidgets.QApplication.processEvents()
        QtTest.QTest.qWait(2000)
        QtTest.QTest.qWaitForWindowExposed(self.window)
        QtTest.QTest.mouseClick(self.window.cbCacheEnabled,
                                QtCore.Qt.LeftButton)
        QtWidgets.QApplication.processEvents()
示例#3
0
 def openTool(self, index):
     """Slot that handles requests to open tool windows.
     """
     index = self.controlToBeCreated(index)
     if index >= 0:
         if index == WMS:
             # Open a WMS control widget.
             title = "Web Service Plot Control"
             widget = wms.VSecWMSControlWidget(
                 default_WMS=config_loader(dataset="default_VSEC_WMS"),
                 waypoints_model=self.waypoints_model,
                 view=self.mpl.canvas,
                 wms_cache=config_loader(dataset="wms_cache"))
             self.mpl.canvas.waypoints_interactor.signal_get_vsec.connect(widget.call_get_vsec)
         else:
             raise IndexError("invalid control index")
         # Create the actual dock widget containing <widget>.
         self.createDockWidget(index, title, widget)