示例#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);
	}
}
示例#2
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;
		}
	}
示例#3
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);
  }
}
示例#4
0
void CanvasPicker::drawTextMarker(const QPoint& point)
{
	LegendWidget t(plotWidget);
	t.move(point);
	t.setText(tr("enter your text here"));

	ApplicationWindow *app = plot()->multiLayer()->applicationWindow();
	if (app){		
		t.setFrameStyle(app->legendFrameStyle);
		t.setFont(app->plotLegendFont);
		t.setTextColor(app->legendTextColor);
		t.setBackgroundColor(app->legendBackground);
	}

	LegendWidget *l = plot()->insertText(&t);
	l->setSelected();
	l->showTextDialog();

	plot()->drawText(FALSE);
	emit drawTextOff();
}
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);
	}
}
示例#6
0
void Filter::showLegend()
{
	if (!d_output_graph)
		return;

	LegendWidget* legend = d_output_graph->legend();
	LegendWidget* l = d_output_graph->newLegend(legendInfo());
	if (legend)
		l->move(QPoint(legend->x(), legend->y() + legend->height() + 20));
}
	foreach(QWidget *i, d_widgets){
		LegendWidget *l = qobject_cast<LegendWidget *>(i);
		if (!l){
			QRect r = operateOn(i->geometry());
			i->setGeometry(r);

			FrameWidget *f = qobject_cast<FrameWidget *>(i);
			if (f)
				f->updateCoordinates();
			continue;
		}

		QRect new_rect = operateOn(l->geometry());
		l->move(new_rect.topLeft());
		if (!l->text().isEmpty()){
            QFont f = l->font();
            f.setPointSize(f.pointSize() * new_rect.width() * new_rect.height()/(l->rect().width() * l->rect().height()));
            l->setFont(f);
            l->plot()->notifyFontChange(f);
		}
	}
示例#8
0
void EnrichmentDialog::setWidget(QWidget *w)
{
	if (!w || !d_app)
		return;

	d_widget = w;

    FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget);
    if (fw){
	#ifndef QT_MAC_USE_COCOA
		if (d_plot)
			d_plot->deselectMarker();
	#endif

		frameBox->blockSignals(true);
        frameBox->setCurrentIndex(fw->frameStyle());
		frameBox->blockSignals(false);

		frameColorBtn->blockSignals(true);
        frameColorBtn->setColor(fw->frameColor());
		frameColorBtn->blockSignals(false);

		boxFrameLineStyle->blockSignals(true);
		boxFrameLineStyle->setStyle(fw->framePen().style());
		boxFrameLineStyle->blockSignals(false);

		boxFrameWidth->blockSignals(true);
		if (d_widget_type == Ellipse)
			boxFrameWidth->setValue(fw->framePen().widthF());
		else
			boxFrameWidth->setValue(fw->framePen().width());
		boxFrameWidth->blockSignals(false);

		unitBox->setCurrentIndex(d_app->d_frame_geometry_unit);
		attachToBox->setCurrentIndex((int)fw->attachPolicy());
		displayCoordinates(d_app->d_frame_geometry_unit);
    } else {
		unitBox->setCurrentIndex(FrameWidget::Pixel);
		displayCoordinates(FrameWidget::Pixel);
	}

	if (d_widget_type == Text){
		LegendWidget *l = qobject_cast<LegendWidget *>(d_widget);
		if (l){
			setText(textEditBox, l->text());
			textFont = l->font();
			QFont fnt = textFont;
			fnt.setPointSize(QFont().pointSize() + 2);
			textEditBox->setFont(fnt);
			textColorBtn->blockSignals(true);
			textColorBtn->setColor(l->textColor());
			textColorBtn->blockSignals(false);

			QColor bc = l->backgroundColor();
			boxBackgroundTransparency->blockSignals(true);
			boxBackgroundTransparency->setValue(100*bc.alphaF());
			boxBackgroundTransparency->blockSignals(false);

			transparencySlider->blockSignals(true);
			transparencySlider->setValue(boxBackgroundTransparency->value());
			transparencySlider->blockSignals(false);

			textBackgroundBtn->blockSignals(true);
			textBackgroundBtn->setEnabled(bc.alpha());
			bc.setAlpha(255);
			textBackgroundBtn->setColor(bc);
			textBackgroundBtn->blockSignals(false);

			boxTextAngle->blockSignals(true);
            boxTextAngle->setValue(l->angle());
			boxTextAngle->blockSignals(false);
			autoUpdateTextBox->setChecked(l->isAutoUpdateEnabled());
			texOutputBox->setChecked(l->hasTeXOutput());
			updateButtons();
		}
	} else if (d_widget_type == Tex){
		TexWidget *tw = qobject_cast<TexWidget *>(d_widget);
		if (tw){
			setText(equationEditor, tw->formula());
			outputLabel->setPixmap(tw->pixmap());
			bestSizeButton->show();
		}
		return;
	} else if (d_widget_type == Image){
		ImageWidget *i = qobject_cast<ImageWidget *>(d_widget);
		if (i){
			imagePathBox->setText(i->fileName());
			boxSaveImagesInternally->blockSignals(true);
			boxSaveImagesInternally->setChecked(i->saveInternally());
			boxSaveImagesInternally->blockSignals(false);

			bestSizeButton->show();
		}
	} else if (d_widget_type == Frame || d_widget_type == Ellipse){
		QColor bc = fw->backgroundColor();

		boxTransparency->blockSignals(true);
		boxTransparency->setValue(100.0*bc.alphaF());
		boxTransparency->blockSignals(false);

		fillTransparencySlider->blockSignals(true);
		fillTransparencySlider->setValue(boxTransparency->value());
		fillTransparencySlider->blockSignals(false);

		bc.setAlpha(255);
		backgroundColorBtn->blockSignals(true);
		backgroundColorBtn->setColor(bc);
		backgroundColorBtn->blockSignals(false);

		patternBox->blockSignals(true);
		patternBox->setPattern(fw->brush().style());
		patternBox->blockSignals(false);

		patternColorBtn->blockSignals(true);
		patternColorBtn->setColor(fw->brush().color());
		patternColorBtn->blockSignals(false);
	}
}
void EnrichmentDialog::setWidget(QWidget *w)
{
	if (!w)
		return;

	ApplicationWindow *app = (ApplicationWindow *)parent();
	if (!app)
		return;

	d_widget = w;

    FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget);
    if (fw){
		frameBox->blockSignals(true);
        frameBox->setCurrentIndex(fw->frameStyle());
		frameBox->blockSignals(false);

		frameColorBtn->blockSignals(true);
        frameColorBtn->setColor(fw->frameColor());
		frameColorBtn->blockSignals(false);

		boxFrameLineStyle->blockSignals(true);
		boxFrameLineStyle->setStyle(fw->framePen().style());
		boxFrameLineStyle->blockSignals(false);

		boxFrameWidth->blockSignals(true);
		if (d_widget_type == Ellipse)
			boxFrameWidth->setValue(fw->framePen().widthF());
		else
			boxFrameWidth->setValue(fw->framePen().width());
		boxFrameWidth->blockSignals(false);

		unitBox->setCurrentIndex(app->d_frame_geometry_unit);
		attachToBox->setCurrentIndex((int)fw->attachPolicy());
		displayCoordinates(app->d_frame_geometry_unit);
    } else {
		unitBox->setCurrentIndex(FrameWidget::Pixel);
		displayCoordinates(FrameWidget::Pixel);
	}

	if (d_widget_type == Text){
		LegendWidget *l = qobject_cast<LegendWidget *>(d_widget);
		if (l){
			setText(textEditBox, l->text());
			textFont = l->font();
			QFont fnt = textFont;
			fnt.setPointSize(QFont().pointSize() + 2);
			textEditBox->setFont(fnt);
			textColorBtn->blockSignals(true);
			textColorBtn->setColor(l->textColor());
			textColorBtn->blockSignals(false);

			QColor bc = l->backgroundColor();
			boxBackgroundTransparency->blockSignals(true);
			boxBackgroundTransparency->setValue(bc.alpha());
			boxBackgroundTransparency->blockSignals(false);

			textBackgroundBtn->blockSignals(true);
			textBackgroundBtn->setEnabled(bc.alpha());
			textBackgroundBtn->setColor(bc);
			textBackgroundBtn->blockSignals(false);

			boxTextAngle->blockSignals(true);
            boxTextAngle->setValue(l->angle());
			boxTextAngle->blockSignals(false);
			autoUpdateTextBox->setChecked(l->isAutoUpdateEnabled());
			texOutputBox->setChecked(l->hasTeXOutput());
		}
	} else if (d_widget_type == Tex){
		TexWidget *tw = qobject_cast<TexWidget *>(d_widget);
		if (tw){
			setText(equationEditor, tw->formula());
			outputLabel->setPixmap(tw->pixmap());
			bestSizeButton->show();
		}
		return;
	} else if (d_widget_type == Image){
		ImageWidget *i = qobject_cast<ImageWidget *>(d_widget);
		if (i){
			imagePathBox->setText(i->fileName());
			boxSaveImagesInternally->blockSignals(true);
			boxSaveImagesInternally->setChecked(i->saveInternally());
			boxSaveImagesInternally->blockSignals(false);
		}
	} else if (d_widget_type == Frame){
		RectangleWidget *r = qobject_cast<RectangleWidget *>(d_widget);
		if (r){
			backgroundColorBtn->blockSignals(true);
			backgroundColorBtn->setColor(r->backgroundColor());
			backgroundColorBtn->blockSignals(false);

			boxTransparency->blockSignals(true);
			boxTransparency->setValue(r->backgroundColor().alpha());
			boxTransparency->blockSignals(false);

			patternBox->blockSignals(true);
			patternBox->setPattern(r->brush().style());
			patternBox->blockSignals(false);

			patternColorBtn->blockSignals(true);
			patternColorBtn->setColor(r->brush().color());
			patternColorBtn->blockSignals(false);
		}
	} else if (d_widget_type == Ellipse){
		EllipseWidget *r = qobject_cast<EllipseWidget *>(d_widget);
		if (r){
			backgroundColorBtn->blockSignals(true);
			backgroundColorBtn->setColor(r->backgroundColor());
			backgroundColorBtn->blockSignals(false);

			boxTransparency->blockSignals(true);
			boxTransparency->setValue(r->backgroundColor().alpha());
			boxTransparency->blockSignals(false);

			patternBox->blockSignals(true);
			patternBox->setPattern(r->brush().style());
			patternBox->blockSignals(false);

			patternColorBtn->blockSignals(true);
			patternColorBtn->setColor(r->brush().color());
			patternColorBtn->blockSignals(false);
		}
	}
}
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);
	}
}