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;
}
Example #2
0
  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);
  }
Example #3
0
/// 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();
}
Example #4
0
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;
     }
   }
 }