Ejemplo n.º 1
0
void EnrichmentDialog::apply()
{
	if (tabWidget->currentPage() == editPage)
		fetchImage();
	else if (tabWidget->currentPage() == framePage)
		frameApplyTo();
	else if (imagePage && tabWidget->currentPage() == imagePage)
		chooseImageFile(imagePathBox->text());
	else if (tabWidget->currentPage() == geometryPage){
		setCoordinates(unitBox->currentIndex());
		FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget);
        if (fw)
            fw->setAttachPolicy((FrameWidget::AttachPolicy)attachToBox->currentIndex());

		if (d_app)
			d_app->d_keep_aspect_ration = keepAspectBox->isChecked();
	} else if (patternPage && tabWidget->currentPage() == patternPage)
		patternApplyTo();
	else if (textPage && tabWidget->currentPage() == textPage){
		LegendWidget *l = qobject_cast<LegendWidget *>(d_widget);
		if (l)
			l->setText(textEditBox->text());

		textFormatApplyTo();
		if (d_app)
			d_app->setFormatBarFont(textFont);
	}
}
Ejemplo n.º 2
0
void LegendWidget::restore(Graph *g, const QStringList& lst)
{
	QColor backgroundColor = Qt::white;
	double x = 0.0, y = 0.0;
	QStringList::const_iterator line;
	LegendWidget *l = new LegendWidget(g);
	for (line = lst.begin(); line != lst.end(); line++){
        QString s = *line;
        if (s.contains("<Frame>"))
			l->setFrameStyle((s.remove("<Frame>").remove("</Frame>").toInt()));
		else if (s.contains("<Color>"))
			l->setFrameColor(QColor(s.remove("<Color>").remove("</Color>")));
		else if (s.contains("<FrameWidth>"))
			l->setFrameWidth(s.remove("<FrameWidth>").remove("</FrameWidth>").toInt());
		else if (s.contains("<LineStyle>"))
			l->setFrameLineStyle(PenStyleBox::penStyle(s.remove("<LineStyle>").remove("</LineStyle>").toInt()));
		else if (s.contains("<x>"))
			x = s.remove("<x>").remove("</x>").toDouble();
		else if (s.contains("<y>"))
			y = s.remove("<y>").remove("</y>").toDouble();
		else if (s.contains("<Text>")){
			QStringList txt;
			while ( s != "</Text>" ){
				s = *(++line);
				txt << s;
			}
			txt.pop_back();
			l->setText(txt.join("\n"));
		} else if (s.contains("<Font>")){
			QStringList lst = s.remove("<Font>").remove("</Font>").split("\t");
			QFont f = QFont(lst[0], lst[1].toInt(), lst[2].toInt(), lst[3].toInt());
			f.setUnderline(lst[4].toInt());
			f.setStrikeOut(lst[5].toInt());
			l->setFont(f);
		} else if (s.contains("<TextColor>"))
			l->setTextColor(QColor(s.remove("<TextColor>").remove("</TextColor>")));
		else if (s.contains("<Background>"))
			backgroundColor = QColor(s.remove("<Background>").remove("</Background>"));
		else if (s.contains("<Alpha>"))
			backgroundColor.setAlpha(s.remove("<Alpha>").remove("</Alpha>").toInt());
		else if (s.contains("<Angle>"))
			l->setAngle(s.remove("<Angle>").remove("</Angle>").toInt());
		else if (s.contains("<AutoUpdate>"))
			l->setAutoUpdate(s.remove("<AutoUpdate>").remove("</AutoUpdate>").toInt());
	}
	if (l){
		l->setBackgroundColor(backgroundColor);
		l->setOriginCoord(x, y);
		g->add(l, false);
	}
}
Ejemplo n.º 3
0
void Filter::showLegend()
{
	if (!d_output_graph)
		return;

	QList <FrameWidget *> lst = d_output_graph->enrichmentsList();
	foreach(FrameWidget *fw, lst){
		LegendWidget *l = qobject_cast<LegendWidget *>(fw);
		if (l && l->isAutoUpdateEnabled()){
			l->setText(l->text() + "\n" + legendInfo());
			l->repaint();
			return;
		}
	}
Ejemplo n.º 4
0
void Differentiation::output() {
  std::vector<double> result(d_n - 1);
  for (int i = 1; i < d_n - 1; i++)
    result[i] = 0.5 * ((d_y[i + 1] - d_y[i]) / (d_x[i + 1] - d_x[i]) +
                       (d_y[i] - d_y[i - 1]) / (d_x[i] - d_x[i - 1]));

  ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(parent());
  if (!app) {
    throw std::logic_error(
        "Parent of Differentiation is not ApplicationWindow as expected.");
  }
  QLocale locale = app->locale();
  QString tableName = app->generateUniqueName(QString(objectName()));
  QString dataSet;
  if (d_curve)
    dataSet = d_curve->title().text();
  else
    dataSet = d_y_col_name;

  d_result_table = app->newHiddenTable(
      tableName,
      tr("Derivative") + " " + tr("of", "Derivative of") + " " + dataSet,
      d_n - 2, 2);
  for (int i = 1; i < d_n - 1; i++) {
    d_result_table->setText(
        i - 1, 0, locale.toString(d_x[i], 'g', app->d_decimal_digits));
    d_result_table->setText(
        i - 1, 1, locale.toString(result[i], 'g', app->d_decimal_digits));
  }

  if (d_graphics_display) {
    if (!d_output_graph)
      d_output_graph = createOutputGraph()->activeGraph();

    d_output_graph->insertCurve(d_result_table, tableName + "_2", 0);
    QString legend = "\\l(1)" + tr("Derivative") + " " +
                     tr("of", "Derivative of") + " " + dataSet;
    LegendWidget *l = d_output_graph->legend();
    if (l) {
      l->setText(legend);
      l->repaint();
    } else
      d_output_graph->newLegend(legend);
  }
}
void Differentiation::output()
{
    double *result = new double[d_n-1];
	for (int i = 1; i < d_n-1; i++)
		result[i]=0.5*((d_y[i+1]-d_y[i])/(d_x[i+1]-d_x[i]) + (d_y[i]-d_y[i-1])/(d_x[i]-d_x[i-1]));

    ApplicationWindow *app = (ApplicationWindow *)parent();
    QLocale locale = app->locale();
    QString tableName = app->generateUniqueName(QString(objectName()));
    QString dataSet;
	if (d_curve)
		dataSet = d_curve->title().text();
	else
		dataSet = d_y_col_name;

    d_result_table = app->newHiddenTable(tableName, tr("Derivative") + " " + tr("of","Derivative of")  + " " + dataSet, d_n-2, 2);
	for (int i = 1; i < d_n-1; i++) {
		d_result_table->setText(i-1, 0, locale.toString(d_x[i], 'g', app->d_decimal_digits));
		d_result_table->setText(i-1, 1, locale.toString(result[i], 'g', app->d_decimal_digits));
	}
    delete[] result;

	if (d_graphics_display){
		if (!d_output_graph)
			d_output_graph = createOutputGraph()->activeLayer();

    	d_output_graph->insertCurve(d_result_table, tableName + "_2", 0);
    	QString legend = "\\l(1)" + tr("Derivative") + " " + tr("of","Derivative of") + " " + dataSet;
    	LegendWidget *l = d_output_graph->legend();
		if (l){
    		l->setText(legend);
    		l->repaint();
        } else
            d_output_graph->newLegend(legend);
	}
}