Example #1
0
ProofPage::ProofPage(ResizableStackedWidget *pageStack, Model *model, QWidget *parent)
    : QWidget(parent)
{
    this->model = model;
    this->pageStack = pageStack;



    proofEditForm = new ProofForm();
    proofEditDialog = new Dialog(this, proofEditForm, "Edit the proof...", "Change", "Cancel");

    proofDeleteDialog = new Dialog(this, nullptr, "Are you sure you want to delete this proof?", "Delete", "Cancel");



    QVBoxLayout *outerLayout = new QVBoxLayout(this);



    //  ##   ## #######   ###   #####   ####### #####
    //  ##   ## ##       ## ##  ##  ##  ##      ##  ##
    //  ##   ## ##      ##   ## ##   ## ##      ##   ##
    //  ####### #####   ##   ## ##   ## #####   ##  ##
    //  ##   ## ##      ####### ##   ## ##      #####
    //  ##   ## ##      ##   ## ##  ##  ##      ##  ##
    //  ##   ## ####### ##   ## #####   ####### ##   ##

    // The breadcrumbs show the current course and provide
    // a way to go back to the courses screen.
    // It is presented like a filepath.

    QHBoxLayout *crumbBorderLayout = new QHBoxLayout();

    breadCrumbs = new BreadCrumbs(3, model, pageStack);
    breadCrumbs->setFixedWidth(700);

    crumbBorderLayout->addStretch(1);
    crumbBorderLayout->addWidget(breadCrumbs);
    crumbBorderLayout->addStretch(1);

    outerLayout->addLayout(crumbBorderLayout);



    // Now show the name of the current proof and some buttons to
    // edit it, delete it or add a new dependency.

    QHBoxLayout *topBorderLayout = new QHBoxLayout();

    QWidget *topWidget = new QWidget();
    topWidget->setFixedWidth(700);
    QHBoxLayout *topLayout = new QHBoxLayout(topWidget);
    topLayout->setContentsMargins(0, 0, 0, 0);

    proofLabel = new QLabel();
    proofLabel->setWordWrap(true);
    proofLabel->setScaledContents(true);

    QFont proofFont = proofLabel->font();
    proofFont.setPointSize(24);
    proofLabel->setFont(proofFont);

    trafficLight = new TrafficLight(TrafficLight::AMBER);
    trafficLight->setFixedSize(QSize(32, 32));
    QVBoxLayout *trafficLightVLayout = new QVBoxLayout();
    trafficLightVLayout->addSpacing(16);
    trafficLightVLayout->addWidget(trafficLight);

    editProofButton = new ImageButton(QPixmap(":/images/pencil_black.png"), QSize(32, 32));
    QVBoxLayout *editProofVLayout = new QVBoxLayout();
    editProofVLayout->addSpacing(16);
    editProofVLayout->addWidget(editProofButton);

    deleteProofButton = new ImageButton(QPixmap(":/images/trash_black.png"), QSize(32, 32));
    QVBoxLayout *deleteProofVLayout = new QVBoxLayout();
    deleteProofVLayout->addSpacing(16);
    deleteProofVLayout->addWidget(deleteProofButton);

    topLayout->addWidget(proofLabel);
    topLayout->addLayout(trafficLightVLayout);
    topLayout->addSpacing(10);
    topLayout->addLayout(editProofVLayout);
    topLayout->addSpacing(10);
    topLayout->addLayout(deleteProofVLayout);

    topBorderLayout->addStretch(1);
    topBorderLayout->addWidget(topWidget);
    topBorderLayout->addStretch(1);
    outerLayout->addLayout(topBorderLayout);



    outerLayout->addSpacing(20);
    outerLayout->addWidget(new HorizontalSeperator(QColor(66, 139, 202), 2));
    outerLayout->addSpacing(20);



    //  ######   #####  #####   ##    ##
    //  ##   ## ##   ## ##  ###  ##  ##
    //  ##   ## ##   ## ##   ##   ####
    //  ######  ##   ## ##   ##    ##
    //  ##   ## ##   ## ##   ##    ##
    //  ##   ## ##   ## ##  ###    ##
    //  ######   #####  #####      ##

    // Use a vertical splitter to divide the areas.

    splitter = new Splitter(Qt::Vertical);
    outerLayout->addWidget(splitter);
    splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);



    // The first area is a large text editing widget, this is
    // used to edit the proof's body.
    // The QTextEdit does its own scrolling.

    bodyTextEdit = new QTextEdit();

    QFont font = bodyTextEdit->font();
    font.setFamily("Courier");
    font.setPointSize(12);
    bodyTextEdit->setFont(font);

    bodyHighlighter = new LatexHighlighter(bodyTextEdit->document());

    splitter->addWidget(bodyTextEdit);

    QTimer *bodySaveTimer = new QTimer(this);
    bodySaveTimer->setSingleShot(true);
    bodySaveTimer->setInterval(200);

    connect(bodyTextEdit, SIGNAL(textChanged()), bodySaveTimer, SLOT(start()));
    connect(bodySaveTimer, SIGNAL(timeout()), this, SLOT(saveBody()));



    // The second area contains the rendered body.

    QScrollArea *bodyScrollArea = new QScrollArea();
    bodyScrollArea->setWidgetResizable(true);
    bodyScrollArea->setFrameShape(QFrame::NoFrame);

    QWidget *bodyWidget = new QWidget();

    QPalette palette = bodyWidget->palette();
    palette.setColor(QPalette::Background, Qt::white);
    bodyWidget->setPalette(palette);
    bodyWidget->setAutoFillBackground(true);

    bodyImage = new ResizableImage("");

    QHBoxLayout *bodyHLayout = new QHBoxLayout();
    bodyHLayout->addStretch(1);
    bodyHLayout->addWidget(bodyImage);
    bodyHLayout->addStretch(1);

    QVBoxLayout *bodyVLayout = new QVBoxLayout();
    bodyVLayout->addLayout(bodyHLayout);
    bodyVLayout->addStretch(1);

    bodyWidget->setLayout(bodyVLayout);
    bodyScrollArea->setWidget(bodyWidget);
    splitter->addWidget(bodyScrollArea);



    //  #####  ####  #####  ##   ##   ###   ##       #####
    // ##   ##  ##  ##   ## ###  ##  ## ##  ##      ##   ##
    //  ##      ##  ##      ###  ## ##   ## ##       ##
    //   ###    ##  ##      ####### ##   ## ##        ###
    //     ##   ##  ##  ### ##  ### ####### ##          ##
    // ##   ##  ##  ##   ## ##  ### ##   ## ##      ##   ##
    //  #####  ####  #####  ##   ## ##   ## #######  #####

    connect(editProofButton, SIGNAL(clicked()), this, SLOT(proofEditButtonClicked()));

    connect(proofEditDialog, SIGNAL(accepted()), this, SLOT(proofEditDialogCompleted()));
    connect(proofEditDialog, SIGNAL(rejected()), proofEditDialog, SLOT(close()));

    connect(deleteProofButton, SIGNAL(clicked()), proofDeleteDialog, SLOT(show()));

    connect(proofDeleteDialog, SIGNAL(accepted()), this, SLOT(proofDeleteDialogAccepted()));
    connect(proofDeleteDialog, SIGNAL(rejected()), proofDeleteDialog, SLOT(close()));

    connect(model, SIGNAL(proofSelectedChanged(Proof)), this, SLOT(proofSelectedChangedSlot(Proof)));
    connect(model, SIGNAL(proofEdited(Proof)), this, SLOT(proofEditedSlot(Proof)));
    connect(model, SIGNAL(proofDeleted(int)), this, SLOT(proofDeletedSlot(int)));
}
Example #2
0
/**
 * @brief MainWindow::MainWindow Initialize the main window and everything else
 * @param parent
 */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
  // Initialize the interface
  ui->setupUi(this);
  ui->glWidget->addAction(ui->actionFullscreen);
  ui->glWidget->addAction(ui->actionExit);

  connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
  connect(ui->actionFullscreen,SIGNAL(triggered()),this,SLOT(toggleFullscreenSlot()));

  // The test script runs a simple experiment
  experimentScript = new TestScript(this,this);

  // Add a cosmetic line to the splitter handle
  // so that it's easier to grab with the mouse
  QSplitterHandle *handle = ui->splitter->handle(1);
  QVBoxLayout *layout = new QVBoxLayout(handle);
  layout->setSpacing(0);
  layout->setMargin(0);
  QFrame *line = new QFrame(handle);
  line->setFrameShape(QFrame::VLine);
  line->setFrameShadow(QFrame::Sunken);
  layout->addWidget(line);

  // In a future revision, we'll move the SimWorld
  // to a more intelligent place.  It doesn't
  // belong as a child to the graphics widget.
  SimWorld* world = ui->glWidget->getWorld();
  CapBody* capBody = world->getBody();
#if defined( BOARD_DATA )
  BoardMarkerData* md = ui->glWidget->getWorld()->getMarkerData();
#elif defined( POKE_DATA )
  PokeMarkerData* md = ui->glWidget->getWorld()->getMarkerData();
#else
  MarkerData* md = world->getMarkerData();
#endif

  // We populate a ScrollArea with the same number of
  // MarkerWidgets as there are markers in the data file.
  QScrollArea* sa = new QScrollArea;
  QWidget* wid = new QWidget;
  layout = new QVBoxLayout;
  layout->setContentsMargins(0,0,0,0);

  // This part needs to become part of a function
  // that is called everytime a new data file is
  // loaded.
  int markCnt = md->marker_count;
  ui->markerCountLineEdit->setText(QString::number(markCnt));
  ui->frameCountLineEdit->setText(QString::number(md->size()));
  ui->markerFileLineEdit->setText("data.c3d");
  ui->markerFrameStartBox->setValue(0);
  setDataRange(md->size());

  QHBoxLayout* innerLayout = new QHBoxLayout;
  QPushButton* connectButton = new QPushButton("Connect");
  QPushButton* releaseButton = new QPushButton("Release");
  QPushButton* updateButton = new QPushButton("Update Anchors");
  innerLayout->addWidget(connectButton);
  innerLayout->addWidget(releaseButton);
  innerLayout->addWidget(updateButton);
  connect(connectButton,SIGNAL(clicked()),this,SLOT(connectMarkers()));
  connect(releaseButton,SIGNAL(clicked()),this,SLOT(releaseMarkers()));
  connect(updateButton,SIGNAL(clicked()),this,SLOT(updateMarkerAnchors()));
  layout->addLayout(innerLayout);

  markerWidgetArray.resize(markCnt);
  for (int ii=0;ii<markCnt;++ii) {
    markerWidgetArray[ii] = new MarkerWidget(ii,0);
    layout->addWidget(markerWidgetArray[ii]);
  }
  wid->setLayout(layout);
  sa->setWidget(wid);
  ui->controlTabWidget->addTab(sa,"Markers");

  // Joint control tab
  sa = new QScrollArea;
  wid = new QWidget;
  layout = new QVBoxLayout;
  layout->setContentsMargins(0,0,0,0);

  // A couple buttons at the top of the joint tab make it possible
  // to rapidly change all the force limits
  innerLayout = new QHBoxLayout;
  QPushButton* zeroButton = new QPushButton("Zero");
  QPushButton* lightButton = new QPushButton("Light");
  QPushButton* resetButton = new QPushButton("Strong");
  innerLayout->addWidget(zeroButton);
  innerLayout->addWidget(lightButton);
  innerLayout->addWidget(resetButton);
  layout->addLayout(innerLayout);
  connect(zeroButton,SIGNAL(clicked()),this,SLOT(zeroForces()));
  connect(lightButton,SIGNAL(clicked()),this,SLOT(lightForces()));
  connect(resetButton,SIGNAL(clicked()),this,SLOT(strongForces()));

  // Fill the tab with hard-coded data about the model...
  populateJointTab(capBody,layout);
  wid->setLayout(layout);
  sa->setWidget(wid);
  ui->controlTabWidget->addTab(sa,"Joints");

  // Body dimensions widget
  sa = new QScrollArea;
  wid = new QWidget;
  layout = new QVBoxLayout;
  layout->setContentsMargins(0,0,0,0);
  QCheckBox* keepBodyRel = new QCheckBox("Body Rel");
  layout->addWidget(keepBodyRel);

  // Fill the tab with model-specific widgets
  populateBodyTab(capBody,layout);
  wid->setLayout(layout);
  sa->setWidget(wid);
  ui->controlTabWidget->addTab(sa,"Model dimensions");

  // Hook up the interface elements to their respecitve functionality
  connect(ui->saveButton,SIGNAL(clicked()),capBody,SLOT(saveBody()));
  connect(ui->loadButton,SIGNAL(clicked()),capBody,SLOT(loadBody()));
  connect(ui->testButton,SIGNAL(clicked()),this,SLOT(experimentSlot()));

  // When a the CapBody loads the marker map, tell the interface
  // how and where the markers are connected.
  connect(capBody,SIGNAL(markMap(int,int)),this,SLOT(setMarkMap(int,int)));
  connect(capBody,SIGNAL(markPoint(int,double,double,double)),
          this,SLOT(setMarkPoint(int,double,double,double)));

  // *****
  // (Each MarkerWidget informs the capBody when the interface
  //  changes).
  for (int ii=0;ii<markCnt;++ii) {
    connect(markerWidgetArray[ii],SIGNAL(markBodySet(int,int)),md,SLOT(changeBodyConnect(int,int)));
    connect(markerWidgetArray[ii],SIGNAL(markConnect(int,bool)),md,SLOT(changeBodyLink(int,bool)));
    connect(markerWidgetArray[ii],SIGNAL(markPosSet(int,double,double,double)),
            md,SLOT(changeLinkPos(int,double,double,double)));
    connect(markerWidgetArray[ii],SIGNAL(markGrab(int)),this, SLOT(grabMarkPos(int)));
  }

  connect(ui->clearPlotButton,SIGNAL(clicked()),this,SLOT(clearData()));
  connect(ui->glWidget->getWorld(),SIGNAL(useMarkers(bool)),this,SLOT(usingMarkers(bool)));
  connect(ui->frictionSpinBox,SIGNAL(valueChanged(double)),world,SLOT(setGroundFriction(double)));
  connect(ui->terrainSpinBox,SIGNAL(valueChanged(double)),world,SLOT(setTerrainSoftness(double)));
  connect(ui->zBox,SIGNAL(valueChanged(double)),ui->glWidget->getWorld(),SLOT(setTerrainZ(double)));
  connect(ui->forceLinesCheckBox,SIGNAL(clicked(bool)),ui->glWidget,SLOT(setDrawLines(bool)));
  connect(ui->camFollowCheckBox,SIGNAL(clicked(bool)),ui->glWidget,SLOT(setFollowCamera(bool)));
  connect(ui->timeSlider,SIGNAL(valueChanged(int)),world->getMarkerData(),SLOT(setFrame(int)));
  connect(ui->glWidget->getWorld()->getMarkerData(),SIGNAL(frameChanged(int)),ui->timeSlider,SLOT(setValue(int)));
  connect(ui->bodyAlpha,SIGNAL(valueChanged(double)),ui->glWidget,SLOT(setBodyAlpha(double)));
  connect(ui->showMarkBox,SIGNAL(toggled(bool)),ui->glWidget,SLOT(setShowMarkers(bool)));
  connect(ui->selfCollideBox,SIGNAL(toggled(bool)),world,SLOT(setSelfCollide(bool)));
  connect(ui->saveStateButton,SIGNAL(clicked()),this,SLOT(saveModel()));
  connect(ui->restoreButton,SIGNAL(clicked()),this,SLOT(restoreModel()));

  connect(ui->markerRadio,SIGNAL(toggled(bool)),this,SLOT(useMarkers(bool)));
  connect(ui->torqueRadio,SIGNAL(toggled(bool)),this,SLOT(useTorques(bool)));
  connect(ui->altRadio,SIGNAL(toggled(bool)),this,SLOT(useAltForces(bool)));

  connect(ui->playAllButton,SIGNAL(clicked(bool)),this,SLOT(playPauseAll(bool)));
  connect(ui->playPauseDataButton,SIGNAL(clicked(bool)),this,SLOT(playPauseData(bool)));
  connect(ui->playPauseSimButton,SIGNAL(clicked(bool)),this,SLOT(playPauseSim(bool)));

  connect(ui->stepAllButton,SIGNAL(clicked()),this,SLOT(stepAll()));
  connect(ui->stepDataButton,SIGNAL(clicked()),this,SLOT(stepData()));
  connect(ui->stepSimButton,SIGNAL(clicked()),this,SLOT(stepSim()));


  connect(ui->selectFileToolButton,SIGNAL(clicked()),this,SLOT(markerFileDialog()));
  connect(ui->dataStepBox,SIGNAL(valueChanged(int)),this,SLOT(setDataStep(int)));
  connect(ui->dataFrameBox,SIGNAL(valueChanged(int)),this,SLOT(setDataFrame(int)));
  connect(ui->timeSlider,SIGNAL(valueChanged(int)),ui->dataFrameBox,SLOT(setValue(int)));

  // *****
  // Need to dynamically change this
  ui->timeSlider->setRange(0,world->getMarkerData()->size()-1);
  connect(ui->globalBox,SIGNAL(toggled(bool)),this,SLOT(useGlobalForces(bool)));

#if defined( BOARD_DATA )
  bd = new BoardData(this);
  bd->loadData("boardData.dat");
  ui->glWidget->setBoardData(bd);
#endif

  // Start the timer for updating the data, sim, and graphics
  updateTimer.setSingleShot(false);
  connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updateLoop()));

  connect(ui->frameTimeBox,SIGNAL(valueChanged(double)),this,SLOT(setFrameTime(double)));
  ui->frameTimeBox->setValue(1/60.0);
  ui->dataStepBox->setValue(2);

  capBody->loadBody();
  useMarkers(true);
  saveModel();
}
Example #3
0
/**
 * \brief    Met à jour la ressource
 * \details  Met à jour la ressource avec ce qui à été entré dans la vue
 */
void NoteEditor::updateNote(){
    resource->setTitle(title->text());
    saveBody();
}