Ejemplo n.º 1
0
QImage CurveTransform::transform() {
	for(unsigned int i = 0; i < image_width; i++) {
		for(unsigned int j = 0; j < image_height; j++) {
			CartesianPair coords = {i, j};
			drawPixels(convertToPixels(convertToCartesian(convertToPolar(coords))),coords); //Lisp, eat your heart out
		}
	}
	return out_image;	
}
Ejemplo n.º 2
0
void LayerDialog::update()
{
	if (!multi_layer){
		ApplicationWindow *app = (ApplicationWindow *)this->parent();
		multi_layer = app->multilayerPlot(1, -1, app->defaultCurveStyle, MultiLayer::AlignLayers);
		QList<Graph *> layersList = multi_layer->layersList();
		foreach(Graph *g, layersList)
			g->removeLegend();
	}

	int graphs = layersBox->value();
	int old_graphs = multi_layer->numLayers();
	int dn = multi_layer->numLayers() - graphs;
	if (dn > 0 && QMessageBox::question(0, tr("QtiPlot - Delete Layers?"),
				tr("You are about to delete %1 existing layers.").arg(dn)+"\n"+
				tr("Are you sure you want to continue this operation?"),
				tr("&Continue"), tr("&Cancel"), QString(), 0, 1 )) return;

	multi_layer->setNumLayers(graphs);

	if (!graphs)
		return;

	if (dn < 0){// Customize new layers with user default settings
		ApplicationWindow *app = (ApplicationWindow *)this->parent();
		for (int i = old_graphs+1; i <= graphs; i++)
			app->setPreferences(multi_layer->layer(i));
	}

	int cols = boxX->value();
	int rows = boxY->value();

	if (cols>graphs && !fitBox->isChecked()){
		QMessageBox::about(this, tr("QtiPlot - Columns input error"),
				tr("The number of columns you've entered is greater than the number of graphs (%1)!").arg(graphs));
		boxX->setFocus();
		return;
	}

	if (rows>graphs && !fitBox->isChecked()){
		QMessageBox::about(this, tr("QtiPlot - Rows input error"),
				tr("The number of rows you've entered is greater than the number of graphs (%1)!").arg(graphs));
		boxY->setFocus();
		return;
	}

	if (!fitBox->isChecked()){
		multi_layer->setCols(cols);
		multi_layer->setRows(rows);
	}

	FrameWidget::Unit unit = (FrameWidget::Unit)unitBox->currentIndex();
	if (GroupCanvasSize->isChecked()){
		ApplicationWindow *app = multi_layer->applicationWindow();
		if (app)
			app->d_layer_geometry_unit = unitBox->currentIndex();

		multi_layer->setLayerCanvasSize(convertToPixels(boxCanvasWidth->value(), unit, 0), convertToPixels(boxCanvasHeight->value(), unit, 1));
	}

	if (commonAxesBox->isVisible() && commonAxesBox->isChecked())
		multi_layer->setCommonLayerAxes(boxColsGap->value() == 0, boxRowsGap->value() == 0);

	multi_layer->setAlignement(alignHorBox->currentItem(), alignVertBox->currentItem());

	multi_layer->setMargins(boxLeftSpace->value(), boxRightSpace->value(),
			boxTopSpace->value(), boxBottomSpace->value());

	multi_layer->setScaleLayersOnResize(!fixedSizeBox->isChecked());
	multi_layer->linkXLayerAxes(linkXAxesBox->isChecked());

	multi_layer->setAlignPolicy((MultiLayer::AlignPolicy)alignPolicyBox->currentIndex());
	multi_layer->setSpacing(boxRowsGap->value(), boxColsGap->value());
	multi_layer->arrangeLayers(fitBox->isChecked(), GroupCanvasSize->isChecked());
	if (!buttonApply){
		QList<Graph *> layersList = multi_layer->layersList();
		foreach(Graph *g, layersList)
			g->newLegend();
	}

	if (!GroupCanvasSize->isChecked()){//show new layer canvas size
		boxCanvasWidth->blockSignals(true);
		boxCanvasWidth->setValue(convertFromPixels(multi_layer->layerCanvasSize().width(), unit, 0));
		boxCanvasWidth->blockSignals(false);

		boxCanvasHeight->blockSignals(true);
		boxCanvasHeight->setValue(convertFromPixels(multi_layer->layerCanvasSize().height(), unit, 1));
		boxCanvasHeight->blockSignals(false);
	}

	if (fitBox->isChecked()){//show new grid settings
		boxX->setValue(multi_layer->getCols());
		boxY->setValue(multi_layer->getRows());
	}
}