| 1 |
/****************************************************************************** |
| 2 |
|
| 3 |
This source file is part of the Avogadro project. |
| 4 |
|
| 5 |
Copyright 2015 Marcus Johansson <[email protected]> |
| 6 |
|
| 7 |
This source code is released under the New BSD License, (the "License"). |
| 8 |
|
| 9 |
Unless required by applicable law or agreed to in writing, software |
| 10 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
See the License for the specific language governing permissions and |
| 13 |
limitations under the License. |
| 14 |
|
| 15 |
******************************************************************************/ |
| 16 |
|
| 17 |
#include "symmetryutil.h" |
| 18 |
|
| 19 |
#define _ORIENT_HORIZONTAL \ |
| 20 |
msym::_msym_symmetry_operation::MSYM_SYMMETRY_OPERATION_ORIENTATION_HORIZONTAL |
| 21 |
#define _ORIENT_VERTICAL \ |
| 22 |
msym::_msym_symmetry_operation::MSYM_SYMMETRY_OPERATION_ORIENTATION_VERTICAL |
| 23 |
#define _ORIENT_DIHEDRAL \ |
| 24 |
msym::_msym_symmetry_operation::MSYM_SYMMETRY_OPERATION_ORIENTATION_DIHEDRAL |
| 25 |
|
| 26 |
namespace Avogadro::QtPlugins::SymmetryUtil { |
| 27 |
|
| 28 |
QString pointGroupSymbol(const char* point_group) |
| 29 |
{ |
| 30 |
QString pointGroup(point_group); |
| 31 |
if (pointGroup.isEmpty()) |
| 32 |
pointGroup = "C1"; // default |
| 33 |
|
| 34 |
// check if we need an infinity symbol |
| 35 |
if (pointGroup[1] == '0') |
| 36 |
pointGroup = pointGroup.replace(1, 1, "\u221e"); // infinity symbol |
| 37 |
|
| 38 |
// After first character, point group should subscript everything |
| 39 |
pointGroup.insert(1, "<sub>"); |
| 40 |
pointGroup.append("</sub>"); |
| 41 |
|
| 42 |
return pointGroup; |
| 43 |
} |
| 44 |
|
| 45 |
QString operationSymbol(const msym::msym_symmetry_operation_t* operation) |
| 46 |
{ |
| 47 |
// omit first power |
| 48 |
QString symbol; |
| 49 |
if (operation->type == IDENTITY) { |
| 50 |
symbol = QString("E"); |
| 51 |
} else if (operation->type == INVERSION) { |
| 52 |
symbol = QString("i"); |
| 53 |
} else if (operation->type == PROPER_ROTATION) { |
| 54 |
symbol = QString("C<sub>%1</sub>").arg(operation->order); |
| 55 |
if (operation->power > 1) // add the power for ^2, ^3, etc. |
| 56 |
symbol.append(QString("<sup>%2</sup>").arg(operation->power)); |
| 57 |
} else if (operation->type == IMPROPER_ROTATION) { |
| 58 |
symbol = QString("S<sub>%1</sub>").arg(operation->order); |
| 59 |
if (operation->power > 1) // add the power for ^2, ^3, etc. |
| 60 |
symbol.append(QString("<sup>%2</sup>").arg(operation->power)); |
| 61 |
} else if (operation->type == REFLECTION) { |
| 62 |
symbol = QString("σ"); |
| 63 |
if (operation->orientation == _ORIENT_HORIZONTAL) |
| 64 |
symbol.append("<sub>h</sub>"); |
| 65 |
else if (operation->orientation == _ORIENT_DIHEDRAL) |
| 66 |
symbol.append("<sub>d</sub>"); |
| 67 |
else if (operation->orientation == _ORIENT_VERTICAL) |
| 68 |
symbol.append("<sub>v</sub>"); |
| 69 |
} |
| 70 |
|
| 71 |
return symbol; |
| 72 |
} |
| 73 |
} // namespace Avogadro::QtPlugins::SymmetryUtil |