Esempio n. 1
0
Instances *ThresholdCurve::getCurve(std::vector<Prediction*> predictions) {

    if (predictions.size() == 0) {
        return nullptr;
    }
    return getCurve(predictions, (static_cast<NominalPrediction*>(predictions[0]))->distribution().size() - 1);
}
Esempio n. 2
0
void
KnobGui::setInterpolationForDimensions(QAction* action,
                                       KeyframeTypeEnum interp)
{
    if (!action) {
        return;
    }
    int dimension = action->data().toInt();
    KnobPtr knob = getKnob();


    for (int i = 0; i < knob->getDimension(); ++i) {
        if ( (dimension == -1) || (dimension == i) ) {
            boost::shared_ptr<Curve> c = knob->getCurve(ViewIdx(0), i);
            if (c) {
                int kfCount = c->getKeyFramesCount();
                for (int j = 0; j < kfCount; ++j) {
                    c->setKeyFrameInterpolation(interp, j);
                }
                boost::shared_ptr<Curve> guiCurve = getCurve(ViewIdx(0), i);
                if (guiCurve) {
                    guiCurve->clone(*c);
                }
            }
        }
    }
    if ( knob->getHolder() ) {
        knob->getHolder()->incrHashAndEvaluate(knob->getEvaluateOnChange(), false);
    }
    Q_EMIT keyInterpolationChanged();
}
Esempio n. 3
0
void KRAnimationAttribute::deleteCurve()
{
    KRAnimationCurve *curve = getCurve();
    if(curve) {
        getContext().getAnimationCurveManager()->deleteAnimationCurve(curve);
        m_curve = NULL;
    }
}
Esempio n. 4
0
/**
 * Return duplicate of edittable curve which is _curve_before_lpe if it exists or
 * shape->curve if not.
 */
SPCurve* SPPath::get_curve_for_edit () const
{
    if (_curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(this))) {
        return get_original_curve();
    } else {
        return getCurve();
    }
}
Esempio n. 5
0
/** Return area of curve segments
 * @return area.
 */
double OGRCompoundCurve::get_AreaOfCurveSegments() const
{
    double dfArea = 0;
    for( int i = 0; i < getNumCurves(); i++ )
    {
        const OGRCurve* poPart = getCurve(i);
        dfArea += poPart->get_AreaOfCurveSegments();
    }
    return dfArea;
}
Esempio n. 6
0
OGRBoolean  OGRCurveCollection::Equals( OGRCurveCollection *poOCC ) const
{
    if( getNumCurves() != poOCC->getNumCurves() )
        return FALSE;
    
    // we should eventually test the SRS.

    for( int iGeom = 0; iGeom < nCurveCount; iGeom++ )
    {
        if( !getCurve(iGeom)->Equals(poOCC->getCurve(iGeom)) )
            return FALSE;
    }

    return TRUE;
}
Esempio n. 7
0
void
KnobGui::onShowInCurveEditorActionTriggered()
{
    KnobPtr knob = getKnob();

    assert( knob->getHolder()->getApp() );
    getGui()->setCurveEditorOnTop();
    std::vector<boost::shared_ptr<Curve> > curves;
    for (int i = 0; i < knob->getDimension(); ++i) {
        boost::shared_ptr<Curve> c = getCurve(ViewIdx(0), i);
        if ( c->isAnimated() ) {
            curves.push_back(c);
        }
    }
    if ( !curves.empty() ) {
        getGui()->getCurveEditor()->centerOn(curves);
    }
}
Esempio n. 8
0
void LazyGraph::removeCurve(CurveId id)
{
    CurvePtr c = getCurve(id);
    if (c != NULL) {
        NodePtr start = c->getStart();
        NodePtr end = c->getEnd();
        NodeId nId;
        nId.id = NULL_ID;
        c->addVertex(nId, 0);
        c->addVertex(nId, 1);
        if (start != end && start != NULL) {
            start->removeCurve(id);
            if (start->getCurveCount() == 0) {
                NodeId sid = start->getId();
                start = NULL;
                removeNode(sid);
            } else {
                nodeCache->add(start.get(), true);
            }
        }

        if (end != NULL) {
            end->removeCurve(id);
            if (end->getCurveCount() == 0) {
                NodeId eid = end->getId();
                end = NULL;
                removeNode(eid);
            } else {
                nodeCache->add(end.get(), true);
            }
        }
    }

    curveCache->changedResources.erase(c.get());
    map<CurveId, long int>::iterator k = curveOffsets.find(id);
    if (k != curveOffsets.end()) {
        curveOffsets.erase(k);
    }
}
Esempio n. 9
0
CurvePtr LazyGraph::get(CurveId id)
{
    return getCurve(id);
}
Esempio n. 10
0
FractalGenerator::NoiseFunction FractalGenerator::getGradientNoise()
{
	auto curve = getCurve();
	return std::move(mm::gradient_noise(engine_, curve));
}
Esempio n. 11
0
FractalGenerator::NoiseFunction FractalGenerator::getValueNoise()
{
	auto curve = getCurve();
	return std::move(mm::value_noise(engine_, curve));
}
QwtArray<long> LegendWidget::itemsHeight(int symbolLineLength, int &width, int &height, 
							 int &textWidth, int &textHeight)
{
	QString text = d_text->text();
	QStringList titles = text.split("\n", QString::KeepEmptyParts);
	int n = (int)titles.count();
	QwtArray<long> heights(n);

	width = 0;
	height = 0;
	int maxL = 0;
	int h = top_margin + d_frame_pen.width();
	for (int i=0; i<n; i++){
		QString s = titles[i];
		int textL = 0;
		bool curveSymbol = false;
		while (s.contains("\\l(") || s.contains("\\p{")){
			int pos = s.indexOf("\\l(", 0);
			curveSymbol = true;
			if (pos >= 0){
                QwtText aux(parse(s.left(pos)));
                aux.setFont(d_text->font());
                QSize size = aux.textSize();
                textL += size.width();

                int pos1 = s.indexOf("(", pos);
                int pos2 = s.indexOf(")", pos1);
				int point = -1;
				PlotCurve *curve = getCurve(s.mid(pos1+1, pos2-pos1-1), point);
				if (!curve){
                	s = s.right(s.length() - pos2 - 1);
                    continue;
                }

                textL += symbolLineLength + h_space;
                s = s.right(s.length() - s.indexOf(")", pos) - 1);
            } else {
                pos = s.indexOf("\\p{", 0);
                if (pos >= 0){
                    QwtText aux(parse(s.left(pos)));
                    aux.setFont(d_text->font());
                    QSize size = aux.textSize();
                    textL += size.width();
                    textL += symbolLineLength;
                    s = s.right(s.length() - s.indexOf("}", pos) - 1);
                }
            }
		}

		QwtText aux(parse(s));
		aux.setFont(d_text->font());
		QSize size = aux.textSize();
		textL += size.width();
		if (curveSymbol)
			textL += h_space;

		if (textL > maxL)
			maxL = textL;

		int textH = size.height();
		height += textH;

		heights[i] = h + textH/2;
		h += textH;
	}


	height += 2*top_margin;
	width = 2*left_margin + maxL;
	
	int fw = 2*d_frame_pen.width();
    height += fw;
    width += fw;

    textHeight = height;
    textWidth = width;
	
    int aux_a = d_angle;	
	if (aux_a > 270)
		aux_a -= 270;
    if (aux_a >= 180)
        aux_a -= 180;
    if (aux_a > 90)
        aux_a -= 90;
    	
	double angle = aux_a*M_PI/180.0;
	if ((d_angle >= 0 && d_angle <= 90) || (d_angle >= 180 && d_angle <= 270)){
    	height = int(textWidth*sin(angle) + textHeight*cos(angle));
    	width = int(textWidth*cos(angle) + textHeight*sin(angle));
	} else {
    	height = int(textWidth*cos(angle) + textHeight*sin(angle));
    	width = int(textWidth*sin(angle) + textHeight*cos(angle));
	}
	
	if (d_frame == Shadow){
		width += d_shadow_width;
		height += d_shadow_width;
	}
	
	return heights;
}
void LegendWidget::drawText(QPainter *p, const QRect& rect,
		QwtArray<long> height, int symbolLineLength)
{
	p->save();
	if (d_plot->antialiasing())
		p->setRenderHints(QPainter::Antialiasing);

	p->setRenderHint(QPainter::TextAntialiasing);

	p->translate(rect.x(), rect.y());	
	
	int aux_a = d_angle;
	if (aux_a >= 270){
        aux_a -= 270;
		p->translate(rect.height()*cos(aux_a*M_PI/180.0), 0.0);
	} else if (aux_a >= 180){
        aux_a -= 180;
		p->translate(this->width(), rect.height()*cos(aux_a*M_PI/180.0));
	} else if (aux_a > 90){
        aux_a -= 90;
		p->translate(rect.width()*sin(aux_a*M_PI/180.0), this->height());
	}  else
		p->translate(0.0, rect.width()*sin(d_angle*M_PI/180.0));
	
    p->rotate(-d_angle);
	
	int l = symbolLineLength;
	QString text = d_text->text();
	QStringList titles = text.split("\n", QString::KeepEmptyParts);

	for (int i=0; i<(int)titles.count(); i++){
		int w = left_margin + d_frame_pen.width();
		bool  curveSymbol = false;
		QString s = titles[i];
		while (s.contains("\\l(") || s.contains("\\p{")){
			curveSymbol = true;
			int pos = s.indexOf("\\l(", 0);
			if (pos >= 0){
                QwtText aux(parse(s.left(pos)));
                aux.setFont(d_text->font());
                aux.setColor(d_text->color());

                QSize size = aux.textSize();
                QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
                aux.draw(p, tr);
                w += size.width();

                int pos1 = s.indexOf("(", pos);
                int pos2 = s.indexOf(")", pos1);
				int point = -1;
				PlotCurve *curve = getCurve(s.mid(pos1+1, pos2-pos1-1), point);
				if (!curve){
                	s = s.right(s.length() - pos2 - 1);
                    continue;
                }

            	drawSymbol(curve, point, p, w, height[i], l);
            	w += l + h_space;
            	s = s.right(s.length() - pos2 - 1);
			} else {
			    pos = s.indexOf("\\p{", 0);
                if (pos >= 0){
                    QwtText aux(parse(s.left(pos)));
                    aux.setFont(d_text->font());
                    aux.setColor(d_text->color());

                    QSize size = aux.textSize();
                    QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
                    aux.draw(p, tr);
                    w += size.width();

                    int pos1 = s.indexOf("{", pos);
                    int pos2 = s.indexOf("}", pos1);
                    int point = s.mid(pos1 + 1, pos2 - pos1 - 1).toInt() - 1;
					drawSymbol((PlotCurve*)d_plot->curve(0), point, p, w, height[i], l);
                	w += l;
                	s = s.right(s.length() - pos2 - 1);
                }
			}
		}

		if (!s.isEmpty()){
			if (curveSymbol)
				w += h_space;
			QwtText aux(parse(s));
			aux.setFont(d_text->font());
			aux.setColor(d_text->color());
			QSize size = aux.textSize();
			QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
			aux.draw(p, tr);
		}
	}
	p->restore();
}
Esempio n. 14
0
int LegendWidget::symbolsMaxWidth()
{
  QList<int> cvs = d_plot->curveKeys();
  int curves = cvs.count();
  if (!curves)
    return 0;

  // RJT (22/09/09): For rest of method, copied in code from current 
  // QtiPlot (rev. 1373) to fix infinite loop if closing bracket missing
  int maxL = 0;
  QString text = d_text->text();
  QStringList titles = text.split("\n", QString::KeepEmptyParts);
  for (int i=0; i<(int)titles.count(); i++){
    QString s = titles[i];
    while (s.contains("\\l(",Qt::CaseInsensitive)){
      int pos = s.indexOf("\\l(", 0,Qt::CaseInsensitive);
      int pos1 = s.indexOf("(", pos);
      int pos2 = s.indexOf(")", pos1);
      int pos3 = s.indexOf(",",pos1);
      if (pos3 != -1 && pos3 < pos2 ) pos2=pos3; // for pi charts get dataset number
      if (pos2 == -1){
        s = s.right(s.length() - pos1 - 1);
        continue;
      }

      int point = 0;
      PlotCurve* c = getCurve(s.mid(pos1 + 1, pos2 - pos1 - 1), point);
      if (c && c->type() == Graph::Pie){
        maxL = 2*d_text->font().pointSize();//10;
        line_length = 0;
        s = s.right(s.length() - pos2 - 1);
        continue;
      }

      if (c && c->rtti() != QwtPlotItem::Rtti_PlotSpectrogram) {
        if (c->type() == Graph::Pie ||
          c->type() == Graph::VerticalBars ||
          c->type() == Graph::HorizontalBars ||
          c->type() == Graph::Histogram ||
          c->type() == Graph::Box){
          maxL = 2*d_text->font().pointSize();//10;
          line_length = 0;
        } else {
          int l = c->symbol().size().width();
          if (l < 3)
            l = 3;
          else if (l > 15)
            l = 15;
          if (l>maxL && c->symbol().style() != QwtSymbol::NoSymbol)
            maxL = l;
        }
      }
      s = s.right(s.length() - pos2 - 1);
    }

    if (titles[i].contains("\\p{")){ // old syntax for pie charts
      maxL = 2*d_text->font().pointSize();//10;
      line_length = 0;
    }
  }
  return maxL;
}
Esempio n. 15
0
QwtArray<int> LegendWidget::itemsHeight(int y, int symbolLineLength, int &width, int &height)
{
  // RJT (22/09/09): For most of method, copied in code from current 
  // QtiPlot (rev. 1373) to fix infinite loop if closing bracket missing
  QString text = d_text->text();
  QStringList titles = text.split("\n", QString::KeepEmptyParts);
  int n = (int)titles.count();
  QwtArray<int> heights(n);

  width = 0;
  height = 0;
  int maxL = 0;
  int h = top_margin; // In QtiPlot rev 1373: + d_frame_pen.width();
  for (int i=0; i<n; i++){
    QString s = titles[i];
    int textL = 0;
    //bool curveSymbol = false;
    while (s.contains("\\l(",Qt::CaseInsensitive) || s.contains("\\p{",Qt::CaseInsensitive)){
      int pos = s.indexOf("\\l(", 0,Qt::CaseInsensitive);
      int pos2 = s.indexOf(",",pos); // two arguments in case if pie chart
      int pos3 = s.indexOf(")",pos);
      //curveSymbol = true;
      if (pos >= 0 && (pos2==-1 || pos2>pos3)){
        QwtText aux(parse(s.left(pos))); //not a pie chart
        aux.setFont(d_text->font());
        QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
        textL += size.width();

        int pos1 = s.indexOf("(", pos);
        int pos2 = s.indexOf(")", pos1);
        if (pos2 == -1){
          s = s.right(s.length() - pos1 - 1);
          continue;
        }
        int point = -1;
        PlotCurve *curve = getCurve(s.mid(pos1+1, pos2-pos1-1), point);
        if (!curve){
          s = s.right(s.length() - pos2 - 1);
          continue;
        }

        textL += symbolLineLength + h_space;
        s = s.right(s.length() - s.indexOf(")", pos) - 1);
      } else { //Pie chart?
        pos = s.indexOf("\\p{", 0,Qt::CaseInsensitive); //look for old syntax
        if (pos >= 0){
          QwtText aux(parse(s.left(pos)));
          aux.setFont(d_text->font());
          QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
          textL += size.width();
          textL += symbolLineLength;
          int pos2=s.indexOf("}", pos);
          if (pos2==-1) pos2=pos+3;
          s = s.right(s.length() - pos2 - 1);
        } else {
          pos = s.indexOf("\\l(", 0,Qt::CaseInsensitive); // new syntax
          if (pos >= 0){
            QwtText aux(parse(s.left(pos)));
            aux.setFont(d_text->font());
            QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
            textL += size.width();
            textL += symbolLineLength;
            int pos2=s.indexOf(")", pos);
            if (pos2==-1) pos2=pos+3;
            s = s.right(s.length() - pos2 - 1);
          }
        }
      }
    }
    // RJT (22/09/09): End copied in code from rev. 1373

    QwtText aux(parse(s));
    aux.setFont(d_text->font());
    QSize size = aux.textSize();
    textL += size.width();

    if (textL > maxL)
      maxL = textL;

    int textH = size.height();
    height += textH;

    heights[i] = y + h + textH/2;
    h += textH;
  }

  height += 2*top_margin;
  width = 2*left_margin + maxL + h_space;

  return heights;
}
Esempio n. 16
0
void LegendWidget::drawText(QPainter *p, const QRect& rect,
		QwtArray<int> height, int symbolLineLength)
{
  p->save();
  if ((dynamic_cast<Graph *>(d_plot->parent()))->antialiasing())
    p->setRenderHints(QPainter::Antialiasing);

  // RJT (22/09/09): For remainder of method, copied in code from current 
  // QtiPlot (rev. 1373) to fix infinite loop if closing bracket missing
  int l = symbolLineLength;
  QString text = d_text->text();
  QStringList titles = text.split("\n", QString::KeepEmptyParts);

  for (int i=0; i<(int)titles.count(); i++){
    int w = left_margin + rect.x(); // QtiPlot Rev 1373 has this as 2nd arg: d_frame_pen.width();
    bool  curveSymbol = false;
    QString s = titles[i];
    while (s.contains("\\l(",Qt::CaseInsensitive) || s.contains("\\p{",Qt::CaseInsensitive)){
      curveSymbol = true;
      int pos = s.indexOf("\\l(", 0,Qt::CaseInsensitive);
      int pos2 = s.indexOf(",",pos); // two arguments in case if pie chart
      int pos3 = s.indexOf(")",pos);
      if (pos >= 0 && (pos2 == -1 || pos2 > pos3)){
        QwtText aux(parse(s.left(pos))); //not a pie chart
        aux.setFont(d_text->font());
        aux.setColor(d_text->color());
        aux.setRenderFlags (Qt::AlignLeft | Qt::AlignVCenter);

        QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
        QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
        aux.draw(p, tr);
        w += size.width();

        int pos1 = s.indexOf("(", pos);
        int pos2 = s.indexOf(")", pos1);
        if (pos2 == -1){
          s = s.right(s.length() - pos1 - 1);
          continue;
        }
        int point = -1;
        PlotCurve *curve = getCurve(s.mid(pos1+1, pos2-pos1-1), point);
        if (!curve){
          s = s.right(s.length() - pos2 - 1);
          continue;
        }

        drawSymbol(curve, point, p, w, height[i], l);
        w += l + h_space;
        s = s.right(s.length() - pos2 - 1);
      } else { // pie chart?
        pos = s.indexOf("\\p{", 0);
        if (pos >= 0){  // old syntax
          QwtText aux(parse(s.left(pos)));
          aux.setFont(d_text->font());
          aux.setColor(d_text->color());
          aux.setRenderFlags (Qt::AlignLeft | Qt::AlignVCenter);

          QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
          QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
          aux.draw(p, tr);
          w += size.width();

          int pos1 = s.indexOf("{", pos);
          int pos2 = s.indexOf("}", pos1);
          if (pos2 == -1){
          s = s.right(s.length() - pos1 - 1);
          continue;
          }
          int point = s.mid(pos1 + 1, pos2 - pos1 - 1).toInt() - 1;
          drawSymbol(dynamic_cast<PlotCurve*>(d_plot->curve(0)), point, p, w, height[i], l);
          w += l;
          s = s.right(s.length() - pos2 - 1);
        } else {
          pos = s.indexOf("\\l(", 0,Qt::CaseInsensitive);
          if (pos >= 0 && pos2 != -1){ //new syntax
            QwtText aux(parse(s.left(pos)));
            aux.setFont(d_text->font());
            aux.setColor(d_text->color());
            aux.setRenderFlags (Qt::AlignLeft | Qt::AlignVCenter);

            QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
            QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
            aux.draw(p, tr);
            w += size.width();

            int pos1 = s.indexOf(",", pos);
            int pos3 = s.indexOf(")", pos1);
            if (pos3 == -1){
              s = s.right(s.length() - pos1 - 1);
              continue;
            }
            int point = s.mid(pos1 + 1, pos3 - pos1 - 1).toInt() - 1;
            drawSymbol(dynamic_cast<PlotCurve*>(d_plot->curve(0)), point, p, w, height[i], l);
            w += l;
            s = s.right(s.length() - pos3 - 1);
          }
        }
      }
    }

    if (!s.isEmpty()){
      if (curveSymbol)
        w += h_space;
      QwtText aux(parse(s));
      aux.setFont(d_text->font());
      aux.setColor(d_text->color());
      aux.setRenderFlags (Qt::AlignLeft | Qt::AlignVCenter);

      QSize size = aux.textSize(); // In QtiPlot rev 1373: textSize(p, aux);
      QRect tr = QRect(QPoint(w, height[i] - size.height()/2), size);
      aux.draw(p, tr);
    }
  }
  p->restore();
}