Beispiel #1
0
class Preview(QWidget):
    OFFSET_X = 0
    OFFSET_Y = 10
    WIDTH = 211
    HEIGHT = 477

    def __init__(self):
        super(Preview, self).__init__()
        layout = QGridLayout(self)
        layout.setAlignment(Qt.AlignCenter)

        self.loading = Loading(200)
        self.loading.hide()
        layout.addWidget(self.loading, 0, 0)

        self.image = None

    def setImage(self, image):
        if image is None:
            self.loading.show()
            self.image = None
        else:
            self.loading.hide()
            self.image = image.toImage()
        self.update()

    def paintEvent(self, event):
        if self.image is not None:
            painter = QPainter()
            painter.begin(self)

            image = self.image.scaledToWidth(self.width(),
                                             Qt.SmoothTransformation)

            frame = QImage(QDir.currentPath() + '/gui/images/background.png')
            frame = frame.copy(Preview.OFFSET_X, Preview.OFFSET_Y,
                               Preview.WIDTH, Preview.HEIGHT)
            frame = frame.scaled(image.width(), image.height(),
                                 Qt.IgnoreAspectRatio, Qt.SmoothTransformation)

            x1, y1 = 0, (self.height() - image.height()) / 2
            x2, y2 = x1 + self.width() - 1, y1 + image.height() - 1
            w, h, delta = image.width(), image.height(), 5

            painter.drawImage(x1, y1, frame)
            painter.setPen(QColor(QColor(255, 255, 255, 200)))
            painter.drawLine(x1, y1, x1, y2)
            painter.drawLine(x1, y1, x2, y1)
            painter.setPen(QColor(QColor(0, 0, 0, 200)))
            painter.drawLine(x2, y1, x2, y2)
            painter.drawLine(x1, y2, x2, y2)
            painter.drawImage(x1 + delta, y1 + delta,
                              image.scaled(w - delta * 2, h - delta * 2))

            painter.end()
Beispiel #2
0
class Preview(QWidget):
        OFFSET_X = 0
        OFFSET_Y = 10
        WIDTH = 211
        HEIGHT = 477

        def __init__(self):
                super(Preview, self).__init__()
                layout = QGridLayout(self)
                layout.setAlignment(Qt.AlignCenter)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 0, 0)

                self.image = None

        def setImage(self, image):
                if image is None:
                        self.loading.show()
                        self.image = None
                else:
                        self.loading.hide()
                        self.image = image.toImage()
                self.update()

        def paintEvent(self, event):
                if self.image is not None:
                        painter = QPainter()
                        painter.begin(self)

                        image = self.image.scaledToWidth(self.width(), Qt.SmoothTransformation)

                        frame = QImage(QDir.currentPath() + '/gui/images/background.png')
                        frame = frame.copy(Preview.OFFSET_X, Preview.OFFSET_Y, Preview.WIDTH, Preview.HEIGHT)
                        frame = frame.scaled(image.width(), image.height(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation)

                        x1, y1 = 0, (self.height() - image.height()) / 2
                        x2, y2 = x1 + self.width() - 1, y1 + image.height() - 1
                        w, h, delta = image.width(), image.height(), 5

                        painter.drawImage(x1, y1, frame)
                        painter.setPen(QColor(QColor(255, 255, 255, 200)))
                        painter.drawLine(x1, y1, x1, y2)
                        painter.drawLine(x1, y1, x2, y1)
                        painter.setPen(QColor(QColor(0, 0, 0, 200)))
                        painter.drawLine(x2, y1, x2, y2)
                        painter.drawLine(x1, y2, x2, y2)
                        painter.drawImage(x1 + delta, y1 + delta, image.scaled(w - delta * 2, h - delta * 2))

                        painter.end()
Beispiel #3
0
class GameViewFrame(QWidget):
    def __init__(self, parent):
        super(GameViewFrame, self).__init__(parent)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(20, 15, 20, 20)

        self.title = Title('', 23)
        titleLayout = QHBoxLayout()
        titleLayout.setAlignment(Qt.AlignTop)
        titleLayout.addWidget(QLabel(' ' * 5))
        titleLayout.addWidget(self.title, 1)
        layout.addLayout(titleLayout, 0)

        self.loading = Loading(200)
        self.loading.hide()
        layout.addWidget(self.loading, 1, Qt.AlignCenter)

        self.countDown = CountDown(200, self)
        self.countDown.hide()

        self.gameView = None

    def setTitle(self, title):
        self.title.setText(title)

    def showLoading(self):
        if self.gameView is not None:
            self.gameView.hide()
        self.loading.show()

    def showCountDown(self, quick=False):
        center = self.gameView.pos() + QPoint(self.gameView.width() / 2,
                                              self.gameView.height() / 2)
        self.countDown.move(center - QPoint(self.countDown.width() / 2,
                                            self.countDown.height() / 2))
        self.countDown.show()
        self.countDown.raise_()
        self.countDown.start(5 if not quick else 0)

    def showGameView(self, gameMap):
        self.loading.hide()
        self.gameView = GameView(gameMap)
        self.layout().addWidget(self.gameView, 1, Qt.AlignCenter)
class GameViewFrame(QWidget):
        def __init__(self, parent):
                super(GameViewFrame, self).__init__(parent)
                layout = QVBoxLayout(self)
                layout.setContentsMargins(20, 15, 20, 20)
                
                self.title = Title('', 23)
                titleLayout = QHBoxLayout()
                titleLayout.setAlignment(Qt.AlignTop)
                titleLayout.addWidget(QLabel(' ' * 5))
                titleLayout.addWidget(self.title, 1)
                layout.addLayout(titleLayout, 0)

                self.loading = Loading(200)
                self.loading.hide()
                layout.addWidget(self.loading, 1, Qt.AlignCenter)

                self.countDown = CountDown(200, self)
                self.countDown.hide()

                self.gameView = None

        def setTitle(self, title):
                self.title.setText(title)


        def showLoading(self):
                if self.gameView is not None:
                        self.gameView.hide()
                self.loading.show()

        def showCountDown(self, quick = False):
                center = self.gameView.pos() + QPoint(self.gameView.width() / 2, self.gameView.height() / 2)
                self.countDown.move(center - QPoint(self.countDown.width() / 2, self.countDown.height() / 2))
                self.countDown.show()
                self.countDown.raise_()
                self.countDown.start(5 if not quick else 0)

        def showGameView(self, gameMap):
                self.loading.hide()
                self.gameView = GameView(gameMap)
                self.layout().addWidget(self.gameView, 1, Qt.AlignCenter)
Beispiel #5
0
class Main(QMainWindow):
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)
        self.initUI()
        self.setMenu()

    def initUI(self):
        '''
        初始化UI
        :return:
        '''
        self.resize(1000, 600)
        self.setWindowTitle("海上数据挖掘可视化分析系统")
        self.setWindowIcon(QIcon(".\\res\\boat.ico"))  # 设置窗体图标
        self.center()  # 屏幕居中显示

    def setMenu(self):
        """
        设置菜单栏
        :return:
        """
        menubar = self.menuBar()
        importMenu = menubar.addMenu(u"导入数据")
        remoteAct = QAction("遥感数据", self)
        AisAct = QAction("AIS数据", self)
        ReplayAct = QAction("数据回放", self)
        importMenu.addAction(remoteAct)
        importMenu.addAction(AisAct)
        importMenu.addAction(ReplayAct)
        # remoteAct.triggered.connect()
        # AisAct.triggered.connect()
        # ReplayAct.triggered.connect()

        preMenu = menubar.addMenu(u"预处理")
        defogAct = QAction("视觉去雾", self)
        enhanceAct = QAction("低照度增强", self)
        filterAct = QAction("AIS数据筛选", self)
        preMenu.addAction(defogAct)
        preMenu.addAction(enhanceAct)
        preMenu.addAction(filterAct)
        # defogAct.triggered.connect()
        # enhanceAct.triggered.connect()
        # filterAct.triggered.connect()

        visualMenu = menubar.addMenu(u"源数据可视化")
        trackAct = QAction("船舶轨迹可视化", self)
        densityAct = QAction("船舶密度可视化", self)
        heatAct = QAction("热力图", self)
        trafficFlowAct = QAction("船舶交通流可视化", self)
        visualMenu.addAction(trackAct)
        visualMenu.addAction(densityAct)
        visualMenu.addAction(heatAct)
        visualMenu.addAction(trafficFlowAct)
        # trackAct.triggered.connect()
        # densityAct.triggered.connect()
        # heatAct.triggered.connect()
        # trafficFlowAct.triggered.connect()

        processMenu = menubar.addMenu(u"过程可视化")
        dbscanAct = QAction("航道驱动聚类", self)
        abnAct = QAction("异常模式", self)
        freAct = QAction("频繁模式", self)
        togAct = QAction("共现模式", self)
        cycAct = QAction("周期模式", self)
        processMenu.addAction(dbscanAct)
        processMenu.addAction(abnAct)
        processMenu.addAction(freAct)
        processMenu.addAction(togAct)
        processMenu.addAction(cycAct)
        # dbscanAct.triggered.connect()
        # abnAct.triggered.connect()
        # freAct.triggered.connect()
        # togAct.triggered.connect()
        # cycAct.triggered.connect()

        resultMenu = menubar.addMenu(u"结果可视化")
        randForestAct = QAction("随机森林算法", self)
        resultMenu.addAction(randForestAct)
        # randForestAct.triggered.connect()

        aboutMenu = menubar.addMenu(u"关于")
        aboutAct = QAction("关于", self)
        aboutMenu.addAction(aboutAct)
        aboutAct.triggered.connect(self.showAbout)

    def process(self):
        self.window = Loading()
        self.window.show()

    def center(self):
        '''
        窗口在屏幕居中显示
        :return:
        '''
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) / 2,
                  (screen.height() - size.height()) / 2)

    def showAbout(self):
        """
        显示关于
        :return:
        """
        QMessageBox.about(self, "关于", "海上数据挖掘可视化分析系统")