Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlignPlugin.hh
1 #pragma once
2 
7 #include <set>
8 
15 
16 #include <QObject>
17 
18 #include <Eigen/Geometry>
19 
20 
21 #include "ObjectInfoListModel.hh"
22 
23 class AlignPlugin : public QObject,
29 {
30  Q_OBJECT
31  Q_INTERFACES(BackupInterface)
32  Q_INTERFACES(BaseInterface)
33  Q_INTERFACES(LoadSaveInterface)
34  Q_INTERFACES(LoggingInterface)
35  Q_INTERFACES(ToolboxInterface)
36 
37 #if QT_VERSION >= 0x050000
38  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Align")
39 #endif
40 
41 public:
42  AlignPlugin();
43 
44 signals:
45  // BackupInterface
46  void createBackup(int objectId, QString name, UpdateType type = UPDATE_ALL);
47 
48  // BaseInterface
49  void updateView();
50  void updatedObject(int objectId, UpdateType const& type);
51 
52  // LoggingInterface
53  void log(Logtype type, QString message);
54  void log(QString message);
55 
56  // ToolboxInterface
57  void addToolbox(QString name, QWidget *widget, QIcon *icon);
58 
59 private slots:
60  // BaseInterface
61  void initializePlugin();
62  void pluginsInitialized();
63  void slotObjectUpdated(int, UpdateType const&);
64  void slotObjectSelectionChanged(int);
65 
66  // LoadSaveInterface
67  void objectDeleted(int objectId);
68 
69 private slots:
70  void slotAlignMeshes();
71 
72  void slotSourceMeshChanged(int objectId);
73  void slotTargetMeshChanged(int objectId);
74 
75 private:
76  void updateGui();
77 
78  QComboBox *sourceMeshCombo_;
80 
81  QComboBox *targetMeshCombo_;
83 
84  QCheckBox *doScaleCheckBox_;
85  QPushButton *alignMeshesButton_;
86 
87 private:
88  typedef std::pair<Eigen::Vector3d, Eigen::Vector3d> BBox;
89  typedef std::vector<Eigen::Vector3d> Point_container;
90 
91  Point_container getPoints(BaseObjectData *object);
92  void transformObject(BaseObjectData *object, Eigen::Affine3d const& t);
93  void transformPoints(Point_container& points, Eigen::Affine3d const& t);
94  BBox computeBoundingBox(Point_container const& points);
95  Eigen::Vector3d computeCentroid(Point_container const& points);
96  bool computePCA(Point_container const& points, Eigen::Vector3d& centroid, Eigen::Matrix3d& principal_directions);
97 
98  int sourceId_;
99  int targetId_;
100 
101 public:
102  // BaseInterface
103  QString name()
104  {
105  return QString("Mesh alignment plugin");
106  }
107 
108  QString description()
109  {
110  return QString("Align two meshes by using PCA and scaling");
111  }
112 
113 public slots:
114  QString version()
115  {
116  return QString("1.0");
117  }
118 };
QString name()
Return a name for the plugin.
Definition: AlignPlugin.hh:103
Interface for all plugins which want to Load or Save files and create Objects.
QString description()
Return a description of what the plugin is doing.
Definition: AlignPlugin.hh:108
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Interface class for backup handling.
Interface for all Plugins which do logging to the logging window of the framework.
Update type class.
Definition: UpdateType.hh:70
Interface class from which all plugins have to be created.
Logtype
Log types for Message Window.
void initializePlugin()
Definition: ToolboxGui.cc:7
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.