From ad5a7ba0945ed3ff6cc5dde1a5cd1c523940df05 Mon Sep 17 00:00:00 2001 From: Patrick Avery Date: Sun, 5 Aug 2018 20:35:38 -0400 Subject: [PATCH] Add special k point tick markers Unfortunately, some unicode characters (such as Greek characters) do not currently work. When we add a font to VTK that can display unicode characters, we can start using the unicode gamma. Signed-off-by: Patrick Avery --- avogadro/qtplugins/yaehmop/yaehmop.cpp | 24 +++++++++++++++++++++-- avogadro/qtplugins/yaehmop/yaehmopout.cpp | 6 ++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/avogadro/qtplugins/yaehmop/yaehmop.cpp b/avogadro/qtplugins/yaehmop/yaehmop.cpp index c751c3f9f2..a883e1726d 100644 --- a/avogadro/qtplugins/yaehmop/yaehmop.cpp +++ b/avogadro/qtplugins/yaehmop/yaehmop.cpp @@ -293,6 +293,25 @@ void Yaehmop::calculateBandStructure() for (int i = 1; i < numKPoints; ++i) xVals.push_back(kpointDistance(kpoints[i - 1], kpoints[i]) + xVals.back()); + // Calculate the special k point distances + std::vector specialKPointVals{ 0.0 }; + for (int i = 1; i < numSpecialKPoints; ++i) { + specialKPointVals.push_back( + kpointDistance(specialKPoints[i - 1].coords, specialKPoints[i].coords) + + specialKPointVals.back()); + } + + // This is to make sure vtk shows the symbols on the far left and right + specialKPointVals.front() += 0.0001; + specialKPointVals.back() -= 0.0001; + + // Make a vector of labels for the special k points + std::vector specialKPointLabels; + for (int i = 0; i < numSpecialKPoints; ++i) { + std::string label = specialKPoints[i].label.toStdString(); + specialKPointLabels.push_back(label); + } + // Now generate a plot with the data std::vector> data; data.push_back(xVals); @@ -307,12 +326,13 @@ void Yaehmop::calculateBandStructure() lineColors.push_back(color); } - const char* xTitle = "Special K-Points Go Here"; + const char* xTitle = ""; const char* yTitle = "Energy (eV)"; const char* windowName = "YAeHMOP Band Structure"; VTK::VtkPlot::generatePlot(data, lineLabels, lineColors, xTitle, yTitle, - windowName); + windowName, specialKPointVals, + specialKPointLabels); } QString Yaehmop::createGeometryAndLatticeInput() const diff --git a/avogadro/qtplugins/yaehmop/yaehmopout.cpp b/avogadro/qtplugins/yaehmop/yaehmopout.cpp index fab6eb8250..3a867f1abb 100644 --- a/avogadro/qtplugins/yaehmop/yaehmopout.cpp +++ b/avogadro/qtplugins/yaehmop/yaehmopout.cpp @@ -86,8 +86,10 @@ bool YaehmopOut::readBandData(const QString& data, kp.label = lines[ind].split(" ")[0]; // If the label is "GM", use "Γ" instead - if (kp.label.toLower() == "gm") - kp.label = QString::fromUtf8("Γ"); + // FIXME: our vtk can't currently display a unicode gamma like this. When + // we add a font that can, we can uncomment this. +// if (kp.label.toLower() == "gm") +// kp.label = QString::fromUtf8("Γ"); kp.coords = Vector3(lines[ind].split(" ")[1].toDouble(), lines[ind].split(" ")[2].toDouble(), lines[ind].split(" ")[3].toDouble());