Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to rename viewer to pilot #446

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,19 @@ jobs:
python3 -c "import modmesh; assert modmesh.HAS_VIEW == True"
make pytest VERBOSE=1

- name: make viewer
- name: make pilot
run: |
rm -f build/*/Makefile
make viewer \
make pilot \
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=ON \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"

- name: make run_viewer_pytest
- name: make run_pilot_pytest
run: |
export LD_LIBRARY_PATH=$(python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))")
make run_viewer_pytest VERBOSE=0
make run_pilot_pytest VERBOSE=0

# FIXME: turn off until all issues resolved
- name: make cmake USE_SANITIZER=ON & make pytest
Expand Down Expand Up @@ -431,18 +431,18 @@ jobs:
fi
make pytest ${JOB_MAKE_ARGS}

- name: make viewer
- name: make pilot
run: |
rm -f build/*/Makefile
make viewer \
make pilot \
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=ON \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"

- name: make run_viewer_pytest
- name: make run_pilot_pytest
run: |
make run_viewer_pytest VERBOSE=1
make run_pilot_pytest VERBOSE=1

# FIXME: turn off until all issues resolved
- name: make cmake USE_SANITIZER=ON & make pytest
Expand Down Expand Up @@ -563,19 +563,19 @@ jobs:
--config ${{ matrix.cmake_build_type }} `
--target run_gtest

- name: cmake run_viewer_pytest
- name: cmake run_pilot_pytest
run: |
cmake --build ${{ github.workspace }}/build `
--config ${{ matrix.cmake_build_type }} `
--target run_viewer_pytest
--target run_pilot_pytest

- name: generate portable
if: ${{ matrix.cmake_build_type == 'Release' }}
run: |
# Get the Python version installed and extract the major+minor version components
$py_ver=$(python3 -V | awk '{print $2}')
$py_main_ver=$(echo $py_ver | awk -F. '{print $1$2}')
$destination=".\modmesh-viewer-win64\modmesh-viewer-win64"
$destination=".\modmesh-pilot-win64\modmesh-pilot-win64"
$py_exec="$destination\python.exe"

# Create the destination directory
Expand All @@ -597,25 +597,25 @@ jobs:
Invoke-WebRequest -Uri $get_pip_url -OutFile $get_pip_script
& $py_exec $get_pip_script

# Install necessary packages for the viewer
# Install necessary packages for the pilot
$qt_ver=$(qmake -query QT_VERSION)
& $py_exec -m pip install numpy matplotlib PySide6==$qt_ver shiboken6-generator==$qt_ver

# Copy pyside6 and shiboken6 DLLs alongside the viewer executable
# Copy pyside6 and shiboken6 DLLs alongside the pilot executable
$pyside6_path=$(& $py_exec -c "import sys, os, PySide6; sys.stdout.write(os.path.dirname(PySide6.__file__))")
$shiboken6_path=$(& $py_exec -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))")
copy "$pyside6_path\pyside6.abi3.dll" $destination
copy "$shiboken6_path\shiboken6.abi3.dll" $destination
# Remove redundant Qt DLLs from PySide6
Remove-Item -Path $pyside6_path\Qt*.dll

# Configure and build the viewer
# Configure and build the pilot
cmake -Dpybind11_DIR="$(pybind11-config --cmakedir)" -S . -B build
cmake --build build --config Release --target viewer
cmake --build build --config Release --target pilot

# Deploy the Qt environment for the viewer executable and copy necessary files
Copy-Item -Path ".\build\cpp\binary\viewer\Release\viewer.exe" -Destination $destination
windeployqt --release "$destination\viewer.exe"
# Deploy the Qt environment for the pilot executable and copy necessary files
Copy-Item -Path ".\build\cpp\binary\viewer\Release\pilot.exe" -Destination $destination
windeployqt --release "$destination\pilot.exe"
Copy-Item -Path ".\modmesh" -Destination $destination -Recurse
# PUI is necessary
Copy-Item -Path ".\thirdparty" -Destination $destination -Recurse
Expand All @@ -624,5 +624,5 @@ jobs:
if: ${{ matrix.cmake_build_type == 'Release' }}
uses: actions/upload-artifact@v4
with:
name: modmesh-viewer-win64
path: modmesh-viewer-win64/
name: modmesh-pilot-win64
path: modmesh-pilot-win64/
20 changes: 10 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ jobs:
- name: make cinclude (check_include)
run: make cinclude

- name: make viewer
- name: make pilot
run: |
make viewer \
make pilot \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"

- name: make run_viewer_pytest
- name: make run_pilot_pytest
run: |
export LD_LIBRARY_PATH=$(python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))")
make run_viewer_pytest \
make run_pilot_pytest \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
Expand Down Expand Up @@ -278,28 +278,28 @@ jobs:
- name: make cinclude (check_include)
run: make cinclude

- name: make viewer USE_PYTEST_HELPER_BINDING=OFF
- name: make pilot USE_PYTEST_HELPER_BINDING=OFF
run: |
make viewer \
make pilot \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"

- name: make viewer USE_PYTEST_HELPER_BINDING=ON
- name: make pilot USE_PYTEST_HELPER_BINDING=ON
run: |
rm -f build/*/Makefile
make viewer \
make pilot \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"

- name: make run_viewer_pytest
- name: make run_pilot_pytest
run: |
# PySide6 installed by pip will bundle with a prebuilt Qt,
# this will cause duplicated symbol.
# Solve this issue by removed PySide6 prebuilt Qt library
rm -rf $(python3 -c "import sys, os, PySide6; sys.stdout.write(os.path.dirname(PySide6.__file__))")/Qt/lib/*.framework
make run_viewer_pytest \
make run_pilot_pytest \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ pytest: buildext
env $(RUNENV) \
$(PYTEST) $(PYTEST_OPTS) tests/

.PHONY: viewer
viewer: cmake
.PHONY: pilot
pilot: cmake
cmake --build $(BUILD_PATH) --target $@ VERBOSE=$(VERBOSE) $(MAKE_PARALLEL)

.PHONY: gtest
gtest: cmake
cmake --build $(BUILD_PATH) --target run_gtest VERBOSE=$(VERBOSE) $(MAKE_PARALLEL)

.PHONY: run_viewer_pytest
run_viewer_pytest: viewer
.PHONY: run_pilot_pytest
run_pilot_pytest: pilot
cmake --build $(BUILD_PATH) --target $@ VERBOSE=$(VERBOSE)

.PHONY: standalone_buffer_setup
Expand Down
34 changes: 17 additions & 17 deletions cpp/binary/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# BSD-style license; see COPYING

cmake_minimum_required(VERSION 3.16)
project(viewer LANGUAGES CXX)
project(pilot LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# get the root of the modmdesh project
set(PROJECT_ROOT_DIR ${PROJECT_SOURCE_DIR}/../../../)

if(NOT DEFINED INSTALL_VIEWERDIR)
set(INSTALL_VIEWERDIR "viewer")
set(INSTALL_VIEWERDIR "pilot")
endif()

set(CMAKE_AUTOMOC ON)
Expand All @@ -31,66 +31,66 @@ if(APPLE)
set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

qt_add_executable(
viewer
pilot
MACOSX_BUNDLE
viewer.cpp
${app_icon_macos}
)
else()
qt_add_executable(
viewer
pilot
viewer.cpp
)
endif()

target_link_libraries(
viewer PUBLIC
pilot PUBLIC
pybind11::embed
modmesh_primary
)
if(WIN32)
set_target_properties(
viewer
pilot
PROPERTIES
LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE" # open the console for debug mode
)
endif(WIN32)

qt_add_resources(
viewer "app_icon"
pilot "app_icon"
PREFIX "/"
BASE ${PROJECT_ROOT_DIR}/resources/viewer
FILES
${PROJECT_ROOT_DIR}/resources/viewer/icon.ico
)

if(HIDE_SYMBOL)
set_target_properties(viewer PROPERTIES CXX_VISIBILITY_PRESET "hidden")
set_target_properties(pilot PROPERTIES CXX_VISIBILITY_PRESET "hidden")
else()
set_target_properties(viewer PROPERTIES CXX_VISIBILITY_PRESET "default")
set_target_properties(pilot PROPERTIES CXX_VISIBILITY_PRESET "default")
endif()

target_compile_options(
viewer PRIVATE
pilot PRIVATE
${COMMON_COMPILER_OPTIONS}
)

if(CLANG_TIDY_EXE AND USE_CLANG_TIDY)
set_target_properties(
viewer PROPERTIES
pilot PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
endif()

# Hack: add a .clang-tidy file in the generated .rcc directory.
# See https://gitlab.kitware.com/cmake/cmake/-/merge_requests/777
file(WRITE "${viewer_BINARY_DIR}/.rcc/.clang-tidy" "---
file(WRITE "${pilot_BINARY_DIR}/.rcc/.clang-tidy" "---
Checks: '-*,llvm-twine-local'")
file(WRITE "${viewer_BINARY_DIR}/viewer_autogen/.clang-tidy" "---
file(WRITE "${pilot_BINARY_DIR}/viewer_autogen/.clang-tidy" "---
Checks: '-bugprone-suspicious-include,llvm-twine-local'")

set_target_properties(
viewer PROPERTIES
pilot PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
Expand All @@ -101,16 +101,16 @@ if(APPLE)
find_library(APPLE_FWK_METAL Metal REQUIRED)

target_link_libraries(
viewer PUBLIC
pilot PUBLIC
${APPLE_FWK_FOUNDATION}
${APPLE_FWK_QUARTZ_CORE}
${APPLE_FWK_METAL}
)
endif()

add_custom_target(run_viewer_pytest $<TARGET_FILE:viewer> --mode=pytest)
add_custom_target(run_pilot_pytest $<TARGET_FILE:pilot> --mode=pytest)

install(TARGETS viewer
install(TARGETS pilot
RUNTIME DESTINATION "${INSTALL_VIEWERDIR}"
BUNDLE DESTINATION "${INSTALL_VIEWERDIR}"
LIBRARY DESTINATION "${INSTALL_VIEWERDIR}"
Expand Down
6 changes: 4 additions & 2 deletions cpp/modmesh/python/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ void initialize(pybind11::module_ mod)
#endif

#ifdef QT_CORE_LIB
mod.attr("HAS_VIEW") = true;
mod.attr("HAS_VIEW") = true; // backward compatibility
mod.attr("HAS_PILOT") = true;
pybind11::module_ view_mod = mod.def_submodule("view", "view");
initialize_view(view_mod);
#else // QT_CORE_LIB
mod.attr("HAS_VIEW") = false;
mod.attr("HAS_VIEW") = false; // backward compatibility
mod.attr("HAS_PILOT") = false;
#endif // QT_CORE_LIB
}

Expand Down
2 changes: 1 addition & 1 deletion modmesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from . import core
from .core import * # noqa: F401, F403
from . import apputil # noqa: F401
from . import view # noqa: F401
from . import pilot # noqa: F401
from . import spacetime # noqa: F401
from . import onedim # noqa: F401
from . import system # noqa: F401
Expand Down
4 changes: 2 additions & 2 deletions modmesh/app/bad_euler1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
from matplotlib.figure import Figure

from .. import view
from .. import pilot
from .. import spacetime as libst


def load_app():
cmd = "win, svr = mm.app.bad_euler1d.run(animate=True, interval=10)"
view.mgr.pycon.command = cmd
pilot.mgr.pycon.command = cmd


class ApplicationWindow(QtWidgets.QMainWindow):
Expand Down
10 changes: 5 additions & 5 deletions modmesh/app/euler1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from PUI.PySide6.toolbar import ToolBar
from PUI.PySide6.modal import Modal
from ..onedim import euler1d
from .. import view
from .. import pilot


@dataclass
Expand Down Expand Up @@ -677,8 +677,8 @@ def log(msg):
if sys.stdout is not None:
sys.stdout.write(msg)
sys.stdout.write('\n')
view.mgr.pycon.writeToHistory(msg)
view.mgr.pycon.writeToHistory('\n')
pilot.mgr.pycon.writeToHistory(msg)
pilot.mgr.pycon.writeToHistory('\n')

def update_lines(self):
"""
Expand Down Expand Up @@ -833,8 +833,8 @@ def load_app():
config_widget = QDockWidget("config")
config_widget.setWidget(config_window.ui.ui)

view.mgr.mainWindow.addDockWidget(Qt.LeftDockWidgetArea, config_widget)
_subwin = view.mgr.addSubWindow(plotting_area.ui.ui)
pilot.mgr.mainWindow.addDockWidget(Qt.LeftDockWidgetArea, config_widget)
_subwin = pilot.mgr.addSubWindow(plotting_area.ui.ui)
_subwin.showMaximized()

config_window.redraw()
Expand Down
4 changes: 2 additions & 2 deletions modmesh/app/linear_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
FigureCanvas, NavigationToolbar2QT as NavigationToolbar)
from matplotlib.figure import Figure

from .. import view
from .. import pilot
from .. import spacetime as libst


def load_app():
cmd = "win, svr = mm.app.linear_wave.run_linear(animate=True, interval=10)"
view.mgr.pycon.command = cmd
pilot.mgr.pycon.command = cmd


class ApplicationWindow(QtWidgets.QMainWindow):
Expand Down
Loading
Loading