예제 #1
0
void Spectrogram::updateLabels(QPainter *p, const QwtScaleMap &, const QwtScaleMap &,
		const QwtRasterData::ContourLines &contourLines) const
{
	QwtValueList levels = contourLevels();
	const int numLevels = levels.size();
	int x_axis = xAxis();
	int y_axis = yAxis();
	for (int l = 0; l < numLevels; l++){
		const double level = levels[l];
		const QPolygonF &lines = contourLines[level];
		if (lines.isEmpty())
			continue;

		PlotMarker *mrk = d_labels_list[l];
		if (!mrk)
			return;

		QSize size = mrk->label().textSize();
		int dx = int((d_labels_x_offset + mrk->xLabelOffset())*0.01*size.height());
		int dy = -int(((d_labels_y_offset + mrk->yLabelOffset())*0.01 + 0.5)*size.height());

		int i = (int)lines.size()/2;
		double x = lines[i].x();
		double y = lines[i].y();

		int x2 = d_graph->transform(x_axis, x) + dx;
		int y2 = d_graph->transform(y_axis, y) + dy;

		if (p->device()->logicalDpiX() == plot()->logicalDpiX() ||
			p->device()->logicalDpiY() == plot()->logicalDpiY())
			mrk->setValue(d_graph->invTransform(x_axis, x2),
							d_graph->invTransform(y_axis, y2));
	}
}
예제 #2
0
Spectrogram* Spectrogram::copy(Graph *g)
{
	Spectrogram *new_s = new Spectrogram(g, matrix());
	new_s->setDisplayMode(QwtPlotSpectrogram::ImageMode, testDisplayMode(QwtPlotSpectrogram::ImageMode));
	new_s->setDisplayMode(QwtPlotSpectrogram::ContourMode, testDisplayMode(QwtPlotSpectrogram::ContourMode));
	new_s->setCustomColorMap(color_map);
	new_s->setAxis(xAxis(), yAxis());
	new_s->setDefaultContourPen(defaultContourPen());
	new_s->color_map_policy = color_map_policy;
	new_s->d_show_labels = d_show_labels;
	new_s->d_labels_angle = d_labels_angle;
	new_s->d_labels_color = d_labels_color;
	new_s->d_white_out_labels = d_white_out_labels;
	new_s->d_labels_font = d_labels_font;
	new_s->d_labels_x_offset = d_labels_x_offset;
	new_s->d_labels_y_offset = d_labels_y_offset;

	new_s->setContourLevels(contourLevels());

	if (defaultContourPen().style() == Qt::NoPen && !d_color_map_pen)
		new_s->setContourPenList(d_pen_list);
	else
		new_s->d_color_map_pen = d_color_map_pen;

	QList <PlotMarker *> lst = new_s->labelsList();
	int count = lst.size();
	for(int i = 0; i < count; i++){
		PlotMarker *m = lst[i];
		PlotMarker *mrk = d_labels_list[i];
		if (m && mrk)
			m->setLabelOffset(mrk->xLabelOffset(), mrk->yLabelOffset());
	}
	return new_s;
}