WSpacePlot::WSpacePlot(QSize size, bool dg, QWidget* parent, QWidget *colorBarParent, WGraphXAxis::Position xAxisPos, WGraphYAxis::Position yAxisPos, int border) : WGraphWidget(parent,xAxisPos,yAxisPos,border), paintColor(red), dataRange(0.0, 1.0), recRects(0), cellLabelRect(QRect()), colorBar(0), startCell(0,0), currCell(0,0), selecting(true), dragEnabled(false), drawGrid(dg), autoScale(true), multiSelect(true) { if (colorBarParent) { colorBar = new WColorBar(colorBarParent); connect(this,SIGNAL(colorChanged(QColor)), colorBar,SLOT(setColor(QColor))); connect(colorBar,SIGNAL(rangeSelected(WRange)), this,SLOT(selectRange(WRange))); connect(colorBar,SIGNAL(yVisRangeChanged(WRange)), this,SLOT(setDataRange(WRange))); colorBar->show(); } setCursor(crossCursor); if (drawGrid) setBackgroundColor(white); setFocusPolicy(TabFocus); xAxis()->setBaseTick(1.0); yAxis()->setBaseTick(1.0); showGrid(false); setSize(size); autoPanTimer = new QTimer(this); labelClearTimer = new QTimer(this); connect(frame(),SIGNAL(aboutToDraw()),this,SLOT(checkDataRange())); connect(autoPanTimer,SIGNAL(timeout()),this,SLOT(autoPan())); connect(labelClearTimer,SIGNAL(timeout()),this,SLOT(clearCellLabel())); connect(this,SIGNAL(frameResized()),SLOT(calcGeometry())); connect(this,SIGNAL(visRangeChanged()),SLOT(calcGeometry())); }
/** * @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(); }
void SPScatterPlotter::setData(QList<QPointF> data) { m_data = data; setDataRange(dataRange(data), true); }