Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev-sge
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Mar 19, 2024
2 parents 019f3c9 + bfb3e86 commit 269e42c
Show file tree
Hide file tree
Showing 71 changed files with 1,124 additions and 522 deletions.
44 changes: 44 additions & 0 deletions lib/app/include/app/application/renderer/proxy_wrapper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef __VTX_APP_APPLICATION_RENDERER_PROXY_WRAPPER__
#define __VTX_APP_APPLICATION_RENDERER_PROXY_WRAPPER__

#include "app/application/renderer/renderer_accessor.hpp"
#include "app/application/system/renderer.hpp"
#include <memory>

namespace VTX::App::Application::Renderer
{
template<typename T>
class ProxyWrapper
{
public:
class ProxyAccessor
{
friend ProxyWrapper;

public:
T & proxy() { return _wrapper.proxy(); }
~ProxyAccessor() = default;

private:
ProxyAccessor( ProxyWrapper & p_wrapper ) : _wrapper( p_wrapper ), _rendererAccessor( App::RENDERER() ) {}

Application::Renderer::RendererAccessor _rendererAccessor;
ProxyWrapper & _wrapper;
};

ProxyWrapper() {}
ProxyWrapper( std::unique_ptr<T> & p_proxyPtr ) : _proxyPtr( std::move( p_proxyPtr ) ) {}

void setProxy( std::unique_ptr<T> & p_proxyPtr ) { _proxyPtr = std::move( p_proxyPtr ); }
bool isValid() { return _proxyPtr != nullptr; }

ProxyAccessor accessor() { return ProxyAccessor( *this ); }
T & proxy() { return *_proxyPtr; }
const T & proxy() const { return *_proxyPtr; }

private:
std::unique_ptr<T> _proxyPtr = nullptr;
};

} // namespace VTX::App::Application::Renderer
#endif
23 changes: 23 additions & 0 deletions lib/app/include/app/application/renderer/renderer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef __VTX_APP_APPLICATION_RENDERER_RENDERER__
#define __VTX_APP_APPLICATION_RENDERER_RENDERER__

#include <memory>
#include <renderer/facade.hpp>

namespace VTX::App::Application::Renderer
{
class Renderer
{
public:
Renderer() = default;
void init();

VTX::Renderer::Facade & get();
const VTX::Renderer::Facade & get() const;

private:
std::unique_ptr<VTX::Renderer::Facade> _rendererPtr = nullptr;
};

} // namespace VTX::App::Application::Renderer
#endif
34 changes: 34 additions & 0 deletions lib/app/include/app/application/renderer/renderer_accessor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef __VTX_APP_APPLICATION_RENDERER_RENDERER_ACCESSOR__
#define __VTX_APP_APPLICATION_RENDERER_RENDERER_ACCESSOR__

#include "app/application/renderer/renderer.hpp"
#include <renderer/facade.hpp>
#include <util/callback.hpp>

namespace VTX::App::Application::Renderer
{
class RendererAccessor
{
public:
RendererAccessor(
Renderer & p_renderer,
const Util::Callback<> & p_onGet,
const Util::Callback<> & p_onRelease
);
~RendererAccessor();

Renderer & get();
const Renderer & get() const;

VTX::Renderer::Facade & facade();
const VTX::Renderer::Facade & facade() const;

private:
Renderer & _renderer;

const Util::Callback<> & onGet;
const Util::Callback<> & onRelease;
};

} // namespace VTX::App::Application::Renderer
#endif
38 changes: 28 additions & 10 deletions lib/app/include/app/application/selection/selection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <concepts>
#include <map>
#include <set>
#include <util/callback.hpp>
#include <util/concepts.hpp>
#include <util/math/aabb.hpp>

Expand Down Expand Up @@ -287,17 +288,37 @@ namespace VTX::App::Application::Selection

SelectionData & getSelectionData( const Component::Scene::Selectable & p_selectableComponent );
const SelectionData & getSelectionData( const Component::Scene::Selectable & p_selectableComponent ) const;
template<SelectionDataConcept T>
T & getSelectionData( const Component::Scene::Selectable & p_selectableComponent )
{
return dynamic_cast<T &>( getSelectionData( p_selectableComponent ) );
}
template<SelectionDataConcept T>
const T & getSelectionData( const Component::Scene::Selectable & p_selectableComponent ) const
{
return dynamic_cast<T &>( getSelectionData( p_selectableComponent ) );
}

template<Core::ECS::ECS_Component C>
SelectionData & getSelectionData( const C & p_component )
SelectionData & getSelectionDataFromComponent( const C & p_component )
{
return getSelectionData( MAIN_REGISTRY().getComponent<Component::Scene::Selectable>( p_component ) );
}
template<Core::ECS::ECS_Component C>
const SelectionData & getSelectionData( const C & p_component ) const
const SelectionData & getSelectionDataFromComponent( const C & p_component ) const
{
return getSelectionData( MAIN_REGISTRY().getComponent<Component::Scene::Selectable>( p_component ) );
}
template<SelectionDataConcept T, Core::ECS::ECS_Component C>
T & getSelectionDataFromComponent( const C & p_component )
{
return getSelectionData<T>( MAIN_REGISTRY().getComponent<Component::Scene::Selectable>( p_component ) );
}
template<SelectionDataConcept T, Core::ECS::ECS_Component C>
const T & getSelectionDataFromComponent( const C & p_component ) const
{
return getSelectionData<T>( MAIN_REGISTRY().getComponent<Component::Scene::Selectable>( p_component ) );
}

inline size_t getCount() const { return _items.size(); }

Expand Down Expand Up @@ -338,8 +359,9 @@ namespace VTX::App::Application::Selection

std::string toString() const;

protected:
void _notifyDataChanged();
Util::Callback<SelectionData> onSelect;
Util::Callback<SelectionData> onDeselect;
Util::Callback<const SelectionData *> onCurrentObjectChange;

private:
SelectionDataSet _items = SelectionDataSet();
Expand All @@ -348,12 +370,8 @@ namespace VTX::App::Application::Selection
const std::unique_ptr<SelectionData> & _getSelectionDataPtr( const Component::Scene::Selectable & p_selectable
) const;

void _clearWithoutNotify();

// void _refreshMoleculeSelection( App::Old::Component::Chemistry::Molecule * const );

void _setCurrentObject( const SelectionData * const p_model, const bool p_notify = true );
void _clearCurrentObject( const bool p_notify = true );
void _setCurrentObject( const SelectionData * const p_model );
void _clearCurrentObject();
};

} // namespace VTX::App::Application::Selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ namespace VTX::App::Application::Selection
Selection & getSaved( const std::string & p_name );

private:
void _setCurrentSelection( const Selection & p_selection );
void _linkCallbackToSelectables();

std::unique_ptr<Selection> _currentSelection = std::make_unique<Selection>();

mutable std::map<std::string, std::unique_ptr<Selection>> _savedSelectionMap
Expand Down
37 changes: 37 additions & 0 deletions lib/app/include/app/application/system/renderer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef __VTX_APP_APPLICATION_SYSTEM_RENDERER__
#define __VTX_APP_APPLICATION_SYSTEM_RENDERER__

#include "app/application/renderer/renderer.hpp"
#include "app/application/renderer/renderer_accessor.hpp"
#include "app/application/system/system_registration.hpp"
#include "app/core/system/base_system.hpp"
#include <renderer/facade.hpp>
#include <util/callback.hpp>

namespace VTX::App::Application::System
{
class Renderer : public Core::System::BaseSystem
{
public:
inline static const System::SystemRegistration<Renderer> SYSTEM = System::SystemRegistration<Renderer>();

public:
Renderer() = default;
Application::Renderer::RendererAccessor accessor();
VTX::Renderer::Facade & facade();

Util::Callback<> onGet;
Util::Callback<> onRelease;

private:
Application::Renderer::Renderer _renderer;
};

} // namespace VTX::App::Application::System

namespace VTX::App
{
Application::System::Renderer & RENDERER_SYSTEM();
Application::Renderer::RendererAccessor RENDERER();
} // namespace VTX::App
#endif
3 changes: 3 additions & 0 deletions lib/app/include/app/component/chemistry/bond.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace VTX::App::Component::Chemistry
atom_index_t getIndexSecondAtom() const;
void setIndexSecondAtom( const atom_index_t p_atomIndex );

bool isVisible() const;
void setVisible( const bool p_visible );

private:
Molecule * _moleculePtr = nullptr;
size_t _index = INVALID_INDEX;
Expand Down
5 changes: 5 additions & 0 deletions lib/app/include/app/component/chemistry/chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ namespace VTX::App::Component::Chemistry
Iterator::ResidueContainer residues() const;
Iterator::AtomContainer atoms() const;

bool isVisible() const;
bool isFullyVisible() const;

void setVisible( const bool p_visible );

private:
Molecule * _moleculePtr = nullptr;
size_t _index = INVALID_INDEX;
Expand Down
28 changes: 19 additions & 9 deletions lib/app/include/app/component/chemistry/molecule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include "_fwd.hpp"
#include "app/application/system/ecs_system.hpp"
#include "app/core/uid/uid.hpp"
#include <app/core/visibility/enum.hpp>
#include <core/struct/molecule.hpp>
#include <memory>
#include <util/callback.hpp>
#include <util/math/range_list.hpp>
#include <util/math/transform.hpp>
#include <util/types.hpp>
#include <vector>
Expand All @@ -18,6 +20,10 @@ namespace VTX::App::Component::Render

namespace VTX::App::Component::Chemistry
{

using AtomIndexRange = Util::Math::Range<atom_index_t>;
using AtomIndexRangeList = Util::Math::RangeList<atom_index_t>;

class Molecule
{
private:
Expand Down Expand Up @@ -76,12 +82,16 @@ namespace VTX::App::Component::Chemistry
const std::string & getPdbIdCode() const { return _pdbIdCode; }
void setPdbIdCode( const std::string & p_pdbIdCode ) { _pdbIdCode = p_pdbIdCode; }

bool getAtomVisibility( const size_t p_index ) const { return _atomVisibilities[ p_index ]; }
void setAtomVisibility( const size_t p_index, const bool p_visible )
{
_atomVisibilities[ p_index ] = p_visible;
}
const std::vector<bool> & getAtomVisibilities() const { return _atomVisibilities; }
bool isVisible() const;
bool isFullyVisible() const;

void setVisible( const bool p_visible );
void setVisible( const atom_index_t & p_atomId, bool p_visible );
void setVisible( const AtomIndexRange & p_atomRange, bool p_visible );
void setVisible( const AtomIndexRangeList & p_atomRange, bool p_visible );

const AtomIndexRangeList & getAtomVisibilities() const { return _visibleAtomIds; }
void setAtomVisibilities( const AtomIndexRangeList & p_visibility );

const Core::UID::UIDRange & getAtomUIDs() const { return _atomUidRange; }
const Atom * getAtomFromUID( Core::UID::uid p_uid ) const;
Expand All @@ -91,7 +101,8 @@ namespace VTX::App::Component::Chemistry
const Residue * getResidueFromUID( Core::UID::uid p_uid ) const;
Residue * getResidueFromUID( Core::UID::uid p_uid );

Util::Callback<> onStruct;
Util::Callback<> onStruct;
Util::Callback<AtomIndexRangeList, App::Core::VISIBILITY_APPLY_MODE> onVisibilityChange;

private:
VTX::Core::Struct::Molecule _moleculeStruct = VTX::Core::Struct::Molecule();
Expand All @@ -104,8 +115,7 @@ namespace VTX::App::Component::Chemistry
Util::Math::Transform _transform = Util::Math::Transform();
std::string _pdbIdCode = "";

std::vector<bool> _atomVisibilities = std::vector<bool>();
std::vector<bool> _atomSelections = std::vector<bool>();
AtomIndexRangeList _visibleAtomIds = AtomIndexRangeList();

Core::UID::UIDRange _atomUidRange = Core::UID::UIDRange();
Core::UID::UIDRange _residueUidRange = Core::UID::UIDRange();
Expand Down
5 changes: 5 additions & 0 deletions lib/app/include/app/component/chemistry/residue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ namespace VTX::App::Component::Chemistry

Iterator::AtomContainer atoms() const;

bool isVisible() const;
bool isFullyVisible() const;

void setVisible( const bool p_visible );

private:
Molecule * _moleculePtr = nullptr;
size_t _index = INVALID_INDEX;
Expand Down
5 changes: 5 additions & 0 deletions lib/app/include/app/component/chemistry/trajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "app/application/system/ecs_system.hpp"
#include "app/core/trajectory_player/base_player.hpp"
#include "enum_trajectory.hpp"
#include <util/callback.hpp>

namespace VTX::App::Component::Chemistry
{
Expand All @@ -23,11 +24,15 @@ namespace VTX::App::Component::Chemistry
Molecule * const getMoleculePtr() const { return _moleculePtr; }

size_t getCurrentFrame() const;
void setCurrentFrame( const size_t p_frameIndex );

size_t getFrameCount() const;

App::Core::TrajectoryPlayer::BasePlayer & getPlayer() const { return *_player; }
void setPlayer( std::unique_ptr<App::Core::TrajectoryPlayer::BasePlayer> & p_player );

Util::Callback<size_t> onFrameChange;

private:
void _update( const float p_deltaTime );
void _referenceUpdateFunction();
Expand Down
10 changes: 5 additions & 5 deletions lib/app/include/app/component/render/proxy_camera.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef __VTX_APP_COMPONENT_RENDER_PROXY_CAMERA__
#define __VTX_APP_COMPONENT_RENDER_PROXY_CAMERA__

#include "app/component/render/camera.hpp"
#include "app/application/renderer/proxy_wrapper.hpp"
#include <memory>
#include <renderer/facade.hpp>
#include <renderer/proxy/camera.hpp>

namespace VTX::App::Component::Render
Expand All @@ -11,16 +12,15 @@ namespace VTX::App::Component::Render
{
public:
ProxyCamera();
void init();
~ProxyCamera();

VTX::Renderer::Proxy::Camera & getProxy() { return *_proxyPtr; }
const VTX::Renderer::Proxy::Camera & getProxy() const { return *_proxyPtr; }
void setInRenderer( Renderer::Facade & p_renderer );

private:
void _generateProxy();
void _initCallbacks();

std::unique_ptr<VTX::Renderer::Proxy::Camera> _proxyPtr = nullptr;
Application::Renderer::ProxyWrapper<VTX::Renderer::Proxy::Camera> _proxyWrapper;
};

} // namespace VTX::App::Component::Render
Expand Down
Loading

0 comments on commit 269e42c

Please sign in to comment.