Skip to content

Commit

Permalink
Merge pull request #560 from spirit-code/feature-clang-format
Browse files Browse the repository at this point in the history
clang-format file for homogeneous formatting
  • Loading branch information
MSallermann authored Dec 19, 2020
2 parents 76318ac + 5c32292 commit 4b439ce
Show file tree
Hide file tree
Showing 39 changed files with 7,370 additions and 6,936 deletions.
53 changes: 53 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
### General default config, applies to all languages ###
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
AlignOperands: true
AlignTrailingComments: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: false
ContinuationIndentWidth: 4
ColumnLimit: 120
IndentCaseLabels: true
IndentWidth: 4
PenaltyBreakComment: 10000000
SpaceBeforeParens: Never
SpacesInParentheses: true
TabWidth: 4
UseTab: Never
---
Language: Cpp
Standard: C++11
AlwaysBreakTemplateDeclarations: Yes
Cpp11BracedListStyle: false
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 8
FixNamespaceComments: true
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
NamespaceIndentation: None
PointerAlignment: Middle
SpaceAfterTemplateKeyword: false
SpacesInAngles: false
---
Language: JavaScript
AlignConsecutiveAssignments: false
BreakBeforeBraces: Attach
ContinuationIndentWidth: 2
IndentWidth: 2
JavaScriptQuotes: Single
SpacesInContainerLiterals: true
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
TabWidth: 2
117 changes: 58 additions & 59 deletions ui-cpp/include/ConfigurationsWidget.hpp
Original file line number Diff line number Diff line change
@@ -1,86 +1,85 @@
#pragma once
#ifndef ConfigurationsWidget_H
#define ConfigurationsWidget_H
#ifndef SPIRIT_CONFIGURATIONSWIDGET_HPP
#define SPIRIT_CONFIGURATIONSWIDGET_HPP

#include "ui_ConfigurationsWidget.h"

#include "IsosurfaceWidget.hpp"
#include "SpinWidget.hpp"

#include <QtWidgets/QWidget>
#include <QRegularExpressionValidator>
#include <QtWidgets/QWidget>

#include <memory>
#include <thread>

#include "SpinWidget.hpp"
#include "IsosurfaceWidget.hpp"
//#include "SettingsWidget.hpp"

#include "ui_ConfigurationsWidget.h"

struct State;

/*
Converts a QString to an std::string.
This function is needed sometimes due to weird behaviour of QString::toStdString().
Converts a QString to an std::string.
This function is needed sometimes due to weird behaviour of QString::toStdString().
*/
std::string string_q2std(QString qs);
std::string string_q2std( QString qs );

class ConfigurationsWidget : public QWidget, private Ui::ConfigurationsWidget
{
Q_OBJECT

public:
ConfigurationsWidget(std::shared_ptr<State> state, SpinWidget * spinWidget);
void updateData();
ConfigurationsWidget( std::shared_ptr<State> state, SpinWidget * spinWidget );
void updateData();

public slots:
// Configurations
void configurationAddNoise();
void randomPressed();
void lastConfiguration();
// Configurations
void configurationAddNoise();
void randomPressed();
void lastConfiguration();

private slots:
// Configurations
void addNoisePressed();
void domainPressed();
void plusZ();
void minusZ();
void create_Hopfion();
void create_Skyrmion();
void create_SpinSpiral();
// Pinning and atom types
void set_atom_type_pressed();
void set_pinned_pressed();
// Transitions
void homogeneousTransitionPressed();
void homogeneousTransitionFirstLastPressed();
void homogeneousTransitionInterpolatePressed();
// Configurations
void addNoisePressed();
void domainPressed();
void plusZ();
void minusZ();
void create_Hopfion();
void create_Skyrmion();
void create_SpinSpiral();
// Pinning and atom types
void set_atom_type_pressed();
void set_pinned_pressed();
// Transitions
void homogeneousTransitionPressed();
void homogeneousTransitionFirstLastPressed();
void homogeneousTransitionInterpolatePressed();
void DW_Width_CheckBox_State_Changed();

private:
void Setup_Input_Validators();
void Setup_Configurations_Slots();
void Setup_Transitions_Slots();

// Helpers
std::array<float, 3> get_position();
std::array<float, 3> get_border_rectangular();
float get_border_cylindrical();
float get_border_spherical();
float get_inverted();

// Debug?
void print_Energies_to_console();

std::shared_ptr<State> state;
SpinWidget * spinWidget;
//SettingsWidget * settingsWidget;

// Last used configuration
std::string last_configuration;

// Validator for Input into lineEdits
QRegularExpressionValidator * number_validator;
QRegularExpressionValidator * number_validator_unsigned;
QRegularExpressionValidator * number_validator_int;
QRegularExpressionValidator * number_validator_int_unsigned;
void Setup_Input_Validators();
void Setup_Configurations_Slots();
void Setup_Transitions_Slots();

// Helpers
std::array<float, 3> get_position();
std::array<float, 3> get_border_rectangular();
float get_border_cylindrical();
float get_border_spherical();
float get_inverted();

// Debug?
void print_Energies_to_console();

std::shared_ptr<State> state;
SpinWidget * spinWidget;
// SettingsWidget * settingsWidget;

// Last used configuration
std::string last_configuration;

// Validator for Input into lineEdits
QRegularExpressionValidator * number_validator;
QRegularExpressionValidator * number_validator_unsigned;
QRegularExpressionValidator * number_validator_int;
QRegularExpressionValidator * number_validator_int_unsigned;
};

#endif
30 changes: 15 additions & 15 deletions ui-cpp/include/ControlWidget.hpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#pragma once
#ifndef CONTROLWIDGET_H
#define CONTROLWIDGET_H
#ifndef SPIRIT_CONTROLWIDGET_HPP
#define SPIRIT_CONTROLWIDGET_HPP

#include "ui_ControlWidget.h"

#include "SettingsWidget.hpp"
#include "SpinWidget.hpp"

#include <QWidget>
#include <QFutureWatcher>
#include <QWidget>

#include <memory>
#include <thread>

#include "SpinWidget.hpp"
#include "SettingsWidget.hpp"

#include "ui_ControlWidget.h"

struct State;

/*
Converts a QString to an std::string.
This function is needed sometimes due to weird behaviour of QString::toStdString().
*/
std::string string_q2std(QString qs);
std::string string_q2std( QString qs );

class ControlWidget : public QWidget, private Ui::ControlWidget
{
Q_OBJECT

public:
ControlWidget(std::shared_ptr<State> state, SpinWidget *spinWidget, SettingsWidget *settingsWidget);
ControlWidget( std::shared_ptr<State> state, SpinWidget * spinWidget, SettingsWidget * settingsWidget );
void updateData();
void cycleMethod();
void cycleSolver();
Expand All @@ -41,13 +41,13 @@ public slots:
void prev_image();
void jump_to_image();
void cut_image();
void paste_image(std::string where="current");
void paste_image( std::string where = "current" );
void delete_image();
void next_mode();
void prev_mode();
void jump_to_mode();
void calculate();
void apply_mode();
void apply_mode();
void calculate_disable_widget();
void calculate_enable_widget();
void ema_buttons_show();
Expand All @@ -68,9 +68,9 @@ private slots:
// State
std::shared_ptr<State> state;
// Spin Widget
SpinWidget *spinWidget;
SpinWidget * spinWidget;
// Settings Widget
SettingsWidget *settingsWidget;
SettingsWidget * settingsWidget;

// Method vectors
std::vector<std::thread> threads_image;
Expand All @@ -90,7 +90,7 @@ private slots:
void save_Energies();

protected:
void closeEvent(QCloseEvent *event);
void closeEvent( QCloseEvent * event );
};

#endif
22 changes: 11 additions & 11 deletions ui-cpp/include/DebugWidget.hpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
#pragma once
#ifndef DEBUGWIDGET_H
#define DEBUGWIDGET_H
#ifndef SPIRIT_DEBUGWIDGET_HPP
#define SPIRIT_DEBUGWIDGET_HPP

#include "ui_DebugWidget.h"

#include <QWidget>

#include <memory>

#include "ui_DebugWidget.h"

struct State;

class DebugWidget : public QWidget, private Ui::DebugWidget
{
Q_OBJECT

public:
DebugWidget(std::shared_ptr<State> state);
void updateData();
DebugWidget( std::shared_ptr<State> state );
void updateData();

void LoadFromLog();
void UpdateFromLog();
void LoadFromLog();
void UpdateFromLog();

std::shared_ptr<State> state;
std::shared_ptr<State> state;

private slots:
void AllPressed();
void AllPressed();

private:
int n_log_entries;
int n_log_entries;
};

#endif
40 changes: 20 additions & 20 deletions ui-cpp/include/GeometryWidget.hpp
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
#pragma once
#ifndef GeometryWidget_H
#define GeometryWidget_H
#ifndef SPIRIT_GEOMETRYWIDGET_HPP
#define SPIRIT_GEOMETRYWIDGET_HPP

#include "ui_GeometryWidget.h"

#include "SpinWidget.hpp"

#include <QtWidgets/QWidget>
#include <QRegularExpressionValidator>
#include <QtWidgets/QWidget>

#include <memory>
#include <thread>

#include "SpinWidget.hpp"

#include "ui_GeometryWidget.h"

struct State;

class GeometryWidget : public QWidget, private Ui::GeometryWidget
{
Q_OBJECT

public:
GeometryWidget(std::shared_ptr<State> state, SpinWidget * spinWidget);
void updateData();
GeometryWidget( std::shared_ptr<State> state, SpinWidget * spinWidget );
void updateData();

signals:
void updateNeeded();
void updateNeeded();

private slots:
void setNCells();
void setNCells();

private:
void Setup_Input_Validators();
void Setup_Slots();
void Setup_Input_Validators();
void Setup_Slots();

std::shared_ptr<State> state;
SpinWidget * spinWidget;
std::shared_ptr<State> state;
SpinWidget * spinWidget;

// Validator for Input into lineEdits
QRegularExpressionValidator * number_validator;
QRegularExpressionValidator * number_validator_unsigned;
QRegularExpressionValidator * number_validator_int;
QRegularExpressionValidator * number_validator_int_unsigned;
// Validator for Input into lineEdits
QRegularExpressionValidator * number_validator;
QRegularExpressionValidator * number_validator_unsigned;
QRegularExpressionValidator * number_validator_int;
QRegularExpressionValidator * number_validator_int_unsigned;
};

#endif
Loading

0 comments on commit 4b439ce

Please sign in to comment.