MeshLib Documentation
Loading...
Searching...
No Matches
MRViewportParametersAction.h
Go to the documentation of this file.
1#pragma once
4#include "MRViewport.h"
5#include "MRViewer.h"
6
7namespace MR
8{
9
12
17{
18public:
21 name_(name)
22 {
23 Viewer* viewer = &getViewerInstance();
24 for ( ViewportId id : viewports & viewer->getPresentViewports() )
25 saveParameters_.push_back( { id, viewer->viewport( id ).getParameters() } );
26 }
27
28 virtual std::string name() const override
29 {
30 return name_;
31 }
32
33 virtual void action( HistoryAction::Type ) override
34 {
35 // Assume user does not change viewports number
36 Viewer* viewer = &getViewerInstance();
37 for ( auto& [id, parameters] : saveParameters_ )
38 if ( viewer->getPresentViewports().contains( id ) )
39 {
41 viewer->viewport( id ).setParameters( parameters );
42 parameters = t;
43 }
44 }
45
46 [[nodiscard]] virtual size_t heapBytes() const override
47 {
48 return name_.capacity() + MR::heapBytes( saveParameters_ );
49 }
50
51private:
52 std::vector<std::pair<ViewportId, Viewport::Parameters>> saveParameters_;
53
54 std::string name_;
55};
56
57} // namespace MR
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
ViewportMask getPresentViewports() const
Definition MRViewer.h:316
MRVIEWER_API Viewport & viewport(ViewportId viewportId={})
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
bool contains(ViewportId id) const
Definition MRViewportId.h:50
static ViewportMask all()
mask meaning all or any viewports
Definition MRViewportId.h:45
Definition MRViewportParametersAction.h:17
MRVIEWER_API void setParameters(const Viewport::Parameters &params)
const Parameters & getParameters() const
Definition MRViewport.h:437
size_t heapBytes(const std::vector< T > &vec)
returns the amount of memory given vector occupies on heap
Definition MRHeapBytes.h:15
ViewportParametersAction(std::string name, ViewportMask viewports=ViewportMask::all())
Use this constructor to remember viewport configuration before making changes in it.
Definition MRViewportParametersAction.h:20
virtual std::string name() const override
Definition MRViewportParametersAction.h:28
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRViewportParametersAction.h:33
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRViewportParametersAction.h:46
Definition MRCameraOrientationPlugin.h:8
MRVIEWER_API Viewer & getViewerInstance()
returns global instance of Viewer class
Definition Viewer.dox.py:1
Definition MRViewport.h:277