Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes
omni::ui::Canvas Class Reference

Dockwidget for editing canvas type and parameters. More...

#include <Canvas.h>

Inheritance diagram for omni::ui::Canvas:
Inheritance graph
[legend]
Collaboration diagram for omni::ui::Canvas:
Collaboration graph
[legend]

Public Slots

void selectCanvasType (QString)
 Select canvas type with id. More...
 
void updateSceneSize (bool)
 Set size of scene for canvas parameter widget. More...
 
void updateUnits ()
 Set unit suffix string for canvas parameter widget. More...
 

Signals

void dataModelChanged ()
 
void canvasTypeChanged ()
 

Public Member Functions

 Canvas (QWidget *=nullptr)
 
 ~Canvas ()
 
- Public Member Functions inherited from omni::ui::DockWidget
 DockWidget (QWidget *=nullptr)
 
template<typename UI >
 DockWidget (UI &_ui, QWidget *_parent=nullptr)
 
virtual ~DockWidget ()
 
- Public Member Functions inherited from omni::ui::mixin::DataModel< DATAMODEL, SHARED >
 DataModel ()
 
void setDataModel (pointer_type _dataModel)
 Set new data model. More...
 
pointer_type dataModel ()
 Return pointer to data model. More...
 
const pointer_type dataModel () const
 Return pointer to data model (const version) More...
 
virtual void updateFrontend ()
 Push data to frontend widgets and all child widgets. More...
 
virtual void updateDataModel ()
 Update the data model interface. More...
 

Private Member Functions

void dataToFrontend ()
 Update widgets from current mapping. More...
 
bool frontendToData ()
 Assign widget values to current mapping. More...
 
void showParameterWidget ()
 
- Private Member Functions inherited from omni::ui::mixin::ParameterWidget< ui::CanvasParameters >
void removeParameterWidget (PARENT_WIDGET *_widget)
 Remove parameter widget from given widget. More...
 
bool setupParameterWidget (PARENT_WIDGET *_widget, INTERFACE *_interface)
 Setup widget for interface and place it onto widget. More...
 
widget_typeparameterWidget ()
 Return pointer to parameterWidget. More...
 

Private Attributes

std::unique_ptr< Ui::Canvas > ui_
 
TypeIdMemory< canvas::InterfacecanvasMemory_
 

Additional Inherited Members

- Public Types inherited from omni::ui::mixin::DataModel< DATAMODEL, SHARED >
typedef DATAMODEL data_model_type
 Data type. More...
 
typedef DataModel
< data_model_type, SHARED > 
type
 This type. More...
 
typedef detail::PointerType
< data_model_type, SHARED > 
pointer_type_handler
 Pointer type handler. More...
 
typedef pointer_type_handler::type pointer_type
 Derived pointer type. More...
 
- Protected Member Functions inherited from omni::ui::DockWidget
template<typename UI >
void setup (UI &_ui)
 Setup ui form UI parameter is smart pointer (e.g. unique_ptr) to UI form. More...
 
- Protected Member Functions inherited from omni::ui::mixin::Locked
template<typename F >
void locked (F f)
 Lock widget and execute given functor. More...
 
bool isLocked () const
 Return true if widget is locked. More...
 
- Private Types inherited from omni::ui::mixin::ParameterWidget< ui::CanvasParameters >
typedef ui::CanvasParameters widget_type
 

Detailed Description

Dockwidget for editing canvas type and parameters.

Constructor & Destructor Documentation

omni::ui::Canvas::Canvas ( QWidget *  _parent = nullptr)
33  :
34  DockWidget(ui_,_parent)
35  {
36  this->setup(ui_);
37 
38  // Add canvas types from Factory
39  for (auto& _idCanvasClass : omni::canvas::Factory::classes())
40  {
41  QString _id = _idCanvasClass.first.str();
42  ui_->boxCanvasSelect->addItem(QIcon(QString(":/canvas/") + _id +
43  QString(
44  ".png")), _id,
45  QVariant(_id));
46  }
47 
48  connect(ui_->boxCanvasSelect, SIGNAL(currentIndexChanged(QString)), this,
49  SLOT(selectCanvasType(QString)));
50  }
void setup(UI &_ui)
Setup ui form UI parameter is smart pointer (e.g. unique_ptr) to UI form.
Definition: DockWidget.h:44
std::unique_ptr< Ui::Canvas > ui_
Definition: Canvas.h:73
DockWidget(QWidget *=nullptr)
Definition: DockWidget.cpp:24
void selectCanvasType(QString)
Select canvas type with id.
Definition: Canvas.cpp:101
static class_map_type const & classes()
Gives readonly access to registered classes.
Definition: factory.hpp:108
omni::ui::Canvas::~Canvas ( )
53  {}

Member Function Documentation

void omni::ui::Canvas::canvasTypeChanged ( )
signal
void omni::ui::Canvas::dataModelChanged ( )
signal
void omni::ui::Canvas::dataToFrontend ( )
privatevirtual

Update widgets from current mapping.

Implements omni::ui::mixin::DataModel< DATAMODEL, SHARED >.

56  {
57  if (!dataModel()->canvas())
58  {
59  dataModel()->setCanvas("HalfDome");
60  selectCanvasType("HalfDome");
61  }
62  // Search combobox for available canvas types
63  int _index = 0;
64 
65  for (int i = 0; i < ui_->boxCanvasSelect->count(); ++i)
66  {
67  QString _id = ui_->boxCanvasSelect->itemData(i).toString();
68 
69  if (_id == dataModel()->canvas()->getTypeId().str())
70  {
71  _index = i;
72  }
73  }
74 
75  ui_->boxCanvasSelect->setCurrentIndex(_index);
77  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void showParameterWidget()
Definition: Canvas.cpp:121
std::unique_ptr< Ui::Canvas > ui_
Definition: Canvas.h:73
void selectCanvasType(QString)
Select canvas type with id.
Definition: Canvas.cpp:101
bool omni::ui::Canvas::frontendToData ( )
privatevirtual

Assign widget values to current mapping.

Implements omni::ui::mixin::DataModel< DATAMODEL, SHARED >.

79  {
80  return false;
81  }
void omni::ui::Canvas::selectCanvasType ( QString  _id)
slot

Select canvas type with id.

Dont do anything if type id has not changed

102  {
103  if (!dataModel() || this->isLocked()) return;
104 
105  tryWithExceptionList<Exception>([&]() {
106  canvasMemory_.store(dataModel()->canvas());
107 
108  /// Dont do anything if type id has not changed
109  if (dataModel()->canvas()->getTypeId().str() == _id) {
110  return;
111  }
112 
113  dataModel()->setCanvas(_id);
114  canvasMemory_.restore(dataModel()->canvas());
116 
117  emit canvasTypeChanged();
118  });
119  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void restore(interface_type *_t) const
Restore object with interface in memory, if exists.
Definition: TypeIdMemory.h:56
void showParameterWidget()
Definition: Canvas.cpp:121
bool isLocked() const
Return true if widget is locked.
Definition: Locked.h:40
void store(interface_type const *_t)
Store object with interface in memory.
Definition: TypeIdMemory.h:44
TypeIdMemory< canvas::Interface > canvasMemory_
Definition: Canvas.h:75
void canvasTypeChanged()
void omni::ui::Canvas::showParameterWidget ( )
private
121  {
122  if (this->setupParameterWidget(widget(),dataModel()->canvas())) {
123  dataModel()->canvas()->update();
124 
125  // Update parameters when canvas has changed
126  connect(this->parameterWidget(),SIGNAL(dataModelChanged()),
127  this,SIGNAL(dataModelChanged()));
128  }
129  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
void dataModelChanged()
bool setupParameterWidget(PARENT_WIDGET *_widget, INTERFACE *_interface)
Setup widget for interface and place it onto widget.
Definition: ParameterWidget.h:51
widget_type * parameterWidget()
Return pointer to parameterWidget.
Definition: ParameterWidget.h:73
void omni::ui::Canvas::updateSceneSize ( bool  _rescaleValues)
slot

Set size of scene for canvas parameter widget.

83  {
84  auto* _paramWidget = this->parameterWidget();
85 
86  if (_paramWidget && dataModel()) {
87  _paramWidget->setRescaleValues(_rescaleValues);
88  _paramWidget->setScale(dataModel()->scene().size());
89  }
90  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
widget_type * parameterWidget()
Return pointer to parameterWidget.
Definition: ParameterWidget.h:73
void omni::ui::Canvas::updateUnits ( )
slot

Set unit suffix string for canvas parameter widget.

Update parameter slider unit suffixes

92  {
93  auto* _paramWidget = this->parameterWidget();
94 
95  if (_paramWidget && dataModel()) {
96  /// Update parameter slider unit suffixes
97  _paramWidget->setUnit(dataModel()->scene().unit().abbreviation());
98  }
99  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
widget_type * parameterWidget()
Return pointer to parameterWidget.
Definition: ParameterWidget.h:73

Field Documentation

TypeIdMemory<canvas::Interface> omni::ui::Canvas::canvasMemory_
private
std::unique_ptr<Ui::Canvas> omni::ui::Canvas::ui_
private

The documentation for this class was generated from the following files: