bool CorrelationTimeArcGrbcat::doParse(type::CorrelationCmdType cmd, std::list<std::string>& tokens) { switch (cmd) { default: break; } tokens.clear(); const Catalog* catalog = AnalysisData::instance()->getCatalogData(); auto minEntry = std::min_element(catalog->getEntries().begin(), catalog->getEntries().end(), CompareTime()); auto maxEntry = std::max_element(catalog->getEntries().begin(), catalog->getEntries().end(), CompareTime()); type::Float range = std::ceil((getTime(*maxEntry) - getTime(*minEntry)) / 365.0) * 365.0; if (setXAxis(range, 365)) { Exception exc(type::EXCEPTION_WARNING + type::EXCEPTION_MOD_NO_PREFIX, "CorrelationTimeArcGrbcat failed to set correlation x axis.\n"); throw exc; } setYAxis(M_PIl, 180); return true; }
void LinePlot::drawPlot(Frame* frame) { Frame innerFrame = getPlotArea(frame); // Obtain mins and maxes from the data double minXdata, maxXdata, minYdata, maxYdata; sl.findMinMax(minXdata,maxXdata,minYdata,maxYdata); // Assume these will be used as boundaries of the plots double minX=minXdata, maxX=maxXdata, minY=minYdata, maxY=maxYdata; // See if the user overrode the axes limits if (fixedXaxis) { minX = minx; maxX = minx + width; } if (fixedYaxis) { minY = miny; maxY = miny+height; } // Use default min/max sl.drawInFrame(innerFrame,minX,maxX,minY,maxY); setXAxis(minX, maxX); setYAxis(minY, maxY); drawAxis(frame); }
/// Initialises the coordinate axes, adds labels and/or units to the axes, /// calculates axes-lengths, offsets, etc. void DiagramScene::initialize() { QPen pen(Qt::black, 2, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); pen.setCosmetic(true); setXAxis(addArrow(_bounds.width(), 0, pen)); setYAxis(addArrow(_bounds.height(), -90, pen)); _xLabel = addNonScalableText(" "); _yLabel = addNonScalableText(" "); _yLabel->rotate(-90); _xUnit = addNonScalableText(" "); _yUnit = addNonScalableText(" "); update(); }
void AnalysisDataLifetimeModule::dataFinished() { // Need to process the elements present in the last frame explicitly. for (size_t i = 0; i < impl_->currentLifetimes_.size(); ++i) { for (size_t j = 0; j < impl_->currentLifetimes_[i].size(); ++j) { impl_->addLifetime(i, impl_->currentLifetimes_[i][j]); } } impl_->currentLifetimes_.clear(); if (impl_->bCumulative_) { // Sum up subintervals of longer intervals into the histograms // if explicitly requested. std::vector<Impl::LifetimeHistogram>::iterator histogram; for (histogram = impl_->lifetimeHistograms_.begin(); histogram != impl_->lifetimeHistograms_.end(); ++histogram) { Impl::LifetimeHistogram::iterator shorter, longer; for (shorter = histogram->begin(); shorter != histogram->end(); ++shorter) { int subIntervalCount = 2; for (longer = shorter + 1; longer != histogram->end(); ++longer, ++subIntervalCount) { // Interval of length shorter contains (longer - shorter + 1) // continuous intervals of length longer. *shorter += subIntervalCount * (*longer); } } } } // X spacing is determined by averaging from the first and last frame // instead of first two frames to avoid rounding issues. const real spacing = (impl_->frameCount_ > 1) ? (impl_->lastx_ - impl_->firstx_) / (impl_->frameCount_ - 1) : 0.0; setXAxis(0.0, spacing); // Determine output dimensionality to cover all the histograms. setColumnCount(impl_->lifetimeHistograms_.size()); std::vector<Impl::LifetimeHistogram>::const_iterator histogram; size_t maxLifetime = 1; for (histogram = impl_->lifetimeHistograms_.begin(); histogram != impl_->lifetimeHistograms_.end(); ++histogram) { maxLifetime = std::max(maxLifetime, histogram->size()); } setRowCount(maxLifetime); // Fill up the output data from the histograms. allocateValues(); int column = 0; for (histogram = impl_->lifetimeHistograms_.begin(); histogram != impl_->lifetimeHistograms_.end(); ++histogram, ++column) { int row = 0; Impl::LifetimeHistogram::const_iterator i; for (i = histogram->begin(); i != histogram->end(); ++i, ++row) { // Normalize by the number of frames, taking into account the // length of the interval (interval of length N cannot start in // N-1 last frames). row is always smaller than frameCount_ // because of the histograms have at most frameCount_ entries. const real normalized = *i / static_cast<real>(impl_->frameCount_ - row); value(row, column).setValue(normalized); } // Pad the rest of the histogram with zeros to match the longest // histogram. for (; row < rowCount(); ++row) { value(row, column).setValue(0.0); } } impl_->lifetimeHistograms_.clear(); valuesReady(); }
KDChartPlaneSeries::KDChartPlaneSeries( bool isX, double location ) { setXAxis(isX); setLocation(location); }
void PlotCurve::restoreCurveLayout(const QStringList& lst) { QStringList::const_iterator line = lst.begin(); for (line++; line != lst.end(); ++line){ QString s = *line; if (s == "<Pen>"){ QPen pen; while(s != "</Pen>"){ s = (*(++line)).stripWhiteSpace(); if (s.contains("<Color>")) pen.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) pen.setStyle(Graph::getPenStyle(s.remove("<Style>").remove("</Style>").toInt())); else if (s.contains("<Width>")) pen.setWidthF(s.remove("<Width>").remove("</Width>").toDouble()); } setPen(pen); } else if (s == "<Brush>"){ QBrush brush; while(s != "</Brush>"){ s = (*(++line)).stripWhiteSpace(); if (s.contains("<Color>")) brush.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) brush.setStyle(PatternBox::brushStyle(s.remove("<Style>").remove("</Style>").toInt())); } setBrush(brush); } else if (s == "<Symbol>"){ QwtSymbol symbol; while(s != "</Symbol>"){ s = (*(++line)).stripWhiteSpace(); if (s.contains("<Style>")) symbol.setStyle(SymbolBox::style(s.remove("<Style>").remove("</Style>").toInt())); else if (s.contains("<Size>")) symbol.setSize((QwtSymbol::Style)s.remove("<Size>").remove("</Size>").toInt()); else if (s == "<SymbolPen>"){ QPen pen; while(s != "</SymbolPen>"){ s = (*(++line)).stripWhiteSpace(); if (s.contains("<Color>")) pen.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) pen.setStyle(Graph::getPenStyle(s.remove("<Style>").remove("</Style>").toInt())); else if (s.contains("<Width>")) pen.setWidthF(s.remove("<Width>").remove("</Width>").toDouble()); } symbol.setPen(pen); } else if (s == "<SymbolBrush>"){ QBrush brush; while(s != "</SymbolBrush>"){ s = (*(++line)).stripWhiteSpace(); if (s.contains("<Color>")) brush.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<Style>")) brush.setStyle(PatternBox::brushStyle(s.remove("<Style>").remove("</Style>").toInt())); } symbol.setBrush(brush); } setSymbol(symbol); } } else if (s.contains("<xAxis>")) setXAxis(s.remove("<xAxis>").remove("</xAxis>").toInt()); else if (s.contains("<yAxis>")) setYAxis(s.remove("<yAxis>").remove("</yAxis>").toInt()); else if (s.contains("<Visible>")) setVisible(s.remove("<Visible>").remove("</Visible>").toInt()); } }
void GraphHelper::graphSumAmtVsDate(QCustomPlot* plot, std::vector<std::vector<std::string> > &results) { switch(typeGraph) { case 0: //Bar graph { //Initialize myBars QCPBars *myBars = new QCPBars(plot->xAxis, plot->yAxis); plot->addPlottable(myBars); //create the array that will hold the summed amounts for each year double* barAmount = new double[numYears]; for(int i=0; i<numYears;i++){ barAmount[i] = 0; } getData(barAmount,results); QVector<QString> xLabels; QVector<double> years, yValues; for (int i = earliest,k = 0,t=0;i<=latest;i++,k++) { //TODO: add option for user to choose bShowEmptyData(button on ui maybe) //only adds the year to the graph if it has an amount if(bShowEmptyData || barAmount[k] != 0) { //creates the bars and its associated data yValues << barAmount[k]; xLabels << QString::number(i); years << t++; numYears = t; } } //Modify properties of myBars: myBars->setData(years, yValues); //settings for the x and y axis plot->rescaleAxes(); setYAxis(plot); setYAxisTitle(plot); setXAxis(plot, xLabels,years); plot->replot(); free(barAmount); break; } case 1: { plot->addGraph(); plot->graph()->setLineStyle(QCPGraph::lsLine); QPen pen; pen.setColor(QColor(Qt::blue)); pen.setWidth(2.5); plot->graph()->setPen(pen); //create the array that will hold the summed amounts for each year double* amount = new double[numYears]; for(int i=0; i<numYears;i++){ amount[i] = 0; } getData(amount,results); QVector<QString> xLabels; QVector<double> years, yValues; for (int i = earliest,k = 0,t=0;i<=latest;i++,k++) { //TODO: Maybe add option for user to choose bShowEmptyData(button on ui) //only adds the year to the graph if it has an amount if(bShowEmptyData || amount[k] != 0) { //creates the bars and its associated data yValues << amount[k]; xLabels << QString::number(i); years << t++; numYears = t; } } //add data to graph plot->graph()->setData(years, yValues); plot->rescaleAxes(); //format x and y axis setXAxis(plot,xLabels,years); setYAxis(plot); setYAxisTitle(plot); plot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2)); plot->replot(); free(amount); break; } default: break; } }
void GraphHelper::graphAmtByType(QCustomPlot* plot, std::vector<std::vector<std::string>> &results) { switch(typeGraph) { case 0: { //Initialize myBars QCPBars *myBars = new QCPBars(plot->xAxis, plot->yAxis); plot->addPlottable(myBars); //create the array that will hold the summed amounts for each year double amount[250]= {0}; QVector<QString> xLabels = getData(amount,results); QVector<double> years, yValues; int maxYVal = 0; for (int k = 0,t=0;k<25;k++) { //only adds the year to the graph if it has an amount if(bShowEmptyData || amount[k] != 0) { //creates the bars and its associated data yValues << amount[k]; //used to set the y axis range if(maxYVal < amount[k]) maxYVal = amount[k]; years << t++; numYears = t; } } //Modify properties of myBars: myBars->setData(years, yValues); //settings for the x and y axis plot->rescaleAxes(); setYAxis(plot); setYAxisTitle(plot); setXAxis(plot, xLabels,years); plot->yAxis->setRange(0, maxYVal+0.5); plot->xAxis->setRange(-0.5, numYears-0.5); if(graphChoice == 7) plot->xAxis->setLabel("Name"); else plot->xAxis->setLabel(QString::number(dateChoice)); plot->replot(); break; } case 1: { plot->addGraph(); plot->graph()->setLineStyle(QCPGraph::lsLine); QPen pen; pen.setColor(QColor(Qt::blue)); pen.setWidth(2.5); plot->graph()->setPen(pen); //create the array that will hold the summed amounts for each year double amount[250]= {0}; QVector<QString> xLabels = getData(amount,results); QVector<double> years, yValues; int maxYVal = 0; for (int k = 0,t=0;k<25;k++) { //only adds the year to the graph if it has an amount if(bShowEmptyData || amount[k] != 0) { //creates the bars and its associated data yValues << amount[k]; //used to set the y axis range if(maxYVal < amount[k]) maxYVal = amount[k]; years << t++; numYears = t; } } //add data to graph plot->graph()->setData(years, yValues); plot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5)); plot->rescaleAxes(); //format x and y axis setXAxis(plot,xLabels,years); setYAxis(plot); setYAxisTitle(plot); plot->yAxis->setRange(0, maxYVal+0.5); plot->xAxis->setRange(-0.5, numYears-0.5); if(graphChoice == 7) plot->xAxis->setLabel("Name"); else plot->xAxis->setLabel(QString::number(dateChoice)); plot->replot(); break; } } }