Skip to content

Commit

Permalink
Improving form style. Adding MD duration preview scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinGuillaume committed May 23, 2024
1 parent 4986c09 commit ccc3e50
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 12 deletions.
Binary file modified lib/tool/tools/mdprep/include/tools/mdprep/ui/basic_form.hpp
Binary file not shown.
Binary file not shown.
Binary file modified lib/tool/tools/mdprep/include/tools/mdprep/ui/form_data.hpp
Binary file not shown.
Binary file modified lib/tool/tools/mdprep/include/tools/mdprep/ui/md_engine_form.hpp
Binary file not shown.
46 changes: 36 additions & 10 deletions lib/tool/tools/mdprep/src/mdprep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

namespace VTX::QT::Mdprep
{


// Class responsible for managing the mdprep main window by coordinating the common form and the md engine
// specifics.
class MainWindow : public UI::QT::QtDockablePanel
{
using FormCollection
= std::array<std::optional<VTX::Tool::Mdprep::ui::MdEngineForm>, VTX::Tool::Mdprep::ui::MD_ENGINE_NUMBER>;

inline static const QSize PREFERRED_SIZE { 640, 720 };
inline static const QSize PREFERRED_SIZE { 500, 720 };
QComboBox * _w_mdEngine = nullptr;

VTX::Tool::Mdprep::ui::MdFieldsOrganizer _fieldOrganizer;
Expand All @@ -50,20 +52,42 @@ namespace VTX::QT::Mdprep
this->setWindowTitle( "Molecular Dynamics Preparation" );

setWindowState( Qt::WindowState::WindowActive );
const QSize winsize = QSize( 640, 720 );
const QSize winsize = PREFERRED_SIZE;
resize( winsize );

QVBoxLayout * windowLayout = new QVBoxLayout( mainWidget );
windowLayout->setContentsMargins( 0, 0, 0, 0 );
QVBoxLayout * qLayoutWindow = new QVBoxLayout( mainWidget );
qLayoutWindow->setContentsMargins( 0, 0, 0, 0 );
qLayoutWindow->addSpacerItem( new QSpacerItem( 0, 10 ) );

QHBoxLayout * qLayoutCentering = new QHBoxLayout;
qLayoutWindow->addLayout( qLayoutCentering );

// following content is meant to be moved eventually
_w_mdEngine = new QComboBox;
for ( auto & it : VTX::Tool::Mdprep::ui::mdEngineStrings() )
_w_mdEngine->addItem( QString( it ) );
_w_mdEngine->setCurrentIndex( _mdEngineCurrentIdx );
windowLayout->addWidget( _w_mdEngine, 1 );

_fieldOrganizer.setupUi( windowLayout );
qLayoutCentering->addStretch( 1 );

QFormLayout * qLayoutFormEngine = new QFormLayout;
qLayoutCentering->addLayout( qLayoutFormEngine );
QLabel * qLabelMdEngine = new QLabel( "Choose your MD engine" );
{
auto font = qLabelMdEngine->font();
font.setPointSize( font.pointSize() + 2 );
qLabelMdEngine->setFont( font );
font = _w_mdEngine->font();
font.setPointSize( font.pointSize() + 2 );
_w_mdEngine->setFont( font );
}
qLayoutFormEngine->addRow( qLabelMdEngine, _w_mdEngine );

qLayoutCentering->addStretch( 1 );

qLayoutWindow->addSpacerItem( new QSpacerItem( 0, 10 ) );

_fieldOrganizer.setupUi( qLayoutWindow );
_formBasic.setupUi( _fieldOrganizer.containerParamBasic );
}
void _updateFormEngine( int idx ) noexcept
Expand All @@ -80,10 +104,12 @@ namespace VTX::QT::Mdprep
);
_formsMd[ _mdEngineCurrentIdx ]->activate();

const VTX::Tool::Mdprep::ui::EngineSpecificCommonFormData * engineSpecificData = nullptr;
_formsMd[ _mdEngineCurrentIdx ]->get( engineSpecificData );
if ( engineSpecificData )
_formBasic.update( *engineSpecificData );
{
const VTX::Tool::Mdprep::ui::EngineSpecificCommonFormData * engineSpecificData = nullptr;
_formsMd[ _mdEngineCurrentIdx ]->get( engineSpecificData );
if ( engineSpecificData )
_formBasic.update( *engineSpecificData );
}

VTX::VTX_DEBUG( "info from Mdprep::MainWindow::_updateFormEngine({})", idx );
}
Expand Down
Binary file modified lib/tool/tools/mdprep/src/ui/basic_form.cpp
Binary file not shown.
Binary file modified lib/tool/tools/mdprep/src/ui/engine_form_gromacs.cpp
Binary file not shown.
16 changes: 14 additions & 2 deletions lib/tool/tools/mdprep/src/ui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace VTX::Tool::Mdprep::ui
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
return "DEBUUUG"; // For developers that add new MD Engine support
}
namespace
{
Expand All @@ -36,12 +36,24 @@ namespace VTX::Tool::Mdprep::ui

const std::array<const char *, MD_ENGINE_NUMBER> & mdEngineStrings() { return g_mdEngineStrings; }

namespace
{
class NoopForm
{
public:
NoopForm() = default;
void get( const VTX::Tool::Mdprep::ui::EngineSpecificCommonFormData *& ) const noexcept {}
void activate() noexcept {}
void deactivate() noexcept {}
};
} // namespace

MdEngineForm form( const E_MD_ENGINE & p_engine, FormLayouts p_layout ) noexcept
{
switch ( p_engine )
{
case E_MD_ENGINE::gromacs: return { EngineFormGromacs( std::move( p_layout ) ) };
default: return { EngineFormGromacs( std::move( p_layout ) ) }; // Default is gromacs. Period.
default: return { NoopForm() }; // Default is gromacs. Period.
}
}

Expand Down

0 comments on commit ccc3e50

Please sign in to comment.