MatrixSetColorMapCommand::MatrixSetColorMapCommand(Matrix *m, Matrix::ColorMapType type_before, const QwtLinearColorMap& map_before, Matrix::ColorMapType type_after, const QwtLinearColorMap& map_after, const QString & text): QUndoCommand(text), d_matrix(m), d_map_type_before(type_before), d_map_type_after(type_after) { setText(m->objectName() + ": " + text); d_map_before = QwtLinearColorMap(map_before); d_map_after = QwtLinearColorMap(map_after); }
void Matrix::initGlobals() { d_workspace = NULL; d_table_view = NULL; imageLabel = NULL; d_header_view_type = ColumnRow; d_color_map_type = GrayScale; d_color_map = QwtLinearColorMap(Qt::black, Qt::white); d_column_width = 100; formula_str = ""; txt_format = 'f'; num_precision = 6; x_start = 1.0; x_end = 10.0; y_start = 1.0; y_end = 10.0; d_stack = new QStackedWidget(); d_stack->setFocusPolicy(Qt::StrongFocus); setWidget(d_stack); d_undo_stack = new QUndoStack(); d_undo_stack->setUndoLimit(applicationWindow()->matrixUndoStackSize()); }
Spectrogram::Spectrogram(Graph *graph, Matrix *m): QwtPlotSpectrogram(QString(m->objectName())), d_graph(graph), d_matrix(m), color_axis(QwtPlot::yRight), color_map_policy(Default), color_map(QwtLinearColorMap()), d_show_labels(true), d_labels_color(Qt::black), d_labels_font(QFont()), d_white_out_labels(false), d_labels_angle(0.0), d_labels_x_offset(0), d_labels_y_offset(0), d_selected_label(NULL), d_use_matrix_formula(false), d_color_map_pen(false), d_impose_range(false) { setData(MatrixData(m)); double step = fabs(data().range().maxValue() - data().range().minValue())/5.0; QwtValueList contourLevels; for ( double level = data().range().minValue() + step; level < data().range().maxValue(); level += step ) contourLevels += level; setContourLevels(contourLevels); }
void Matrix::setGrayScale() { d_color_map_type = GrayScale; d_color_map = QwtLinearColorMap(Qt::black, Qt::white); if (d_view_type == ImageView) displayImage(d_matrix_model->renderImage()); emit modifiedWindow(this); }
Spectrogram::Spectrogram(): QwtPlotSpectrogram(), d_matrix(0), color_axis(QwtPlot::yRight), color_map_policy(Default), color_map(QwtLinearColorMap()) { }
SectionWindow::SectionWindow(QWidget *parent): QMainWindow(parent) { m_data = new RasterData(); m_plot = new QwtPlot(parent); m_spect = new QwtPlotSpectrogram(); m_spect->setColorMap(QwtLinearColorMap(Qt::darkCyan, Qt::red)); m_spect->setData(*m_data); m_spect->attach(m_plot); m_plot->axisWidget(QwtPlot::xBottom)->setTitle("Band (index)"); m_plot->axisWidget(QwtPlot::yLeft)->setTitle("Arclength (pixel)"); m_plot->setMargin(5); // A color bar on the right axis QwtScaleWidget *rightAxis = m_plot->axisWidget(QwtPlot::yRight); rightAxis->setTitle("Intensity"); rightAxis->setColorBarEnabled(true); m_plot->enableAxis(QwtPlot::yRight); m_plot->plotLayout()->setAlignCanvasToScales(true); m_plot->replot(); // LeftButton for the zooming // MidButton for the panning // RightButton: zoom out by 1 // Ctrl+RighButton: zoom out to full size m_zoomer = new MyZoomer(this, m_plot->canvas()); m_zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); m_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); const QColor c(Qt::darkBlue); m_zoomer->setRubberBandPen(c); m_zoomer->setTrackerPen(c); QwtPlotPanner *panner = new QwtPlotPanner(m_plot->canvas()); panner->setAxisEnabled(QwtPlot::yRight, false); panner->setMouseButton(Qt::MidButton); // Avoid jumping when labels with more/less digits // appear/disappear when scrolling vertically const QFontMetrics fm(m_plot->axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw *sd = m_plot->axisScaleDraw(QwtPlot::yLeft); sd->setMinimumExtent( fm.width("100.00") ); setCentralWidget(m_plot); }
void Matrix::setRainbowColorMap() { d_color_map_type = Rainbow; d_color_map = QwtLinearColorMap(Qt::blue, Qt::red); d_color_map.addColorStop(0.25, Qt::cyan); d_color_map.addColorStop(0.5, Qt::green); d_color_map.addColorStop(0.75, Qt::yellow); if (d_view_type == ImageView) displayImage(d_matrix_model->renderImage()); emit modifiedWindow(this); }
void Spectrogram::setGrayScale() { color_map = QwtLinearColorMap(Qt::black, Qt::white); setColorMap(color_map); color_map_policy = GrayScale; if (!d_graph) return; QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis); if (colorAxis) colorAxis->setColorMap(range(), colorMap()); }
ColorMapEditor::ColorMapEditor(const QLocale& locale, int precision, QWidget* parent) : QWidget(parent), color_map(QwtLinearColorMap()), min_val(0), max_val(1), d_locale(locale), d_precision(precision) { table = new QTableWidget(); table->setColumnCount(2); table->setSelectionMode(QAbstractItemView::SingleSelection); table->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); table->verticalHeader()->hide(); table->horizontalHeader()->setClickable( false ); table->horizontalHeader()->setResizeMode(0, QHeaderView::Interactive); table->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); table->horizontalHeader()->setStretchLastSection(true); table->viewport()->setMouseTracking(true); table->viewport()->installEventFilter(this); table->setHorizontalHeaderLabels(QStringList() << tr("Level") << tr("Color")); table->setMinimumHeight(6*table->horizontalHeader()->height() + 2); table->installEventFilter(this); connect(table, SIGNAL(cellClicked (int, int)), this, SLOT(showColorDialog(int, int))); insertBtn = new QPushButton(tr("&Insert")); insertBtn->setEnabled(false); connect(insertBtn, SIGNAL(clicked()), this, SLOT(insertLevel())); deleteBtn = new QPushButton(tr("&Delete")); deleteBtn->setEnabled(false); connect(deleteBtn, SIGNAL(clicked()), this, SLOT(deleteLevel())); QHBoxLayout* hb = new QHBoxLayout(); hb->addWidget(insertBtn); hb->addWidget(deleteBtn); scaleColorsBox = new QCheckBox(tr("&Scale Colors")); scaleColorsBox->setChecked(true); connect(scaleColorsBox, SIGNAL(toggled(bool)), this, SLOT(setScaledColors(bool))); QVBoxLayout* vl = new QVBoxLayout(this); vl->setSpacing(0); vl->addWidget(table); vl->addLayout(hb); vl->addWidget(scaleColorsBox); setFocusProxy(table); setMaximumWidth(200); }
void Spectrogram::setGrayScale() { color_map = QwtLinearColorMap(Qt::black, Qt::white); setColorMap(color_map); color_map_policy = GrayScale; QwtPlot *plot = this->plot(); if (!plot) return; QwtScaleWidget *colorAxis = plot->axisWidget(color_axis); if (colorAxis) colorAxis->setColorMap(data().range(), colorMap()); }
Spectrogram::Spectrogram(Matrix *m): QwtPlotSpectrogram(QString(m->objectName())), d_matrix(m), color_axis(QwtPlot::yRight), color_map_policy(Default), color_map(QwtLinearColorMap()) { setData(MatrixData(m)); double step = fabs(data().range().maxValue() - data().range().minValue())/5.0; QwtValueList contourLevels; for ( double level = data().range().minValue() + step; level < data().range().maxValue(); level += step ) contourLevels += level; setContourLevels(contourLevels); }
void Matrix::setColorMap(const QStringList& lst) { d_color_map_type = Custom; QStringList::const_iterator line = lst.begin(); QString s = (*line).stripWhiteSpace(); int mode = s.remove("<Mode>").remove("</Mode>").stripWhiteSpace().toInt(); s = *(++line); QColor color1 = QColor(s.remove("<MinColor>").remove("</MinColor>").stripWhiteSpace()); s = *(++line); QColor color2 = QColor(s.remove("<MaxColor>").remove("</MaxColor>").stripWhiteSpace()); d_color_map = QwtLinearColorMap(color1, color2); d_color_map.setMode((QwtLinearColorMap::Mode)mode); s = *(++line); int stops = s.remove("<ColorStops>").remove("</ColorStops>").stripWhiteSpace().toInt(); for (int i = 0; i < stops; i++){ s = (*(++line)).stripWhiteSpace(); QStringList l = QStringList::split("\t", s.remove("<Stop>").remove("</Stop>")); d_color_map.addColorStop(l[0].toDouble(), QColor(l[1])); } }