Esempio n. 1
0
// Change the colormap to match new exponent value
void ColorBarWidget::changedExponent(double nth_power)
{
    m_colorMap.setNthPower(nth_power);
    updateColorMap();

    emit changedColorRange(m_min,m_max,m_log);
}
void ColorMapEditor::insertLevel()
{
int row = table->currentRow();
QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);

double val = 0.5*(table->item(row, 0)->text().toDouble() + table->item(row - 1, 0)->text().toDouble());
double mapped_val = (val - min_val)/range.width();
QColor c = QColor(color_map.rgb(QwtDoubleInterval(0, 1), mapped_val));

table->blockSignals(true);
table->insertRow(row);

QTableWidgetItem *it = new QTableWidgetItem(QString::number(val));
table->setItem(row, 0, it);
		
it = new QTableWidgetItem(c.name());
it->setFlags(Qt::ItemFlags(!Qt::ItemIsEditable));
it->setBackground(QBrush(c));
it->setForeground(QBrush(c));
table->setItem(row, 1, it);
table->blockSignals(false);
	
enableButtons(table->currentRow(), 0);
updateColorMap();
}
Esempio n. 3
0
/** Set the color bar to use log scale
 *
 * @param log :: true to use log scale
 */
void ColorBarWidget::setLog(bool log)
{
  m_log = log;
  m_colorMap.changeScaleType( m_log ? GraphOptions::Log10 : GraphOptions::Linear );
  ui.checkLog->setChecked( m_log );
  ui.valMin->setLogSteps( m_log );
  ui.valMax->setLogSteps( m_log );
  setSpinBoxesSteps();
  updateColorMap();
}
Esempio n. 4
0
/** SLOT called when maxValue changes */
void ColorBarWidget::changedMaximum()
{
    m_max = ui.valMax->value();
    if (m_max < m_min)
    {
        m_min = m_max-0.001;
        ui.valMin->setValue( m_min );
    }
    updateColorMap();
    emit changedColorRange(m_min,m_max,m_log);
}
Esempio n. 5
0
/*
 * Update display if different scale type is selected
 */
void ColorBarWidget::changedScaleType(int type)
{
    // If power scale option is selected, enable "n =" widget
    ui.dspnN->setEnabled(type == 2);

    // Record if log scale option is selected
    m_log = (type == 1);

    m_colorMap.changeScaleType( GraphOptions::ScaleType(type) );
    ui.valMin->setLogSteps( m_log );
    ui.valMax->setLogSteps( m_log );
    setSpinBoxesSteps();
    updateColorMap();

    emit changedColorRange(m_min,m_max,m_log);
}
void ColorMapEditor::showColorDialog(int row, int col)
{
if (col != 1)
	return;

QColor c = QColor(table->item(row, 1)->text());
QColor color = QColorDialog::getColor(c, this);
if (!color.isValid() || color == c)
	return;

table->item(row, 1)->setText(color.name());
table->item(row, 1)->setForeground(QBrush(color));
table->item(row, 1)->setBackground(QBrush(color));

updateColorMap();
}
void ColorMapEditor::insertLevel()
{
  int row = table->currentRow();
  DoubleSpinBox *sb = (DoubleSpinBox*)table->cellWidget(row, 0);
  if (!sb)
    return;

  double current_value = sb->value();
  double previous_value = min_val;
  sb = (DoubleSpinBox*)table->cellWidget(row - 1, 0);
  if (sb)
    previous_value = sb->value();

  double val = 0.5*(current_value + previous_value);
  QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);
  double mapped_val = (val - min_val)/range.width();

  QColor c = QColor(color_map.rgb(QwtDoubleInterval(0, 1), mapped_val));

  table->blockSignals(true);
  table->insertRow(row);

  sb = new DoubleSpinBox();
  sb->setLocale(d_locale);
  sb->setDecimals(d_precision);
  sb->setValue(val);
  sb->setRange(min_val, max_val);
  connect(sb, SIGNAL(valueChanged(double)), this, SLOT(updateColorMap()));
  connect(sb, SIGNAL(activated(DoubleSpinBox *)), this, SLOT(spinBoxActivated(DoubleSpinBox *)));
  table->setCellWidget(row, 0, sb);

  QTableWidgetItem *it = new QTableWidgetItem(c.name());
// Avoid compiler warning
//#ifdef Q_CC_MSVC
  it->setFlags(it->flags() & (~Qt::ItemIsEditable));
//#else
//  it->setFlags(!Qt::ItemIsEditable);
//#endif
  it->setBackground(QBrush(c));
  it->setForeground(QBrush(c));
  table->setItem(row, 1, it);
  table->blockSignals(false);

  enableButtons(table->currentRow());
  updateColorMap();
}
void ColorMapEditor::deleteLevel()
{
  table->removeRow (table->currentRow());
  enableButtons(table->currentRow());
  updateColorMap();
}
Esempio n. 9
0
//-------------------------------------------------------------------------------------------------
/// Event called after resizing
void ColorBarWidget::resizeEvent(QResizeEvent * event)
{
    updateColorMap();
    QWidget::resizeEvent(event);
}
/**
 * Sets the state of the "Autoscale" checkbox
 * @param autoscale :: [input] Autoscale on/off
 */
void ColorBarWidget::setAutoScale(bool autoscale) {
  ui.autoScale->setChecked(autoscale);
  updateColorMap();
}