Skip to content

Commit

Permalink
Add special k point tick markers
Browse files Browse the repository at this point in the history
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 <psavery@buffalo.edu>
  • Loading branch information
psavery committed Aug 25, 2018
1 parent b88152f commit ad5a7ba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
24 changes: 22 additions & 2 deletions avogadro/qtplugins/yaehmop/yaehmop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> 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<std::string> 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<std::vector<double>> data;
data.push_back(xVals);
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions avogadro/qtplugins/yaehmop/yaehmopout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit ad5a7ba

Please sign in to comment.