diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index d2fda20a5..8595f165d 100644 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -82,12 +82,13 @@ include("${DIR_LIBS}/ui/test/cmake/library.cmake") vtx_clear_registered_copies() -# Tool. -include("${DIR_LIBS}/tool/cmake/library.cmake") - # MdPrep. include("${DIR_LIBS}/tool/tools/mdprep/cmake/library.cmake") # MdPrep test. include("${DIR_LIBS}/tool/tools/mdprep/test/cmake/library.cmake") +# Tool. +include("${DIR_LIBS}/tool/cmake/library.cmake") + + diff --git a/lib/tool/include/tool/mdprep.hpp b/lib/tool/include/tool/mdprep.hpp index 896acde22..2959ccb40 100644 --- a/lib/tool/include/tool/mdprep.hpp +++ b/lib/tool/include/tool/mdprep.hpp @@ -23,6 +23,13 @@ namespace VTX::Tool private: void _addButtonsInMenu(); void _openMdPrepWindow(); + + struct Data; + struct Del + { + void operator()( Data * ) const noexcept; + }; + std::unique_ptr _data = nullptr; }; } // namespace VTX::Tool diff --git a/lib/tool/src/tool/mdprep.cpp b/lib/tool/src/tool/mdprep.cpp index 7d38bcdc6..8f1a9e158 100644 --- a/lib/tool/src/tool/mdprep.cpp +++ b/lib/tool/src/tool/mdprep.cpp @@ -1,4 +1,5 @@ #include "tool/mdprep.hpp" +#include "tools/mdprep/mdprep.hpp" #include "ui/qt/application_qt.hpp" #include "ui/qt/main_window.hpp" #include "ui/qt/tool/pytx/details/include_python_binding.hpp" @@ -12,6 +13,11 @@ namespace VTX::Tool { + struct ToolMdprep::Data + { + VTX::Tool::Mdprep::MainWindow mainWindow; + }; + ToolMdprep::ToolMdprep() {} void ToolMdprep::instantiateTool() { @@ -32,12 +38,18 @@ namespace VTX::Tool = VTX::UI::QT::WidgetFactory::get().instantiateWidget( &toolBlock, "MdPrepButton" ); - // button->setData( "MD prep", ":/sprite/info_button.png", Qt::Orientation::Vertical ); button->setData( "MD prep", ":/sprite/icon_tool_mdprep_mainButton.png", Qt::Orientation::Vertical ); button->setTriggerAction( this, &ToolMdprep::_openMdPrepWindow ); toolBlock.pushButton( *button ); } - void ToolMdprep::_openMdPrepWindow() { VTX_INFO( "Opening ToolMdprep window" ); } + void ToolMdprep::_openMdPrepWindow() + { + VTX_INFO( "Opening ToolMdprep window" ); + _data.reset( new Data() ); + _data->mainWindow.show(); + } + + void VTX::Tool::ToolMdprep::Del::operator()( Data * p_ ) const noexcept { delete p_; } } // namespace VTX::Tool diff --git a/lib/tool/tools/mdprep/cmake/library.cmake b/lib/tool/tools/mdprep/cmake/library.cmake index 1544f9852..b63036130 100644 --- a/lib/tool/tools/mdprep/cmake/library.cmake +++ b/lib/tool/tools/mdprep/cmake/library.cmake @@ -9,6 +9,7 @@ set(SOURCES "") set(QT_FORMS "") set(QT_RESOURCES "") file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_LIST_DIR}/../include/*") +message("mdprep headers : <${HEADERS}>") file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_LIST_DIR}/../src/*") file(GLOB_RECURSE QT_FORMS asset/qt/forms/*.ui) file(GLOB_RECURSE QT_RESOURCES asset/qt/resources/*.qrc) @@ -23,10 +24,12 @@ if (NOT DEFINED _VTX_MDPREP_CONAN) target_link_libraries(vtx_tool_mdprep PRIVATE vtx_util) target_link_libraries(vtx_tool_mdprep PRIVATE vtx_core) target_link_libraries(vtx_tool_mdprep PRIVATE vtx_app) + target_link_libraries(vtx_tool_mdprep PRIVATE vtx_ui) else() target_link_libraries(vtx_tool_mdprep PRIVATE vtx_util::vtx_util) target_link_libraries(vtx_tool_mdprep PRIVATE vtx_core::vtx_core) target_link_libraries(vtx_tool_mdprep PRIVATE vtx_app::vtx_app) + target_link_libraries(vtx_tool_mdprep PRIVATE vtx_ui::vtx_ui) endif() target_link_libraries(vtx_tool_mdprep PRIVATE Qt6::Core) target_link_libraries(vtx_tool_mdprep PRIVATE Qt6::Gui) diff --git a/lib/tool/tools/mdprep/conanfile.py b/lib/tool/tools/mdprep/conanfile.py index 084066e1b..815c64559 100644 --- a/lib/tool/tools/mdprep/conanfile.py +++ b/lib/tool/tools/mdprep/conanfile.py @@ -24,6 +24,7 @@ class VTXToolMdprepRecipe(ConanFile): def requirements(self): self.requires("vtx_util/1.0") self.requires("vtx_app/1.0") + self.requires("vtx_core/1.0") self.requires("vtx_ui/1.0") self.requires("re2/20231101") self.requires("gromacs/2024.0") diff --git a/lib/tool/tools/mdprep/include/tools/mdprep/mdprep.hpp b/lib/tool/tools/mdprep/include/tools/mdprep/mdprep.hpp index ac5dfbb08..42dcebb06 100644 --- a/lib/tool/tools/mdprep/include/tools/mdprep/mdprep.hpp +++ b/lib/tool/tools/mdprep/include/tools/mdprep/mdprep.hpp @@ -1,5 +1,25 @@ +#ifndef __VTX_TOOL_TOOLS_MDPREP__ +#define __VTX_TOOL_TOOLS_MDPREP__ +#include namespace VTX::Tool::Mdprep { + // Designed to be the self-contained window that allow the user to use the MDprep tool + class MainWindow + { + public: + MainWindow(); + + void show() noexcept; + + private: + class _impl; + struct Del + { + void operator()( _impl * ) noexcept; + }; + std::unique_ptr<_impl, Del> _pimpl = nullptr; + }; } // namespace VTX::Tool::Mdprep +#endif diff --git a/lib/tool/tools/mdprep/include/tools/mdprep/ui/main_window.hpp b/lib/tool/tools/mdprep/include/tools/mdprep/ui/main_window.hpp new file mode 100644 index 000000000..5015b3c8f --- /dev/null +++ b/lib/tool/tools/mdprep/include/tools/mdprep/ui/main_window.hpp @@ -0,0 +1,20 @@ +#ifndef __VTX_TOOL_TOOLS_MDPREP_UI_MAINWINDOW__ +#define __VTX_TOOL_TOOLS_MDPREP_UI_MAINWINDOW__ + +#include +#include + +namespace VTX::Tool::Mdprep::ui +{ + enum class E_MD_ENGINE + { + gromacs, + COUNT + }; + constexpr const size_t MD_ENGINE_NUMBER = static_cast( E_MD_ENGINE::COUNT ); + constexpr const char * string( const E_MD_ENGINE & ) noexcept; + + const std::array & mdEngineStrings(); +} // namespace VTX::Tool::Mdprep::ui + +#endif diff --git a/lib/tool/tools/mdprep/src/mdprep.cpp b/lib/tool/tools/mdprep/src/mdprep.cpp index b2a9282b6..de3ee280a 100644 --- a/lib/tool/tools/mdprep/src/mdprep.cpp +++ b/lib/tool/tools/mdprep/src/mdprep.cpp @@ -1,6 +1,81 @@ #include "tools/mdprep/mdprep.hpp" +#include "tools/mdprep/ui/main_window.hpp" +#include +#include +#include +#include +#include +#include + +namespace VTX::QT::Mdprep +{ + class MainWindow : public UI::QT::QtDockablePanel + { + private: + inline static const QSize PREFERRED_SIZE { 640, 720 }; + virtual void _setupUi( const QString & p_name ) + { + auto _t = p_name.toLatin1(); + std::string v( _t.begin(), _t.end() ); + VTX::VTX_INFO( "info from Mdprep::MainWindow::_setupUi : <{}>", v ); + QWidget * const mainWidget = _instantiateMainWidget( PREFERRED_SIZE, PREFERRED_SIZE ); + + UI::QT::QtDockablePanel::_setupUi( p_name ); + + this->setWindowTitle( "Molecular Dynamics Preparation" ); + + setWindowState( Qt::WindowState::WindowActive ); + const QSize winsize = QSize( 640, 720 ); + resize( winsize ); + + QVBoxLayout * windowLayout = new QVBoxLayout( mainWidget ); + windowLayout->setContentsMargins( 0, 0, 0, 0 ); + + QComboBox * engineList = new QComboBox; + for ( auto & it : VTX::Tool::Mdprep::ui::mdEngineStrings() ) + engineList->addItem( QString( it ) ); + + QWidget * mainContainer = new QWidget( this ); + mainContainer->setStyleSheet( "border: 1px solid red" ); + mainContainer->setSizePolicy( QSizePolicy( QSizePolicy ::Expanding, QSizePolicy ::Expanding ) ); + windowLayout->addWidget( mainContainer, 1 ); + QHBoxLayout * hLayout = new QHBoxLayout( mainContainer ); + + auto layoutToAddThoseTextboxTo = hLayout; + + QLineEdit * textbox = new QLineEdit(); + textbox->setText( "textbox" ); + // QFormLayout * layout = new QFormLayout( this ); + // layout->addRow( tr( "&Textbox:" ), textbox ); + // layout->addRow( tr( "&Textbox2:" ), textbox2 ); + // hLayout->addLayout( layout ); + layoutToAddThoseTextboxTo->addWidget( engineList, 1 ); + layoutToAddThoseTextboxTo->addWidget( textbox, 1 ); + } + virtual void _setupSlots() { VTX::VTX_INFO( "info from Mdprep::MainWindow::_setupSlots" ); } + + public: + MainWindow( QWidget * const p_parent = nullptr ) : UI::QT::QtDockablePanel( p_parent ) + { + _setupUi( "Is this parameter useful ?" ); + } + }; +} // namespace VTX::QT::Mdprep namespace VTX::Tool::Mdprep { + class MainWindow::_impl + { + VTX::QT::Mdprep::MainWindow _win { &VTX::UI::QT::QT_APP()->getMainWindow() }; + + public: + _impl() {} + void show() noexcept { _win.show(); } + }; + MainWindow::MainWindow() : _pimpl( new MainWindow::_impl() ) {} + + // Assumes pimpl is always valid ptr + void MainWindow::show() noexcept { _pimpl->show(); } + void MainWindow::Del::operator()( _impl * p_ ) noexcept { delete p_; } } // namespace VTX::Tool::Mdprep diff --git a/lib/tool/tools/mdprep/src/ui/main_window.cpp b/lib/tool/tools/mdprep/src/ui/main_window.cpp new file mode 100644 index 000000000..5942bed54 --- /dev/null +++ b/lib/tool/tools/mdprep/src/ui/main_window.cpp @@ -0,0 +1,29 @@ +#include "tools/mdprep/ui/main_window.hpp" + +namespace VTX::Tool::Mdprep::ui +{ + constexpr const char * string( const E_MD_ENGINE & p_ ) noexcept + { + switch ( p_ ) + { + case E_MD_ENGINE::gromacs: return { "Gromacs" }; + default: break; + } + return "Please provide a user string for the MD engine"; // For developers that add new MD Engine support + } + namespace + { + constexpr std::array createMdEngineStringList() + { + std::array out; + for ( int i = 0; i < MD_ENGINE_NUMBER; i++ ) + { + out[ i ] = string( static_cast( i ) ); + } + return out; + } + } // namespace + constexpr const std::array g_mdEngineStrings = createMdEngineStringList(); + + const std::array & mdEngineStrings() { return g_mdEngineStrings; } +} // namespace VTX::Tool::Mdprep::ui