Skip to content

Commit

Permalink
WIP - Assembling GUI for MDprep
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinGuillaume committed May 16, 2024
1 parent 8ad451c commit a38d07d
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 5 deletions.
7 changes: 4 additions & 3 deletions dev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")


7 changes: 7 additions & 0 deletions lib/tool/include/tool/mdprep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, Del> _data = nullptr;
};
} // namespace VTX::Tool

Expand Down
16 changes: 14 additions & 2 deletions lib/tool/src/tool/mdprep.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -12,6 +13,11 @@
namespace VTX::Tool
{

struct ToolMdprep::Data
{
VTX::Tool::Mdprep::MainWindow mainWindow;
};

ToolMdprep::ToolMdprep() {}
void ToolMdprep::instantiateTool()
{
Expand All @@ -32,12 +38,18 @@ namespace VTX::Tool
= VTX::UI::QT::WidgetFactory::get().instantiateWidget<VTX::UI::QT::Widget::MainMenu::MenuToolButtonWidget>(
&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
3 changes: 3 additions & 0 deletions lib/tool/tools/mdprep/cmake/library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/tool/tools/mdprep/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 20 additions & 0 deletions lib/tool/tools/mdprep/include/tools/mdprep/mdprep.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#ifndef __VTX_TOOL_TOOLS_MDPREP__
#define __VTX_TOOL_TOOLS_MDPREP__

#include <memory>

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
20 changes: 20 additions & 0 deletions lib/tool/tools/mdprep/include/tools/mdprep/ui/main_window.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef __VTX_TOOL_TOOLS_MDPREP_UI_MAINWINDOW__
#define __VTX_TOOL_TOOLS_MDPREP_UI_MAINWINDOW__

#include <array>
#include <string>

namespace VTX::Tool::Mdprep::ui
{
enum class E_MD_ENGINE
{
gromacs,
COUNT
};
constexpr const size_t MD_ENGINE_NUMBER = static_cast<size_t>( E_MD_ENGINE::COUNT );
constexpr const char * string( const E_MD_ENGINE & ) noexcept;

const std::array<const char *, MD_ENGINE_NUMBER> & mdEngineStrings();
} // namespace VTX::Tool::Mdprep::ui

#endif
75 changes: 75 additions & 0 deletions lib/tool/tools/mdprep/src/mdprep.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,81 @@
#include "tools/mdprep/mdprep.hpp"
#include "tools/mdprep/ui/main_window.hpp"
#include <qcombobox.h>
#include <qformlayout.h>
#include <qlineedit.h>
#include <ui/qt/application_qt.hpp>
#include <ui/qt/main_window.hpp>
#include <util/logger.hpp>

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
29 changes: 29 additions & 0 deletions lib/tool/tools/mdprep/src/ui/main_window.cpp
Original file line number Diff line number Diff line change
@@ -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<const char *, MD_ENGINE_NUMBER> createMdEngineStringList()
{
std::array<const char *, MD_ENGINE_NUMBER> out;
for ( int i = 0; i < MD_ENGINE_NUMBER; i++ )
{
out[ i ] = string( static_cast<E_MD_ENGINE>( i ) );
}
return out;
}
} // namespace
constexpr const std::array<const char *, MD_ENGINE_NUMBER> g_mdEngineStrings = createMdEngineStringList();

const std::array<const char *, MD_ENGINE_NUMBER> & mdEngineStrings() { return g_mdEngineStrings; }
} // namespace VTX::Tool::Mdprep::ui

0 comments on commit a38d07d

Please sign in to comment.