mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-16 01:24:36 +00:00
- Extrapolated getColorByQuality function from function applyColorByVertexQuality
- Added "get" methods ifor minQuality, maxQuality, midRelQuality, brightness - Modified generation of the colorband in GL area
This commit is contained in:
parent
b1cab72f46
commit
3abafe8631
@ -80,6 +80,7 @@ int loadEqualizerInfo(QString fileName, EQUALIZER_INFO *data)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
void applyColorByVertexQuality(MeshModel& mesh, TransferFunction *transferFunction, float minQuality, float maxQuality, float midHandlePercentilePosition, float brightness)
|
||||
{
|
||||
CMeshO::VertexIterator vi;
|
||||
@ -111,4 +112,15 @@ void applyColorByVertexQuality(MeshModel& mesh, TransferFunction *transferFuncti
|
||||
|
||||
(*vi).C() = currentColor;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
void applyColorByVertexQuality(MeshModel& mesh, TransferFunction *transferFunction, float minQuality, float maxQuality, float midHandlePercentilePosition, float brightness)
|
||||
{
|
||||
CMeshO::VertexIterator vi;
|
||||
float percentageQuality;
|
||||
Color4b currentColor;
|
||||
|
||||
for(vi=mesh.cm.vert.begin(); vi!=mesh.cm.vert.end(); ++vi)
|
||||
if(!(*vi).IsD())
|
||||
(*vi).C() = transferFunction->getColorByQuality ((*vi).Q(), minQuality, maxQuality, midHandlePercentilePosition, brightness);
|
||||
}
|
||||
@ -449,6 +449,34 @@ Color4b TransferFunction::getColorByQuality (float percentageQuality)
|
||||
255 );
|
||||
}
|
||||
|
||||
//converts a quality value into a color depending on the transfer function channels values, min quality, max quality, mid quality and brightness
|
||||
Color4b TransferFunction::getColorByQuality (float absoluteQuality, float minQuality, float maxQuality, float midRelativeQuality, float brightness)
|
||||
{
|
||||
float percentageQuality;
|
||||
Color4b currentColor;
|
||||
|
||||
if (absoluteQuality < minQuality)
|
||||
percentageQuality = 0.0f;
|
||||
else
|
||||
if (absoluteQuality > maxQuality)
|
||||
percentageQuality = 1.0f;
|
||||
else
|
||||
// calcultating relative quality and applying exponential function: rel(Q)^exp, exp=2*midHandleRelPos
|
||||
percentageQuality = pow( (absoluteQuality - minQuality) / (maxQuality - minQuality) , (float)(2.0f*midRelativeQuality));
|
||||
|
||||
currentColor = getColorByQuality(percentageQuality);
|
||||
|
||||
if (brightness!=1.0f) //Applying brightness to each color channel, 0<brightness<2, 1=normale brightness, 0=white, 2=black
|
||||
if (brightness<1.0f)
|
||||
for (int i=0; i<NUMBER_OF_CHANNELS; i++)
|
||||
currentColor[i] = relative2AbsoluteVali(pow(absolute2RelativeValf(currentColor[i],255.0f),brightness), 255.0f);
|
||||
else
|
||||
for (int i=0; i<NUMBER_OF_CHANNELS; i++)
|
||||
currentColor[i] = relative2AbsoluteVali(1.0f-pow(1.0f-absolute2RelativeValf(currentColor[i],255.0f),2-brightness), 255.0f);
|
||||
|
||||
return currentColor;
|
||||
}
|
||||
|
||||
//saves the current color band onto an external file
|
||||
//moreover it saves info about the equalizer state
|
||||
//returns the name of the file
|
||||
|
||||
@ -213,6 +213,7 @@ public:
|
||||
QColor* buildColorBand(void);
|
||||
QString saveColorBand(QString fileName, EQUALIZER_INFO& equalizerInfo);
|
||||
Color4b getColorByQuality(float percentageQuality);
|
||||
Color4b getColorByQuality(float absoluteQuality, float minQuality, float maxQuality, float midRelativeQuality, float brightness);
|
||||
void moveChannelAhead(TF_CHANNELS channel_code);
|
||||
inline int getFirstPlaneChanel(void) { return _channels_order[NUMBER_OF_CHANNELS-1]; }
|
||||
};
|
||||
|
||||
@ -128,14 +128,23 @@ void QualityMapperPlugin::Decorate(QAction*, MeshModel&, GLArea*)
|
||||
glColor4f(.3f,.3f,.3f,.3f);
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
|
||||
|
||||
float maxQuality = _qualityMapperDialog->maxQuality();
|
||||
float minQuality = _qualityMapperDialog->minQuality();
|
||||
float brightness = _qualityMapperDialog->brightness();
|
||||
float relativeMidQuality = _qualityMapperDialog->relativeMidQuality();
|
||||
float step = (float)(maxQuality - minQuality)/(float)steps;
|
||||
float curQ;
|
||||
for(int i=0;i<steps;++i)
|
||||
{
|
||||
glVertex2f(barLeft,barBottom+delta*i); glVertex2f(barRight,barBottom+delta*i);
|
||||
Color4b cc = _qualityMapperDialog->_transferFunction->getColorByQuality(float(i)/float(steps));
|
||||
cc[3]=64;
|
||||
glColor(cc);
|
||||
}
|
||||
glVertex2f(barLeft,barTop); glVertex2f(barRight,barTop);
|
||||
{
|
||||
glVertex2f(barLeft,barBottom+delta*i); glVertex2f(barRight,barBottom+delta*i);
|
||||
curQ = float(i)*step + minQuality;
|
||||
// Color4b cc = _qualityMapperDialog->_transferFunction->getColorByQuality(float(i)/float(steps));
|
||||
Color4b cc = _qualityMapperDialog->_transferFunction->getColorByQuality(curQ, minQuality, maxQuality, relativeMidQuality, brightness);
|
||||
cc[3]=64;
|
||||
glColor(cc);
|
||||
}
|
||||
glVertex2f(barLeft,barTop); glVertex2f(barRight,barTop);
|
||||
glEnd();
|
||||
|
||||
|
||||
|
||||
@ -122,6 +122,11 @@ public:
|
||||
bool initEqualizerHistogram(void);
|
||||
void drawTransferFunction(void);
|
||||
|
||||
float minQuality() {return ui.minSpinBox->value();};
|
||||
float maxQuality() {return ui.maxSpinBox->value();};
|
||||
float relativeMidQuality() {return _equalizerMidHandlePercentilePosition;};
|
||||
float brightness() {return (1.0f - (float)(ui.brightnessSlider->value())/(float)(ui.brightnessSlider->maximum()) )*2.0;};
|
||||
|
||||
private:
|
||||
Ui::QualityMapperDialogClass ui;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user