Commit be4b0671 authored by Sebastien Jourdain's avatar Sebastien Jourdain
Browse files

Provide embedded Simple/Advanced dialog for ScalarBar customs

Change-Id: Ic536ebc09959f9761d828917872d80b7be83308a
parent d04e0578
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>604</width>
<height>463</height>
<width>633</width>
<height>595</height>
</rect>
</property>
<property name="windowTitle">
......@@ -923,6 +923,116 @@
</widget>
</widget>
</item>
<item>
<widget class="QWidget" name="SimplePanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="Container" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="CheckContainer2" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="UseLogScaleSimple">
<property name="text">
<string>Use Log Scaling</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="UseAutoRescaleSimple">
<property name="text">
<string>Automatic Color Scaling</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="ButtonContainer" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="PresetButtonSimple">
<property name="text">
<string>Choose Preset</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="RangeContainer" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelMin">
<property name="text">
<string>Minimum</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="SimpleMin">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelMax">
<property name="text">
<string>Maximum</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="SimpleMax">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......@@ -942,9 +1052,9 @@
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="pushButtonApply">
<widget class="QCheckBox" name="SwitchToAdvanced">
<property name="text">
<string>Apply</string>
<string>Advanced</string>
</property>
</widget>
</item>
......@@ -961,6 +1071,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonApply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="MakeDefaultButton">
<property name="text">
......
......@@ -287,6 +287,33 @@ pqColorScaleEditor::pqColorScaleEditor(QWidget *widgetParent)
//Hook up the MakeDefaultButton
this->connect(this->Form->MakeDefaultButton, SIGNAL(clicked()),
this, SLOT(makeDefault()));
// =========================
// Simple UI add-on
// =========================
this->connect( this->Form->SwitchToAdvanced, SIGNAL(toggled(bool)),
this, SLOT(enableAvancedPanel(bool)));
this->enableAvancedPanel(this->Form->SwitchToAdvanced->isChecked());
this->connect( this->Form->UseLogScaleSimple, SIGNAL(toggled(bool)),
this, SLOT(setLogScale(bool)));
this->connect( this->Form->PresetButtonSimple, SIGNAL(clicked()),
this, SLOT(loadPreset()));
this->connect( this->Form->UseAutoRescaleSimple, SIGNAL(toggled(bool)),
this, SLOT(setAutoRescale(bool)));
this->connect( this->Form->SimpleMin, SIGNAL(editingFinished()),
this, SLOT(rescaleToSimpleRange()));
this->connect( this->Form->SimpleMax, SIGNAL(editingFinished()),
this, SLOT(rescaleToSimpleRange()));
// Make sure the line edits only allow number inputs.
QDoubleValidator* validator = new QDoubleValidator(this);
this->Form->SimpleMin->setValidator(validator);
this->Form->SimpleMax->setValidator(validator);
}
pqColorScaleEditor::~pqColorScaleEditor()
......@@ -1026,6 +1053,11 @@ void pqColorScaleEditor::loadPreset()
void pqColorScaleEditor::setLogScale(bool on)
{
// Make sure both UI widget are in sync
this->Form->UseLogScale->setChecked(on);
this->Form->UseLogScaleSimple->setChecked(on);
// Do the real job
this->renderTransferFunctionViews();
vtkSMProxy *lookupTable = this->ColorMap->getProxy();
......@@ -1042,6 +1074,13 @@ void pqColorScaleEditor::setLogScale(bool on)
void pqColorScaleEditor::setAutoRescale(bool on)
{
// Make sure both UI widget are in sync
this->Form->UseAutoRescale->setChecked(on);
this->Form->UseAutoRescaleSimple->setChecked(on);
this->Form->SimpleMin->setEnabled(!on);
this->Form->SimpleMax->setEnabled(!on);
// Do the real job
this->enableRescaleControls(!on);
this->ColorMap->setScalarRangeLock(!on);
this->enablePointControls();
......@@ -1052,6 +1091,29 @@ void pqColorScaleEditor::setAutoRescale(bool on)
}
}
//-----------------------------------------------------------------------------
void pqColorScaleEditor::rescaleToSimpleRange()
{
if(!this->Form->UseAutoRescaleSimple->isChecked() && !this->Form->SwitchToAdvanced->isChecked())
{
bool okMin = true, okMax = true;
double min = this->Form->SimpleMin->text().toDouble(&okMin);
double max = this->Form->SimpleMax->text().toDouble(&okMax);
if(okMin && okMax)
{
QPair<double, double> range;
this->Form->InSetColors = true;
this->unsetCurrentPoints();
this->setScalarRange(min, max);
this->Form->InSetColors = false;
range = this->ColorMap->getScalarRange();
this->updateScalarRange(range.first, range.second);
this->updateCurrentColorPoint();
}
}
}
//-----------------------------------------------------------------------------
void pqColorScaleEditor::rescaleToNewRange()
{
// Launch the rescale range dialog to get the new range.
......@@ -1449,6 +1511,14 @@ void pqColorScaleEditor::initColorScale()
this->Form->UseAutoRescale->blockSignals(false);
this->enableRescaleControls(!this->Form->UseAutoRescale->isChecked());
// Handle simple UI
this->Form->UseAutoRescaleSimple->blockSignals(true);
this->Form->UseAutoRescaleSimple->setChecked(
!this->ColorMap->getScalarRangeLock());
this->Form->UseAutoRescaleSimple->blockSignals(false);
this->Form->SimpleMin->setEnabled(!this->Form->UseAutoRescale->isChecked());
this->Form->SimpleMax->setEnabled(!this->Form->UseAutoRescale->isChecked());
// Set up the color table size elements.
vtkSMProxy *lookupTable = this->ColorMap->getProxy();
int tableSize = pqSMAdaptor::getElementProperty(
......@@ -1572,6 +1642,8 @@ void pqColorScaleEditor::updateScalarRange(double min, double max)
// Update the spin box ranges and set the values.
this->Form->MinimumLabel->setText(QString::number(min, 'g', 6));
this->Form->MaximumLabel->setText(QString::number(max, 'g', 6));
this->Form->SimpleMin->setText(QString::number(min, 'g', 6));
this->Form->SimpleMax->setText(QString::number(max, 'g', 6));
double chartBounds[8];
// Update the editor scalar range.
......@@ -2084,7 +2156,8 @@ void pqColorScaleEditor::saveOptionalUserSettings()
settings->remove("");
settings->setValue("ImmediateRender", QVariant(
this->Form->checkBoxImmediateRender->isChecked()));
settings->setValue("AdvancedPanel", QVariant(
this->Form->SwitchToAdvanced->isChecked()));
settings->endGroup();
}
......@@ -2098,9 +2171,13 @@ void pqColorScaleEditor::restoreOptionalUserSettings()
{
if(*key == "ImmediateRender")
{
int checked = settings->value(*key).toInt();
bool checked = settings->value(*key).toBool();
this->Form->checkBoxImmediateRender->setChecked(checked);
break;
}
if(*key == "AdvancedPanel")
{
bool checked = settings->value(*key).toBool();
this->Form->SwitchToAdvanced->setChecked(checked);
}
}
......@@ -2171,3 +2248,17 @@ void pqColorScaleEditor::updateOpacity()
this->updateCurrentOpacityPoint();
this->pushOpacity();
}
// ----------------------------------------------------------------------------
void pqColorScaleEditor::enableAvancedPanel(bool checked)
{
// Collapse
this->Form->ColorTabs->setVisible(false);
this->Form->SimplePanel->setVisible(false);
// Expand eventually
this->Form->ColorTabs->setVisible(checked);
this->Form->SimplePanel->setVisible(!checked);
// Adjust size
this->adjustSize();
}
......@@ -100,6 +100,7 @@ private slots:
void rescaleToNewRange();
void rescaleToDataRange();
void rescaleToDataRangeOverTime();
void rescaleToSimpleRange();
void setUseDiscreteColors(bool on);
void setSizeFromText();
......@@ -141,6 +142,8 @@ private slots:
void saveOptionalUserSettings();
void restoreOptionalUserSettings();
// Advanced/Simple management
void enableAvancedPanel(bool);
private:
void loadBuiltinColorPresets();
void loadColorPoints();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment