Skip to content

Commit

Permalink
Fixing and Improving the labels on the IPF Legends that are generated
Browse files Browse the repository at this point in the history
based on user feedback.
  • Loading branch information
imikejackson committed Nov 17, 2017
1 parent 28c3190 commit 802434a
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 91 deletions.
6 changes: 3 additions & 3 deletions Source/OrientationLib/LaueOps/CubicLowOps.cpp
Expand Up @@ -1079,9 +1079,9 @@ SIMPL::Rgb CubicLowOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> CubicLowOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Cubic Low <001>");
QString label1("Cubic Low <011>");
QString label2("Cubic Low <111>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <011>").arg(getSymmetryName());
QString label2 = QString("%1 <111>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
6 changes: 3 additions & 3 deletions Source/OrientationLib/LaueOps/CubicOps.cpp
Expand Up @@ -1773,9 +1773,9 @@ SIMPL::Rgb CubicOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> CubicOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("<001>");
QString label1("<011>");
QString label2("<111>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <011>").arg(getSymmetryName());
QString label2 = QString("%1 <111>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
6 changes: 3 additions & 3 deletions Source/OrientationLib/LaueOps/HexagonalLowOps.cpp
Expand Up @@ -1366,9 +1366,9 @@ SIMPL::Rgb HexagonalLowOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> HexagonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Hex Low <0001>");
QString label1("Hex Low <-1-120>");
QString label2("Hex Low <2-1-10>");
QString label0 = QString("%1 <0001>").arg(getSymmetryName());
QString label1 = QString("%1 <-1-120>").arg(getSymmetryName());
QString label2 = QString("%1 <2-1-10>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
6 changes: 3 additions & 3 deletions Source/OrientationLib/LaueOps/HexagonalOps.cpp
Expand Up @@ -1452,9 +1452,9 @@ SIMPL::Rgb HexagonalOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> HexagonalOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Hex <0001>");
QString label1("Hex <1010>");
QString label2("Hex <1120>");
QString label0 = QString("%1 <0001>").arg(getSymmetryName());
QString label1 = QString("%1 <1010>").arg(getSymmetryName());
QString label2 = QString("%1 <1120>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
6 changes: 3 additions & 3 deletions Source/OrientationLib/LaueOps/MonoclinicOps.cpp
Expand Up @@ -757,9 +757,9 @@ SIMPL::Rgb MonoclinicOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> MonoclinicOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Monoclinic <001>");
QString label1("Monoclinic <100>");
QString label2("Monoclinic <010>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <100>").arg(getSymmetryName());
QString label2 = QString("%1 <010>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
9 changes: 5 additions & 4 deletions Source/OrientationLib/LaueOps/OrthoRhombicOps.cpp
Expand Up @@ -162,7 +162,8 @@ int OrthoRhombicOps::getNumSymOps()
// -----------------------------------------------------------------------------
QString OrthoRhombicOps::getSymmetryName()
{
return "OrthoRhombic mmm";;
return "Orthorhombic mmm";
;
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -779,9 +780,9 @@ SIMPL::Rgb OrthoRhombicOps::generateRodriguesColor(float r1, float r2, float r3)
QVector<UInt8ArrayType::Pointer> OrthoRhombicOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{

QString label0("Orthorhombic <001>");
QString label1("Orthorhombic <100>");
QString label2("Orthorhombic <010>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <100>").arg(getSymmetryName());
QString label2 = QString("%1 <010>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
7 changes: 3 additions & 4 deletions Source/OrientationLib/LaueOps/TetragonalLowOps.cpp
Expand Up @@ -591,7 +591,6 @@ namespace Detail
// -----------------------------------------------------------------------------
void TetragonalLowOps::generateSphereCoordsFromEulers(FloatArrayType* eulers, FloatArrayType* xyz001, FloatArrayType* xyz011, FloatArrayType* xyz111)
{
Q_ASSERT(false);
size_t nOrientations = eulers->getNumberOfTuples();

// Sanity Check the size of the arrays
Expand Down Expand Up @@ -773,9 +772,9 @@ SIMPL::Rgb TetragonalLowOps::generateRodriguesColor(float r1, float r2, float r3
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> TetragonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Tetragonal Low <001>");
QString label1("Tetragonal Low <100>");
QString label2("Tetragonal Low <010>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <100>").arg(getSymmetryName());
QString label2 = QString("%1 <010>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
7 changes: 3 additions & 4 deletions Source/OrientationLib/LaueOps/TetragonalOps.cpp
Expand Up @@ -634,7 +634,6 @@ namespace Detail
// -----------------------------------------------------------------------------
void TetragonalOps::generateSphereCoordsFromEulers(FloatArrayType* eulers, FloatArrayType* xyz001, FloatArrayType* xyz011, FloatArrayType* xyz111)
{
Q_ASSERT(false);
size_t nOrientations = eulers->getNumberOfTuples();

// Sanity Check the size of the arrays
Expand Down Expand Up @@ -814,9 +813,9 @@ SIMPL::Rgb TetragonalOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> TetragonalOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Tetragonal <001>");
QString label1("Tetragonal <100>");
QString label2("Tetragonal <110>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <100>").arg(getSymmetryName());
QString label2 = QString("%1 <110>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
6 changes: 3 additions & 3 deletions Source/OrientationLib/LaueOps/TriclinicOps.cpp
Expand Up @@ -753,9 +753,9 @@ SIMPL::Rgb TriclinicOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> TriclinicOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Triclinic <001>");
QString label1("Triclinic <100>");
QString label2("Triclinic <010>");
QString label0 = QString("%1 <001>").arg(getSymmetryName());
QString label1 = QString("%1 <100>").arg(getSymmetryName());
QString label2 = QString("%1 <010>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
7 changes: 3 additions & 4 deletions Source/OrientationLib/LaueOps/TrigonalLowOps.cpp
Expand Up @@ -611,7 +611,6 @@ namespace Detail
// -----------------------------------------------------------------------------
void TrigonalLowOps::generateSphereCoordsFromEulers(FloatArrayType* eulers, FloatArrayType* xyz001, FloatArrayType* xyz011, FloatArrayType* xyz111)
{
Q_ASSERT(false);
size_t nOrientations = eulers->getNumberOfTuples();

// Sanity Check the size of the arrays
Expand Down Expand Up @@ -789,9 +788,9 @@ SIMPL::Rgb TrigonalLowOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> TrigonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Trigonal Low <0001>");
QString label1("Trigonal Low <-1-120>");
QString label2("Trigonal Low <2-1-10>");
QString label0 = QString("%1 <0001>").arg(getSymmetryName());
QString label1 = QString("%1 <-1-120>").arg(getSymmetryName());
QString label2 = QString("%1 <2-1-10>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
7 changes: 3 additions & 4 deletions Source/OrientationLib/LaueOps/TrigonalOps.cpp
Expand Up @@ -635,7 +635,6 @@ namespace Detail
// -----------------------------------------------------------------------------
void TrigonalOps::generateSphereCoordsFromEulers(FloatArrayType* eulers, FloatArrayType* xyz001, FloatArrayType* xyz011, FloatArrayType* xyz111)
{
Q_ASSERT(false);
size_t nOrientations = eulers->getNumberOfTuples();

// Sanity Check the size of the arrays
Expand Down Expand Up @@ -808,9 +807,9 @@ SIMPL::Rgb TrigonalOps::generateRodriguesColor(float r1, float r2, float r3)
// -----------------------------------------------------------------------------
QVector<UInt8ArrayType::Pointer> TrigonalOps::generatePoleFigure(PoleFigureConfiguration_t& config)
{
QString label0("Trigonal <0001>");
QString label1("Trigonal <0-110>");
QString label2("Trigonal <1-100>");
QString label0 = QString("%1 <0001>").arg(getSymmetryName());
QString label1 = QString("%1 <0-110>").arg(getSymmetryName());
QString label2 = QString("%1 <1-100>").arg(getSymmetryName());
if(config.labels.size() > 0) { label0 = config.labels.at(0); }
if(config.labels.size() > 1) { label1 = config.labels.at(1); }
if(config.labels.size() > 2) { label2 = config.labels.at(2); }
Expand Down
42 changes: 31 additions & 11 deletions Source/OrientationLib/Utilities/PoleFigureUtilities.cpp
Expand Up @@ -101,7 +101,7 @@ int writeVtkFile(FloatArrayType* xyz, const QString& filename)
UInt8ArrayType::Pointer PoleFigureUtilities::CreateColorImage(DoubleArrayType* data, int width, int height, int nColors, const QString& name, double min, double max)
{
QVector<size_t> dims(1, 4);
UInt8ArrayType::Pointer image = UInt8ArrayType::CreateArray(width * height, dims, name);
UInt8ArrayType::Pointer image = UInt8ArrayType::CreateArray(static_cast<size_t>(width * height), dims, name);
PoleFigureConfiguration_t config;
config.imageDim = width;
config.numColors = nColors;
Expand All @@ -124,8 +124,8 @@ void PoleFigureUtilities::CreateColorImage(DoubleArrayType* data, PoleFigureConf
int halfWidth = width / 2;
int halfHeight = height / 2;

float xres = 2.0 / (float)(width);
float yres = 2.0 / (float)(height);
float xres = 2.0f / static_cast<float>(width);
float yres = 2.0f / static_cast<float>(height);
float xtmp, ytmp;

float max = static_cast<float>(config.maxScale);
Expand All @@ -136,7 +136,7 @@ void PoleFigureUtilities::CreateColorImage(DoubleArrayType* data, PoleFigureConf
uint32_t* rgbaPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));

int numColors = config.numColors;
QVector<float> colors(numColors * 3, 0.0);
QVector<float> colors(numColors * 3, 0.0f);
SIMPLColorTable::GetColorTable(config.numColors, colors);

float r = 0.0, g = 0.0, b = 0.0;
Expand All @@ -149,8 +149,8 @@ void PoleFigureUtilities::CreateColorImage(DoubleArrayType* data, PoleFigureConf
{
for (int64_t x = 0; x < width; x++)
{
xtmp = float(x - halfWidth) * xres + (xres * 0.5);
ytmp = float(y - halfHeight) * yres + (yres * 0.5);
xtmp = float(x - halfWidth) * xres + (xres * 0.5f);
ytmp = float(y - halfHeight) * yres + (yres * 0.5f);
idx = (width * y) + x;
if( ( xtmp * xtmp + ytmp * ytmp) <= 1.0) // Inside the circle
{
Expand All @@ -173,7 +173,7 @@ void PoleFigureUtilities::CreateColorImage(DoubleArrayType* data, PoleFigureConf
g = colors[3 * bin + 1];
b = colors[3 * bin + 2];
}
rgbaPtr[idx] = RgbColor::dRgb(r * 255, g * 255, b * 255, 255);
rgbaPtr[idx] = RgbColor::dRgb(static_cast<int>(r) * 255, static_cast<int>(g) * 255, static_cast<int>(b) * 255, 255);
}
else // Outside the Circle - Set pixel to White
{
Expand All @@ -192,8 +192,7 @@ void PoleFigureUtilities::GenerateHexPoleFigures(FloatArrayType* eulers, int lam
DoubleArrayType::Pointer& intensity1010,
DoubleArrayType::Pointer& intensity1120)
{
int numOrientations = eulers->getNumberOfTuples();

size_t numOrientations = eulers->getNumberOfTuples();

// Create an Array to hold the XYZ Coordinates which are the coords on the sphere.
// this is size for HEX ONLY, <0001> Family
Expand Down Expand Up @@ -255,8 +254,7 @@ void PoleFigureUtilities::GenerateOrthoPoleFigures(FloatArrayType* eulers, int l
DoubleArrayType::Pointer& intensity010,
DoubleArrayType::Pointer& intensity001)
{
int numOrientations = eulers->getNumberOfTuples();

size_t numOrientations = eulers->getNumberOfTuples();

// Create an Array to hold the XYZ Coordinates which are the coords on the sphere.
// this is size for ORTHO ONLY, <100> Family
Expand Down Expand Up @@ -309,3 +307,25 @@ void PoleFigureUtilities::GenerateOrthoPoleFigures(FloatArrayType* eulers, int l
poleFigurePtr->setName("PoleFigure_<001>");
intensity001.swap(poleFigurePtr);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
GeneratePoleFigureRgbaImageImpl::GeneratePoleFigureRgbaImageImpl()
{
}

GeneratePoleFigureRgbaImageImpl::GeneratePoleFigureRgbaImageImpl(DoubleArrayType* intensity, PoleFigureConfiguration_t* config, UInt8ArrayType* rgba)
: m_Intensity(intensity)
, m_Config(config)
, m_Rgba(rgba)
{
}
GeneratePoleFigureRgbaImageImpl::~GeneratePoleFigureRgbaImageImpl()
{
}

void GeneratePoleFigureRgbaImageImpl::operator()() const
{
PoleFigureUtilities::CreateColorImage(m_Intensity, *m_Config, m_Rgba);
}
35 changes: 15 additions & 20 deletions Source/OrientationLib/Utilities/PoleFigureUtilities.h
Expand Up @@ -58,15 +58,16 @@
*/
typedef struct
{
FloatArrayType* eulers; ///<* The Euler Angles (in Radians) to use for the pole figure
int imageDim; ///<* The height/width of the generated pole figure
int lambertDim; ///<* The dimensions in voxels of the Lambert Square used for interpolation
int numColors; ///<* The number of colors to use in the Pole figure
double minScale; ///<* The minimum scale of the Pole Figure
double maxScale; ///<* The maximum scale of the Pole Figure
float sphereRadius; ///<* The radius of the Sphere to compute XYZ coords. Should ALWAYS be 1.0
QVector<QString> labels; ///<* The labels for each of the 3 Pole Figures
FloatArrayType* eulers; ///<* The Euler Angles (in Radians) to use for the pole figure
int imageDim; ///<* The height/width of the generated pole figure
int lambertDim; ///<* The dimensions in voxels of the Lambert Square used for interpolation
int numColors; ///<* The number of colors to use in the Pole figure
double minScale; ///<* The minimum scale of the Pole Figure
double maxScale; ///<* The maximum scale of the Pole Figure
float sphereRadius; ///<* The radius of the Sphere to compute XYZ coords. Should ALWAYS be 1.0
QVector<QString> labels; ///<* The labels for each of the 3 Pole Figures
QVector<unsigned int> order; ///<* The order that the pole figures should appear in.
QString phaseName; ///<* The Names of the phase
} PoleFigureConfiguration_t;

/**
Expand Down Expand Up @@ -148,19 +149,13 @@ class OrientationLib_EXPORT PoleFigureUtilities
class GeneratePoleFigureRgbaImageImpl
{
public:
GeneratePoleFigureRgbaImageImpl(DoubleArrayType* intensity, PoleFigureConfiguration_t* config, UInt8ArrayType* rgba) :
m_Intensity(intensity),
m_Config(config),
m_Rgba(rgba)
{}
virtual ~GeneratePoleFigureRgbaImageImpl() {}

void operator()() const
{
PoleFigureUtilities::CreateColorImage(m_Intensity, *m_Config, m_Rgba);
}
GeneratePoleFigureRgbaImageImpl(DoubleArrayType* intensity, PoleFigureConfiguration_t* config, UInt8ArrayType* rgba);
virtual ~GeneratePoleFigureRgbaImageImpl();

void operator()() const;

protected:
GeneratePoleFigureRgbaImageImpl() {}
GeneratePoleFigureRgbaImageImpl();

private:
DoubleArrayType* m_Intensity;
Expand Down
Expand Up @@ -137,12 +137,12 @@ QImage OrthorhombicIPFLegendPainter::overlayText(int pixelWidth, int pixelHeight
painter.setPen(QPen(QColor(0, 0, 0, 255), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

// Draw the [111] label in the Upper Right corner
QString label("[100]");
QString label("[010]");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(10, imageSize.height() + fontHeight * 3, label);

label = QString("[010]");
label = QString("[100]");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(pImageWidth - (fontWidth * 1.05), fontHeight * 2, label);
Expand Down
Expand Up @@ -142,7 +142,7 @@ QImage TetragonalIPFLegendPainter::overlayText(int pixelWidth, int pixelHeight,
fontHeight = metrics.height();
painter.drawText(10, imageSize.height() + fontHeight * 3, label);

label = QString("[010]");
label = QString("[110]");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(0.707106781186548 * pImageWidth, fontHeight * 2 + 0.707106781186548 * imageSize.height(), label);
Expand Down
Expand Up @@ -137,12 +137,12 @@ QImage TetragonalLowIPFLegendPainter::overlayText(int pixelWidth, int pixelHeigh
painter.setPen(QPen(QColor(0, 0, 0, 255), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

// Draw the [111] label in the Upper Right corner
QString label("[100]");
QString label("[010]");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(10, imageSize.height() + fontHeight * 3, label);

label = QString("[010]");
label = QString("[100]");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(pImageWidth - (fontWidth * 1.05), fontHeight * 2, label);
Expand All @@ -153,6 +153,7 @@ QImage TetragonalLowIPFLegendPainter::overlayText(int pixelWidth, int pixelHeigh
painter.drawText(10, fontHeight*2, label);

label = ops->getSymmetryName();
label = label.replace("-", "_");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(pImageWidth/2 - fontWidth/2, fontHeight * 1.0, label);
Expand Down
Expand Up @@ -142,12 +142,13 @@ QImage TriclinicIPFLegendPainter::overlayText(int pixelWidth, int pixelHeight, Q
fontHeight = metrics.height();
painter.drawText(pImageWidth/2 - fontWidth/2, fontHeight * 2, label);

label = QString("Center || [010]");
label = QString("Center || [001]");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
painter.drawText(pImageWidth/2 - fontWidth/2, fontHeight * 2.75 + imageSize.height(), label);

label = ops->getSymmetryName();
label = label.replace("-", "_");
fontWidth = metrics.width(label);
fontHeight = metrics.height();
int x = pImageWidth/2 - fontWidth/2;
Expand Down

0 comments on commit 802434a

Please sign in to comment.