Skip to content

Commit

Permalink
Creating patch file for Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Sep 12, 2024
1 parent 1fb0a6e commit 70cefc0
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 60 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: linux

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]

jobs:
#
# Ubuntu
#
build-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
sudo apt update && sudo apt install -y qt6-tools-dev qt6-base-dev libqt6charts6-dev libqt6widgets6 libqt6gui6 libqt6opengl6-dev libgl1-mesa-dev build-essential cmake
- name: Configure CMake
run: |
mkdir build
cd build
cmake ..
- name: Build
run: |
cd build
make -j
#
# Ubuntu 12-Qt5
#
build-ubuntu-qt5:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
apt update && apt install -y sudo apt update && sudo apt install -y qtbase5-dev libqt5charts5-dev libgl1-mesa-dev build-essential cmake
- name: Apply patch
run: patch -p1 CMakeLists.txt < qt5.patch
- name: Configure CMake
run: |
mkdir build
cd build
cmake ..
- name: Build
run: |
cd build
make -j
#
# Debian 12
#
build-debian12:
runs-on: ubuntu-latest
container:
image: debian:12
steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
apt update && apt install -y qt6-tools-dev qt6-base-dev libqt6charts6-dev libqt6widgets6 libqt6gui6 libqt6opengl6-dev libgl1-mesa-dev build-essential cmake
- name: Configure CMake
run: |
mkdir build
cd build
cmake ..
- name: Build
run: |
cd build
make -j
44 changes: 1 addition & 43 deletions .github/workflows/build.yml → .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: windows

on:
push:
Expand Down Expand Up @@ -35,48 +35,6 @@ jobs:
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}

#
# Ubuntu
#
build-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
sudo apt update && sudo apt install -y qt6-tools-dev qt6-base-dev libqt6charts6-dev libqt6widgets6 libqt6gui6 libqt6opengl6-dev libgl1-mesa-dev build-essential cmake
- name: Configure CMake
run: |
mkdir build
cd build
cmake ..
- name: Build
run: |
cd build
make -j
#
# Debian 12
#
build-debian12:
runs-on: ubuntu-latest
container:
image: debian:12
steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
apt update && apt install -y qt6-tools-dev qt6-base-dev libqt6charts6-dev libqt6widgets6 libqt6gui6 libqt6opengl6-dev libgl1-mesa-dev build-essential cmake
- name: Configure CMake
run: |
mkdir build
cd build
cmake ..
- name: Build
run: |
cd build
make -j
#
# Windows
#
Expand Down
67 changes: 60 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Atom Architect

![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/ifilot/atom-architect?label=version)
[![build](https://github.com/ifilot/atom-architect/actions/workflows/build.yml/badge.svg)](https://github.com/ifilot/atom-architect/actions/workflows/build.yml)
[![windows](https://github.com/ifilot/atom-architect/actions/workflows/windows.yml/badge.svg)](https://github.com/ifilot/atom-architect/actions/workflows/windows.yml)
[![linux](https://github.com/ifilot/atom-architect/actions/workflows/linux.yml/badge.svg)](https://github.com/ifilot/atom-architect/actions/workflows/linux.yml)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

![Screenshot of Atom Architect](img/atom-architect-screenshot.JPG)
Expand All @@ -19,13 +20,17 @@ Latest installer for Window: [here](https://github.com/ifilot/atom-architect/rel

## Compilation

For Windows, it is recommended to use the installer as shown above. For Linux,
it is recommended to compile Atom Architect yourself. Please note that Atom
Architect is only tested for Debian 12 and Ubuntu 22.04. For other
distributions, you are on your own.
### Windows

To compile Atom Architect, please follow the compilation instructions as shown
below.
Compilation for Windows is most easily done by installing Qt Creator and loading
the project file `atom-architect.pro`.

### Linux Debian / Ubuntu

Please note that Atom Architect is only tested for Debian 12 and Ubuntu 22.04.
For other distributions, you are on your own.

#### Qt6

Start by installing all the required dependencies

Expand Down Expand Up @@ -60,6 +65,54 @@ folder the following command.
sudo cp -v ./atom_architect /usr/local/bin/atom_architect
```

#### Qt5

Start by installing all the required dependencies

```bash
sudo apt update && sudo apt install -y \
qtbase5-dev \
libqt5charts5-dev \
libgl1-mesa-dev \
build-essential \
cmake
```

After having cloned this repository and starting at its root folder, run a patch
file to change from Qt6 to Qt5.

```bash
patch -p1 CMakeLists.txt < qt5.patch
```

Create a new build folder, go to this folder, create the compilation and start
the compilation.

```bash
mkdir build
cd build
cmake ../
make -j
```

This will generate the compilation scripts and compile Atom Architect. You can
use Atom Architect by running `./atom_architect` in your `build` folder. If
you wish to install Atom Architect on your system, you can run in your `build`
folder the following command.

```bash
sudo cp -v ./atom_architect /usr/local/bin/atom_architect
```

### Snellius

To compile for the Snellius infrastructure, it is recommended to use the Qt5
toolchain. To do so, run the following patch file.

```bash
patch -p1 CMakeLists.txt < qt5.patch
```

## Dependencies

Atom Architect depends on [GLM](https://github.com/g-truc/glm) and
Expand Down
22 changes: 22 additions & 0 deletions qt5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- CMakeLists.txt 2024-09-02 20:58:43.184160900 +0200
+++ CMakeLists-Qt5.txt 2024-09-12 11:33:12.719435600 +0200
@@ -20,8 +20,8 @@
)
add_compile_definitions(GIT_HASH="${GIT_HASH}")

-# Find Qt6 packages
-find_package(Qt6 REQUIRED COMPONENTS Widgets Charts)
+# Find Qt5 packages
+find_package(Qt5 REQUIRED COMPONENTS Widgets Charts)

add_executable(atom-architect
src/main.cpp
@@ -65,7 +65,7 @@
include_directories("src/vendor/eigen-3.4.0"
"src/vendor/glm-1.0.1")

-target_link_libraries(atom-architect PRIVATE Qt6::Core Qt6::Widgets Qt6::Charts)
+target_link_libraries(atom-architect PRIVATE Qt5::Core Qt5::Widgets Qt5::Charts)

set_target_properties(atom-architect PROPERTIES
WIN32_EXECUTABLE ON
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
#pragma once

#define PROGRAM_NAME "Atom Architect"
#define PROGRAM_VERSION "0.2.2"
#define PROGRAM_VERSION "0.2.3"
21 changes: 17 additions & 4 deletions src/gui/anaglyph_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ void AnaglyphWidget::mousePressEvent(QMouseEvent *event) {
emit(signal_selection_message(this->structure->get_selection_string()));
}

// custom menu
if (event->buttons() & Qt::RightButton && event->modifiers() & Qt::ControlModifier) {
this->custom_menu_requested(event->globalPosition().toPoint());
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// custom menu
if (event->buttons() & Qt::RightButton && event->modifiers() & Qt::ControlModifier) {
this->custom_menu_requested(event->globalPosition().toPoint());
}
#else
// custom menu
if (event->buttons() & Qt::RightButton && event->modifiers() & Qt::ControlModifier) {
this->custom_menu_requested(event->globalPos());
}
#endif
}

/**
Expand Down Expand Up @@ -287,8 +294,14 @@ void AnaglyphWidget::mouseMoveEvent(QMouseEvent *event) {
if(this->arcball_rotation_flag) { // drag event
// implementation adapted from
// https://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Arcball

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
double ex = event->position().x();
double ey = event->position().y();
#else
double ex = event->pos().x();
double ey = event->pos().y();
#endif
if(ex != this->m_lastPos.x() || ey != this->m_lastPos.y()) {

// calculate arcball vectors
Expand Down
1 change: 1 addition & 0 deletions src/gui/anaglyph_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QDebug>
#include <QTimer>
#include <QMenu>
#include <QtGlobal>

#include <QtCore/qmath.h>
#include <QtCore/qvariant.h>
Expand Down
8 changes: 5 additions & 3 deletions src/gui/analysis_neb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ void AnalysisNEB::load_file(const QString& filename) {
this->set_structures(sl.load_neb_bin(filename.toStdString()));

// expand anaglyph widgets
unsigned int nr_rows = 4;
static const unsigned int nr_cols = 4;

qDebug() << "Loading " << this->structures.size() << " images.";
for(unsigned int i=0; i<this->structures.size(); i++) {
this->anaglyph_widgets.push_back(new AnaglyphWidget());
this->anaglyph_hypergrid->addWidget(this->anaglyph_widgets.back(), i / nr_rows * 2, i % nr_rows);
this->anaglyph_hypergrid->addWidget(this->anaglyph_widgets.back(), (i / nr_cols) * 2, i % nr_cols);

this->image_labels.push_back(new QLabel(tr("Image %1").arg(i+1)));
this->anaglyph_hypergrid->addWidget(this->image_labels.back(), i / nr_rows * 2 + 1, i % nr_rows);
this->anaglyph_hypergrid->addWidget(this->image_labels.back(), (i / nr_cols) * 2 + 1, i % nr_cols);

this->structures[i].front()->update();
this->anaglyph_widgets.back()->set_structure(this->structures[i].front());
Expand Down
4 changes: 2 additions & 2 deletions src/gui/interface_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ void InterfaceWindow::update_selection_label(const QString& text) {
static const unsigned int sz = 120;

if(pieces1[0].length() > sz) {
pieces1[0] = pieces1[0].first(sz) + "...";
pieces1[0] = pieces1[0].left(sz) + "...";

}

if(pieces2[0].length() > sz) {
pieces2[0] = pieces2[0].first(sz) + "...";
pieces2[0] = pieces2[0].left(sz) + "...";

}

Expand Down

0 comments on commit 70cefc0

Please sign in to comment.