void ExecutingPietLibraries::MakeGLView (std::vector<PietTree> & pt){
    if(pt.size() == 0 )return;
    if(pt[0].isLeaf()) return;
    pt = pt[0].Nodes();

    if(pt.size() < 3) return;
    int w = pt[0].Val();
    int h = pt[1].Val();
    QString title = pt[2].toString();
    for(int i:range(3)) pt.pop_back();
    GLGameWidget* glgw = GLGameWidget::MakeUniqueGLWidget(nullptr);
    if(glgw == nullptr) return ;
    glgw->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    glgw->setSize(w,h);

    QDockWidget* dw = new QDockWidget(nullptr);
    dw->setFloating(true);
    dw->setAllowedAreas(Qt::NoDockWidgetArea);
    dw->connect(dw,&QDockWidget::dockLocationChanged,[=](){ dw->setFloating(true);});
    dw->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    dw->setWidget(glgw);
    dw->setAttribute(Qt::WA_DeleteOnClose);
    dw->setWindowTitle(title);
    dw->show();
}
示例#2
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QToolBar *bar1 = this->addToolBar("Tools");
    QActionGroup *group1 = new QActionGroup(bar1);

    QAction *drawLineAction = new QAction("Line", bar1);
    drawLineAction->setIcon(QIcon(":/res/line.png"));
    drawLineAction->setToolTip(tr("Draw a line."));
    drawLineAction->setStatusTip(tr("Draw a line."));
    drawLineAction->setCheckable(true);
    drawLineAction->setChecked(true);
    group1->addAction(drawLineAction);
    bar1->addAction(drawLineAction);

    QAction *drawRectAction = new QAction("Rectangle", bar1);
    drawRectAction->setIcon(QIcon(":/res/rect.png"));
    drawRectAction->setToolTip(tr("Draw a rectangle."));
    drawRectAction->setStatusTip(tr("Draw a rectangle."));
    drawRectAction->setCheckable(true);
    group1->addAction(drawRectAction);
    bar1->addAction(drawRectAction);

    QAction *drawCircleAction = new QAction("Circle", bar1);
    drawCircleAction->setIcon(QIcon(":/res/circle.png"));
    drawCircleAction->setToolTip(tr("Draw a circle."));
    drawCircleAction->setStatusTip(tr("Draw a circle."));
    drawCircleAction->setCheckable(true);
    group1->addAction(drawCircleAction);
    bar1->addAction(drawCircleAction);

    // Start circle position
    QAction *drawStartCircleAction = new QAction("Circle", bar1);
    drawStartCircleAction->setIcon(QIcon(":/res/startcircle.png"));
    drawStartCircleAction->setToolTip(tr("Draw start position."));
    drawStartCircleAction->setStatusTip(tr("Draw start position."));
    drawStartCircleAction->setCheckable(true);
    group1->addAction(drawStartCircleAction);
    bar1->addAction(drawStartCircleAction);

    // Goal circle position
    QAction *drawGoalCircleAction = new QAction("Circle", bar1);
    drawGoalCircleAction->setIcon(QIcon(":/res/goalcircle.png"));
    drawGoalCircleAction->setToolTip(tr("Draw goal position."));
    drawGoalCircleAction->setStatusTip(tr("Draw goal position."));
    drawGoalCircleAction->setCheckable(true);
    group1->addAction(drawGoalCircleAction);
    bar1->addAction(drawGoalCircleAction);


    // =================== Save action
    QToolBar *bar2 = this->addToolBar("Tools2");
    QActionGroup *group2 = new QActionGroup(bar2);
    QAction *saveAction = new QAction("Save", bar2);
    saveAction->setIcon(QIcon(":/res/save.png"));
    saveAction->setToolTip(tr("Save to image"));
    saveAction->setStatusTip(tr("Save to image"));
    saveAction->setCheckable(false);
    saveAction->setChecked(false);
    group2->addAction(saveAction);
    bar2->addAction(saveAction);


    // =================== Load action
    QAction *loadAction = new QAction("Load", bar2);
    loadAction->setIcon(QIcon(":/res/load.png"));
    loadAction->setToolTip(tr("Load image"));
    loadAction->setStatusTip(tr("Load image"));
    loadAction->setCheckable(false);
    loadAction->setChecked(false);
    group2->addAction(loadAction);
    bar2->addAction(loadAction);


    // =================== Start action
    QAction *startAction = new QAction("Start", bar2);
    startAction->setIcon(QIcon(":/res/start.png"));
    startAction->setToolTip(tr("Start"));
    startAction->setStatusTip(tr("Start"));
    startAction->setCheckable(false);
    startAction->setChecked(false);
    group2->addAction(startAction);
    bar2->addAction(startAction);


    // =================== Stop action
    QAction *showAction = new QAction("Show Preformance", bar2);
    showAction->setIcon(QIcon(":/res/show.png"));
    showAction->setToolTip(tr("Show Preformance"));
    showAction->setStatusTip(tr("Show Preformance"));
    showAction->setCheckable(false);
    showAction->setChecked(false);
    group2->addAction(showAction);
    bar2->addAction(showAction);


    // =================== Reset action
    QAction *resetAction = new QAction("Reset", bar2);
    resetAction->setIcon(QIcon(":/res/reset.png"));
    resetAction->setToolTip(tr("Reset"));
    resetAction->setStatusTip(tr("Reset"));
    resetAction->setCheckable(false);
    resetAction->setChecked(false);
    group2->addAction(resetAction);
    bar2->addAction(resetAction);


    // Status bar
    QLabel *statusMsg = new QLabel;
    statusBar()->addWidget(statusMsg);


    paintWidget = new PaintWidget(this);

    gridLayout = new QGridLayout(this);
    gridLayout->addWidget(paintWidget, 0, 0, 1, 1);


//    paintWidget->resize(100, 100);
//    paintWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    setCentralWidget(paintWidget);


    // Dock widget 1
    //设置主窗体的第一个QDockWidget
    QDockWidget *preferenceDockWidget = new QDockWidget(this);
    //设置第一个QDockWidget的窗口名称
    preferenceDockWidget->setWindowTitle(tr("Preference"));
    //设置第一个QDockWidget的可停靠区域,全部可停靠
    preferenceDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
    preferenceDockWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    //设置第一个QDockWidget内的控件并设置该控件的属性

    preferenceWidget = new PreferenceWidget(this);


    QCalendarWidget *calendar = new QCalendarWidget;
    calendar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    calendar->setGridVisible(true);
    //将QCalendarWidget控件设置成QDockWidget的主控件 使其能随窗口大小改变而改变
    preferenceDockWidget->setWidget(preferenceWidget);
    //向主窗体中添加第一个QDockWidget控件 第一个参数表示初始显示的位置 第二个参数是要添加的QDockWidget控件
    this->addDockWidget(Qt::RightDockWidgetArea, preferenceDockWidget);

    // Dock widget 2
    QDockWidget *performanceDockWidget = new QDockWidget(this);
    //设置第一个QDockWidget的窗口名称
    performanceDockWidget->setWindowTitle(tr("Performance"));
    //设置第一个QDockWidget的可停靠区域,全部可停靠
    performanceDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
    performanceDockWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    //设置第一个QDockWidget内的控件并设置该控件的属性

    performanceWidget = new PerformanceWidget(this);

    //将QCalendarWidget控件设置成QDockWidget的主控件 使其能随窗口大小改变而改变
    performanceDockWidget->setWidget(performanceWidget);
    //向主窗体中添加第一个QDockWidget控件 第一个参数表示初始显示的位置 第二个参数是要添加的QDockWidget控件
    this->addDockWidget(Qt::RightDockWidgetArea, performanceDockWidget);



    connect(drawLineAction, SIGNAL(triggered()), this, SLOT(drawLineActionTriggered()));
    connect(drawRectAction, SIGNAL(triggered()), this, SLOT(drawRectActionTriggered()));
    connect(drawCircleAction, SIGNAL(triggered()), this, SLOT(drawCircleActionTriggered()));
    connect(drawStartCircleAction, SIGNAL(triggered()), this, SLOT(drawStartCircleActionTriggered()));
    connect(drawGoalCircleAction, SIGNAL(triggered()), this, SLOT(drawGoalCircleActionTriggered()));
    connect(this, SIGNAL(changeCurrentShape(Shape::Code)), paintWidget, SLOT(setCurrentShape(Shape::Code)));

    connect(saveAction, SIGNAL(triggered()), this, SLOT(saveActionTriggered()));
    connect(loadAction, SIGNAL(triggered()), this, SLOT(loadActionTriggered()));
    connect(startAction, SIGNAL(triggered()), this, SLOT(startActionTriggered()));
    connect(showAction, SIGNAL(triggered()), this, SLOT(stopActionTriggered()));
    connect(resetAction, SIGNAL(triggered()), this, SLOT(resetActionTriggered()));

    // when received the signal from the perference widget then send to pain widget
    connect(preferenceWidget, SIGNAL(rrtTextChangedSignal(QString)), paintWidget, SLOT(rrtTextChangedSlot(QString)));

    connect(this, SIGNAL(startSimulationSignal()), paintWidget, SLOT(startSimulationSlot()));
    connect(this, SIGNAL(stopSimulationSignal()), paintWidget, SLOT(stopSimulationSlot()));
    connect(this, SIGNAL(resetSimulationSignal()), paintWidget, SLOT(resetSimulationSlot()));


    // connect the iteration to the display panel
   // connect(paintWidget->getMyRRT(),SIGNAL(currentIterationChanged(int)),preferenceWidget,SLOT(currentIterationChangedSlot(int)));
    connect(paintWidget,SIGNAL(currentIteration(int)),performanceWidget,SLOT(currentIterationChangedSlot(int)));
    connect(paintWidget,SIGNAL(currentNodeCount(int)),performanceWidget,SLOT(currentNodecountChangedSlot(int)));
    connect(paintWidget,SIGNAL(currentPathLength(int)),performanceWidget,SLOT(currentPathLengthChangedSlot(int)));
}
示例#3
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *      MainWindow Class Constructor                                                                                           *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Main window layout including creation / allocation of data viewers                                                     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    reorderBufferViewer = new ReorderBufferViewer;
    reservationStationViewer = new ReservationStationsViewer;
    registerFileViewer = new RegisterFileViewer;
    memoryViewer = new MemoryViewer;

    setCentralWidget(reorderBufferViewer);              // ROB Viewer is the central table

    QDockWidget *rsvWidget = new QDockWidget;
    rsvWidget->setWidget(reservationStationViewer);     // Reservation stations viewer is a docking table
    rsvWidget->setWindowTitle(QString("Reservation Stations"));

    QDockWidget *rfvWidget = new QDockWidget;
    rfvWidget->setWidget(registerFileViewer);           // Register array viewer is a docking table
    rfvWidget->setWindowTitle(QString("Register File"));
    rfvWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);

    QDockWidget *mvWidget = new QDockWidget;
    mvWidget->setWidget(memoryViewer);                  // Memory viewer is a docking table
    mvWidget->setWindowTitle(QString("Memory"));

    addDockWidget(Qt::BottomDockWidgetArea, rsvWidget); // Reservation stations monitor is at the bottom
    addDockWidget(Qt::LeftDockWidgetArea, rfvWidget);   // Register array monitor is at the left
    addDockWidget(Qt::RightDockWidgetArea, mvWidget);   // Memory monitor is at the right

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Main menu description                                                                                                  *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    openAction = new QAction(tr("&Open"), this);            // Option not implemented yet: intended to open assembler code
                                                            //  text and run parser
    startAction = new QAction(tr("&Start"), this);          // Start processing: it basically enables the timer
    stopAction = new QAction(tr("&Stop"), this);            // Stop processing: disables the timer

    fileMenu = menuBar()->addMenu(tr("&File"));             // File menu only contains the Open command so far
    fileMenu->addAction(openAction);

    processingMenu = menuBar()->addMenu(tr("&Processing")); // Processing menu contains Start and Stop commands
    processingMenu->addAction(startAction);
    processingMenu->addAction(stopAction);

    mainTimer = new QTimer;                                 // Timer instantiation for 1-Hz operation
    mainTimer->setInterval(1000);
    mainTimer->setSingleShot(false);

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Signal-slot bindings                                                                                                   *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));       // Open commands shows Open File dialog

    connect(startAction, SIGNAL(triggered()), mainTimer, SLOT(start()));    // Start command triggers timer operation
    connect(stopAction, SIGNAL(triggered()), mainTimer, SLOT(stop()));      // Stop command stops timer

    connect(mainTimer, SIGNAL(timeout()), this, SLOT(cycleProcess()));      // Timer periodically triggers cycleProcess method

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Database initialization example                                                                                        *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    memoryData = (MemoryData *)malloc(10000);                           // Memory data structure
    registerFileData = (RegisterFileData *)malloc(10000);               // Register array data structure
    reorderBufferData = (ReorderBufferData *)malloc(10000);             // ROB data structure
    reservationStationsData = (ReservationStationsData *)malloc(10000); // Reservation stations data structure

    srand(time(NULL));  // Random generator initializer for databse management example below
}