void ccColorScaleEditorDialog::setActiveScale(ccColorScale::Shared currentScale) { //the user wants to change the current scale while the it has been modified (and potentially not saved) if (m_colorScale != currentScale) { if (!canChangeCurrentScale()) { //restore old combo-box state int pos = rampComboBox->findData(m_colorScale->getUuid()); if (pos >= 0) { rampComboBox->blockSignals(true); rampComboBox->setCurrentIndex(pos); rampComboBox->blockSignals(false); } else { assert(false); } //stop process return; } } m_colorScale = currentScale; setModified(false); //make sure combo-box is up to date { int pos = rampComboBox->findData(m_colorScale->getUuid()); if (pos >= 0) { rampComboBox->blockSignals(true); rampComboBox->setCurrentIndex(pos); rampComboBox->blockSignals(false); } } //setup dialog components { //locked state bool isLocked = !m_colorScale || m_colorScale->isLocked(); colorScaleParametersFrame->setEnabled(!isLocked); exportToolButton->setEnabled(!isLocked); lockWarningLabel->setVisible(isLocked); selectedSliderGroupBox->setEnabled(!isLocked); m_scaleWidget->setEnabled(!isLocked); customLabelsGroupBox->blockSignals(true); customLabelsGroupBox->setEnabled(!isLocked); customLabelsGroupBox->blockSignals(false); //absolute or relative mode if (m_colorScale) { bool isRelative = m_colorScale->isRelative(); if (!isRelative) { //absolute color scales defines their own boundaries m_colorScale->getAbsoluteBoundaries(m_minAbsoluteVal,m_maxAbsoluteVal); } setScaleModeToRelative(isRelative); } else { //shouldn't be accessible anyway.... assert(isLocked == true); setScaleModeToRelative(false); } } //custom labels { ccColorScale::LabelSet& customLabels = m_colorScale->customLabels(); if (customLabels.empty()) { customLabelsPlainTextEdit->blockSignals(true); customLabelsPlainTextEdit->setPlainText(s_defaultEmptyCustomListText); customLabelsPlainTextEdit->blockSignals(false); } else { QString text; size_t index = 0; for (ccColorScale::LabelSet::const_iterator it=customLabels.begin(); it!=customLabels.end(); ++it, ++index) { if (index != 0) text += QString("\n"); text += QString::number(*it,'f',6); } customLabelsPlainTextEdit->blockSignals(true); customLabelsPlainTextEdit->setPlainText(text); customLabelsPlainTextEdit->blockSignals(false); } customLabelsGroupBox->blockSignals(true); customLabelsGroupBox->setChecked(!customLabels.empty()); customLabelsGroupBox->blockSignals(false); } m_scaleWidget->importColorScale(m_colorScale); onStepSelected(-1); }
void ccColorScaleEditorDialog::setActiveScale(ccColorScale::Shared currentScale) { //the user wants to change the current scale while the it has been modified (and potentially not saved) if (m_colorScale != currentScale) { if (!canChangeCurrentScale()) { //restore old combo-box state int pos = rampComboBox->findData(m_colorScale->getUuid()); if (pos >= 0) { rampComboBox->blockSignals(true); rampComboBox->setCurrentIndex(pos); rampComboBox->blockSignals(false); } else { assert(false); } //stop process return; } } m_colorScale = currentScale; setModified(false); //make sure combo-box is up to date { int pos = rampComboBox->findData(m_colorScale->getUuid()); if (pos >= 0) { rampComboBox->blockSignals(true); rampComboBox->setCurrentIndex(pos); rampComboBox->blockSignals(false); } } //setup dialog components { //locked state bool isLocked = !m_colorScale || m_colorScale->isLocked(); colorScaleParametersFrame->setEnabled(!isLocked); lockWarningLabel->setVisible(isLocked); selectedSliderGroupBox->setEnabled(!isLocked); m_scaleWidget->setEnabled(!isLocked); //absolute or relative mode if (m_colorScale) { bool isRelative = m_colorScale->isRelative(); if (!isRelative) { //absolute color scales defines their own boundaries m_colorScale->getAbsoluteBoundaries(m_minAbsoluteVal,m_maxAbsoluteVal); } setScaleModeToRelative(isRelative); } else { //shouldn't be accessible anyway.... assert(isLocked == true); setScaleModeToRelative(false); } } m_scaleWidget->importColorScale(m_colorScale); onStepSelected(-1); }