now qualitymapper ramps may be flipped, plus minor other changes.

Some work still needed to make process easier and more coherent.
PENDING BUG: if mesh has no vertex color, VC is allocated and filled, but the rendering is not updated
This commit is contained in:
Marco Callieri mcallieri 2016-10-21 14:31:59 +00:00
parent c1fc294db5
commit ee34f28d39
5 changed files with 107 additions and 67 deletions

View File

@ -214,6 +214,15 @@ bool TfChannel::isTail(TF_KEY *key)
return ( key->x == 1.0f );
}
void TfChannel::flip()
{
for (KEY_LISTiterator it = KEYS.begin(); it != KEYS.end(); it++)
(*it)->x = 1.0 - (*it)->x;
this->updateKeysOrder();
}
//this method is called by TFHandle and is used to update the TfHandle position from graphics to logical level.
//When the key value is updated, the keys list must be checked to restore the sorting and the right alternation of LEFT\RIGHT JUNCTION SIDE keys
void TfChannel::updateKeysOrder()
@ -541,6 +550,15 @@ Color4b TransferFunction::getColorByQuality (float absoluteQuality, float minQua
return currentColor;
}
void TransferFunction::flipRamp()
{
//for each channel...
for (size_t i = 0; i<NUMBER_OF_CHANNELS; i++)
{
_channels[i].flip();
}
}
//saves the current color band onto an external file
//moreover it saves info about the equalizer state
//returns the name of the file

View File

@ -131,6 +131,7 @@ public:
TF_KEY *addKey(TF_KEY *newKey);
void removeKey(int index);
void removeKey(TF_KEY *key);
void flip();
float getChannelValuef(float x_position);
UINT8 getChannelValueb(float x_position);
@ -212,6 +213,7 @@ public:
TfChannel& operator [](int i) { return _channels[_channels_order[i]]; }
size_t size();
QColor* buildColorBand(void);
void flipRamp();
QString saveColorBand(QString fileName, EQUALIZER_INFO& equalizerInfo);
vcg::Color4b getColorByQuality(float percentageQuality);
vcg::Color4b getColorByQuality(float absoluteQuality, float minQuality, float maxQuality, float midRelativeQuality, float brightness);

View File

@ -775,6 +775,23 @@ void QualityMapperDialog::drawTransferFunctionBG ()
}
}
//callback for flip button click
void QualityMapperDialog::on_flipButton_clicked()
{
// flip values in ramp
_transferFunction->flipRamp();
//preparing TF to work
this->initTF();
//drawing new TF
this->drawTransferFunction();
//applying preview if necessary
if (ui.previewButton->isChecked())
on_applyButton_clicked();
}
//callback for save button click
void QualityMapperDialog::on_savePresetButton_clicked()
{

View File

@ -215,6 +215,7 @@ private slots:
void on_redButton_toggled(bool checked);
void on_presetComboBox_currentTextChanged(const QString &);
void on_flipButton_clicked();
void on_loadPresetButton_clicked();
void on_savePresetButton_clicked();

View File

@ -234,34 +234,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="xQualityLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>x-quality</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="invisibleQualityLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>quality</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -274,51 +246,81 @@
</sizepolicy>
</property>
<property name="title">
<string>Load Preset</string>
<string>Preset Ramps</string>
</property>
<layout class="QHBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="presetComboBox">
<property name="toolTip">
<string>Transfer Functions list</string>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
<item>
<widget class="QComboBox" name="presetComboBox">
<property name="toolTip">
<string>Transfer Functions list</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="loadPresetButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="topMargin">
<number>5</number>
</property>
<property name="toolTip">
<string>click to load a Transfer Function file</string>
</property>
<property name="icon">
<iconset resource="qualitymapper.qrc">
<normaloff>:/images/opentf.png</normaloff>:/images/opentf.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="savePresetButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Add/Save preset</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<item>
<widget class="QPushButton" name="flipButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Flip Current Ramp Direction</string>
</property>
<property name="text">
<string>Flip</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadPresetButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>click to load a Transfer Function file</string>
</property>
<property name="icon">
<iconset resource="qualitymapper.qrc">
<normaloff>:/images/opentf.png</normaloff>:/images/opentf.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="savePresetButton">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Add/Save preset</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>