Skip to content

Commit 06b31a0

Browse files
committed
Centering rises
1 parent 425358f commit 06b31a0

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

DOCUMENTATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sfoav struct.xyz
3232
> [!important]
3333
> SFOAV can process ```.xyz```, ```.extxyz```, and DL_POLY ```CONFIG```, ```REVCON``` and ```HISTORY``` files. If the file name does not match these patterns all types will be attempted.
3434
35-
This will bring up the view centring the atoms in ```struct.xyz``` in the first frame (if applicable). The camera is centered on (0, 0, 0) and can be moved in spherical coordinates relative to it. The atoms can also be translated relative to (0, 0, 0).
35+
This will bring up the view centring the atoms in ```struct.xyz``` in the first frame (if applicable). The camera is centered on (0, 0, 0) and can be moved in spherical coordinates relative to it. By defaul the atoms are centred at (0, 0, 0). The atoms can also be translated relative to (0, 0, 0).
3636

3737
> [!note]
3838
> Reading of structure files is done in a background thread. For large structure files you may be presented with a loading screen. An intel i7-4790K and Kingston A400 SATA SSD is capable of around 1,000,000 (positions only) atoms per second read.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sfoav struct.xyz
3131
> [!important]
3232
> SFOAV can process ```.xyz```, ```.extxyz```, and DL_POLY ```CONFIG```, ```REVCON``` and ```HISTORY``` files. If the file name does not match these patterns all types will be attempted.
3333
34-
This will bring up the view centring the atoms in ```struct.xyz``` in the first frame (if applicable). The camera is centered on (0, 0, 0) and can be moved in spherical coordinates relative to it. The atoms can also be translated relative to (0, 0, 0).
34+
This will bring up the view centring the atoms in ```struct.xyz``` in the first frame (if applicable). The camera is centered on (0, 0, 0) and can be moved in spherical coordinates relative to it. By defaul the atoms are centred at (0, 0, 0). The atoms can also be translated relative to (0, 0, 0).
3535

3636
> [!note]
3737
> Reading of structure files is done in a background thread. For large structure files you may be presented with a loading screen. An intel i7-4790K and Kingston A400 SATA SSD is capable of around 1,000,000 (positions only) atoms per second read.

include/commandLine.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ struct CommandLine
448448
Argument<bool> play = {"play", "Set to play trajectories at start up (toggle-able at runtime).", false, false};
449449
Argument<uint64_t> bondFocus = {"bondFocus", "Only draw bonds involving this atom index.", NULL_INDEX, false};
450450
Argument<uint8_t> speed = {"speed", "Play speed between 1 and 60.", 60, false};
451+
Argument<bool> noCentering = {"noCentering", "Do not centre the atoms", false, false};
451452

452453
/**
453454
* @brief Determine if help or licenses should be printed.
@@ -532,6 +533,8 @@ struct CommandLine
532533
<< argumentHelp(resolution)
533534
<< "\n"
534535
<< argumentHelp(speed)
536+
<< "\n"
537+
<< argumentHelp(noCentering)
535538
<< "\n";
536539
std::cout << h.str();
537540
}

src/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int main(int argv, char ** argc)
5353

5454
std::unique_ptr<Structure> structure;
5555
readStructureFile(options.structure.value, structure);
56+
glm::vec3 com = glm::vec3(0);
5657

5758
if (!options.colourmap.value.empty())
5859
{
@@ -103,6 +104,7 @@ int main(int argv, char ** argc)
103104
std::cout << "Element " << e << " emphasis bound to key " << keyCodes.at(GLFW_KEY_1+i) << "\n";
104105
}
105106
applyColours(structure->atoms, atomColourOverrides);
107+
if (!options.noCentering.value) { center(structure->atoms); }
106108

107109
std::vector<Bond> bonds;
108110
std::vector<uint64_t> bondsFor;
@@ -193,6 +195,7 @@ int main(int argv, char ** argc)
193195
playBackward = false;
194196
if (!readInProgress)
195197
{
198+
com = getCenter(structure->atoms);
196199
structure->readFrame(structure->framePosition());
197200
readInProgress = true;
198201
}
@@ -203,6 +206,7 @@ int main(int argv, char ** argc)
203206
playBackward = true;
204207
if (!readInProgress)
205208
{
209+
com = getCenter(structure->atoms);
206210
backward(structure);
207211
readInProgress = true;
208212
}
@@ -249,6 +253,8 @@ int main(int argv, char ** argc)
249253
{
250254
// Previous threaded read is done.
251255
readInProgress = false;
256+
if (!options.noCentering.value) { center(structure->atoms); }
257+
translate(structure->atoms, com);
252258
if (options.bondCutoff.value > 0.0)
253259
{
254260
bonds = determineBonds(bondsFor, structure->atoms, options.bondCutoff.value);
@@ -322,6 +328,7 @@ int main(int argv, char ** argc)
322328

323329
if (t >= uint8_t(60)-std::min(options.speed.value, uint8_t(60)))
324330
{
331+
com = getCenter(structure->atoms);
325332
if (playBackward)
326333
{
327334
backward(structure);

0 commit comments

Comments
 (0)