MEPP2 Project
SimpleWindow.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published
6 // by the Free Software Foundation; either version 3 of the License,
7 // or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 
14 #if defined _MSC_VER
15 #pragma warning(push)
16 #pragma warning(disable : 4267) // for VS-2015 // MANDATORY when PCL is ON !!!
17 #endif
18 
19 
20 #include <QTimer>
21 #include <QMainWindow>
22 #include <QLabel>
23 
24 // Plugins
25 #include <QDir>
26 #include <QActionGroup>
27 
28 #include <QMdiSubWindow>
29 
30 #include <iostream>
31 #include <ctime>
32 #include <algorithm>
33 
34 #ifndef Q_MOC_RUN // MT : very important to avoid the error : ' Parse error at
35  // "BOOST_JOIN" ' -> (qt4 pb with boost)
39 #include "Visualization/Helpers/OSGDebug.hpp" // @todo to be removed
42 #endif
43 
44 #include "ui_SimpleWindow.h"
45 
46 #include <QDebug>
47 #include <QMenuBar>
48 
49 //#include <QMdiArea>
50 
51 // DirView
52 #include <QFileSystemModel>
53 #include <QSortFilterProxyModel>
54 
55 #include <boost/assert.hpp>
56 
57 // Plugins
58 #include <QPluginLoader>
59 // Plugins
60 
61 #if 0
64 #endif
65 
66 namespace FEVV {
67 
68 class SimpleViewer;
69 
70 class MdiArea; // NEW
71 
79 class SimpleWindow : public BaseWindowQt
80 {
81  Q_OBJECT
82 
83 public:
91  SimpleWindow(QWidget *_parent = 0, Qt::WindowFlags _flags = Qt::Window);
92 
96  ~SimpleWindow();
97 
104  void attach(Adapter *_adapter) override;
105 
117  void attach(AdapterQt *_adapter, const bool _useMdiWindows = false);
118 
119  void attachPlugin(Plugin *_plugin) override;
120 
121  void init() override;
122 
135  void init(const bool _test, const int _width = 1024, const int _height = 768);
136 
137  void notify() override;
138 
139  void setParam(std::string _name,
140  int *_value,
141  std::string _pluginName,
142  Plugin *_plugin) override;
143 
144  void setParam(std::string _name,
145  double *_value,
146  std::string _pluginName,
147  Plugin *_plugin) override;
148 
149  void setParam(std::string _name,
150  float *_value,
151  std::string _pluginName,
152  Plugin *_plugin) override;
153 
154  void setParam(std::string _name,
155  bool *_value,
156  std::string _pluginName,
157  Plugin *_plugin) override;
158 
159  void setParam(std::string _name,
160  std::string *_value,
161  std::string _pluginName,
162  Plugin *_plugin) override;
163 
164  std::vector< Adapter * > getSelectedAdapters() override;
165  std::vector< Adapter::Viewer * > getSelectedViewers() override;
166 
167  void loadQtPlugins();
168 
169  /*Q*/MdiArea *getMdiArea() { return mdiArea; }
170 
171  void sortModelList();
172 
173  void update(bool pick = false);
174 
175  void enableSpaceTimeMenus();
176 
177  void updateActiveChildTitle();
178 
179  // TODO : standardize template MeshT/HalfedgeGraph
180  template< typename MeshT >
181  void draw_or_redraw_mesh(/*const */ MeshT *mesh,
182  /*const */ FEVV::PMapsContainer *pmaps_bag,
183  FEVV::SimpleViewer *viewer,
184  bool _redraw = false,
185  bool _recomputeNT_if_redraw = false,
186  std::string _mesh_filename = std::string(""),
187  bool _recreateOSGobj_if_redraw = true,
188  float _step = 0.);
189 
190  void activate_time_mode();
191  void activate_space_mode();
192 
193  void writeHG(FEVV::SimpleViewer *viewer);
194 
195  void actionHG(FEVV::SimpleViewer *viewer, char t, char t2);
196 
197  void centerHG(FEVV::SimpleViewer *viewer);
198 
199  QWidget *activeMdiChild();
200 
201 #if 0 //TODO-elo-rm-?-ask_MTO
202  template< typename HalfedgeGraph >
203  void showSelectedHG(FEVV::SimpleViewer *viewer);
204 #endif
205 
206 protected:
207  void updateModelList(bool pick);
208 
209  // Plugins
210  void populateMenus(QObject *plugin);
211  void addToMenu(QObject *plugin,
212  const QStringList &texts,
213  QMenu *menu,
214  const char *member,
215  QActionGroup *actionGroup = 0);
216  // Plugins
217 
218  void closeEvent(QCloseEvent *event) override;
219 
223  template< typename HalfedgeGraph >
225 
230 
235  void readSettings();
236 
241  void writeSettings();
242 
243 public:
251  template< typename HalfedgeGraph >
252  void open_SPACE_TIME(FEVV::SimpleViewer *viewer,
253  const std::vector< std::string >& filenames);
254 
255 
256 protected slots:
257  void on_actionNew_triggered();
258  //void on_actionOpen_triggered();
262 
267 
269  void onGrab();
270 
271  void pre_actionHG(Adapter::Viewer *viewer, char t = 'D', char t2 = '_');
272 
285 
289 
294 #if 0 //TODO-elo-rm-?-ask_MTO
295  void on_actionShow_Selected_triggered();
296 #endif
299 
304 
305  void onAddBall();
306 
307  void onItemChanged(QListWidgetItem *_item, QListWidgetItem *_item_old);
308 
309  // Plugins
310  void applyPlugin();
311  void aboutPlugins();
312  // Plugins
313 
318  void openRecentFile();
319 
320 public slots:
321  void onModificationParam(std::string _pluginName, BasePlugin *_plugin);
322  void onApplyButton();
323 
325 
326 protected:
327  QTimer timerQuit;
328 
329  // Plugins
331  QStringList pluginFileNames;
332  QMenu *menuPlugins;
333 
334  /*Q*/MdiArea *mdiArea = nullptr;
335 
336  // DirView
337  QDockWidget *dockDirView;
338  QFileSystemModel *model;
339  QSortFilterProxyModel *proxyModel;
340  QTreeView *tree;
341 
344 
345  // ---
346 
353  void setCurrentFile(const QString &fileName);
361  QString strippedName(const QString &fullFileName);
362 
368 
370  enum { MaxRecentFiles = 9 };
372 
373  // ---
374 
375  bool useMdiWindows = false;
376 
377  bool open_only_pts_mode = false;
378 
379  bool ctrl_pressed = false;
380 
381  Ui::MainWindow ui; //<! Interface : QtDesigner
382 
383 public:
384  QStringList drag_files;
385 
386  bool drag = false;
387  bool shift_drag = false;
388  bool alt_drag = false;
389  bool ctrl_drag = false;
390 
391  bool recent = false;
392 
393 private:
394  bool clean_closure = false;
395 
396  osg::Matrix matrixVP;
397 };
398 
399 } // namespace FEVV
400 
401 #ifndef Q_MOC_RUN
403 #endif // Q_MOC_RUN
404 
405 
406 #if defined _MSC_VER
407 #pragma warning(pop)
408 #endif
FEVV::SimpleWindow::on_actionChange_MDI_view_mode_triggered
void on_actionChange_MDI_view_mode_triggered()
Definition: SimpleWindow.inl:1375
FEVV::SimpleWindow::getSelectedAdapters
std::vector< Adapter * > getSelectedAdapters() override
Definition: SimpleWindow.inl:2387
FEVV::SimpleWindow::updateModelList
void updateModelList(bool pick)
Definition: SimpleWindow.inl:692
FEVV::SimpleWindow::draw_or_redraw_mesh
void draw_or_redraw_mesh(MeshT *mesh, FEVV::PMapsContainer *pmaps_bag, FEVV::SimpleViewer *viewer, bool _redraw=false, bool _recomputeNT_if_redraw=false, std::string _mesh_filename=std::string(""), bool _recreateOSGobj_if_redraw=true, float _step=0.)
Definition: SimpleWindow.inl:785
OSGDebug.hpp
FEVV::SimpleWindow::addToMenu
void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu, const char *member, QActionGroup *actionGroup=0)
Definition: SimpleWindow.inl:615
FEVV::SimpleWindow::SimpleWindow
SimpleWindow(QWidget *_parent=0, Qt::WindowFlags _flags=Qt::Window)
Definition: SimpleWindow.inl:76
FEVV::SimpleWindow::drag
bool drag
Definition: SimpleWindow.h:386
FEVV::SimpleWindow::attachPlugin
void attachPlugin(Plugin *_plugin) override
Definition: SimpleWindow.inl:188
BaseAdapterVisuQt.h
FEVV::SimpleWindow::onApplyButton
void onApplyButton()
Definition: SimpleWindow.inl:525
FEVV::SimpleWindow::drag_files
QStringList drag_files
Definition: SimpleWindow.h:384
FEVV::SimpleWindow::treeLocation
QString treeLocation
Definition: SimpleWindow.h:342
FEVV::SimpleWindow::dockDirView
QDockWidget * dockDirView
Definition: SimpleWindow.h:337
FEVV::SimpleWindow::on_actionShow_Entire_Mesh_triggered
void on_actionShow_Entire_Mesh_triggered()
Definition: SimpleWindow.inl:2054
FEVV::SimpleWindow::on_actionOpen_triggered
void on_actionOpen_triggered()
Definition: SimpleWindow.inl:961
FEVV::SimpleWindow::writeHG
void writeHG(FEVV::SimpleViewer *viewer)
Definition: SimpleWindow.inl:1108
FEVV::SimpleWindow::timerQuit
QTimer timerQuit
Definition: SimpleWindow.h:327
FEVV::SimpleWindow::on_actionRender_Point_triggered
void on_actionRender_Point_triggered()
Definition: SimpleWindow.inl:1838
FEVV::SimpleWindow::attach
void attach(Adapter *_adapter) override
Definition: SimpleWindow.inl:119
FEVV::SimpleWindow::on_actionQuit_triggered
void on_actionQuit_triggered()
Definition: SimpleWindow.inl:1286
FEVV::SimpleWindow::mdiArea
MdiArea * mdiArea
Definition: SimpleWindow.h:334
FEVV::SimpleWindow::menuPlugins
QMenu * menuPlugins
Definition: SimpleWindow.h:332
FEVV::BaseAdapterVisu
Definition: BaseAdapterVisu.h:27
FEVV::SimpleWindow::useMdiWindows
bool useMdiWindows
Definition: SimpleWindow.h:375
FEVV::SimpleWindow::aboutPlugins
void aboutPlugins()
Definition: SimpleWindow.inl:649
FEVV::SimpleWindow::on_actionSuperimpose_Edges_triggered
void on_actionSuperimpose_Edges_triggered()
Definition: SimpleWindow.inl:1915
FEVV::SimpleWindow
SimpleWindow is a specialization of QMainWindow. This class the Main Window.
Definition: SimpleWindow.h:80
FEVV::SimpleWindow::updateRecentFileActions
void updateRecentFileActions()
Update Mepp recent files list.
Definition: SimpleWindow.inl:1086
FEVV::SimpleWindow::on_actionClose_all_triggered
void on_actionClose_all_triggered()
Definition: SimpleWindow.inl:1334
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
FEVV::SimpleWindow::m_dockDirView_MinimumWidth
int m_dockDirView_MinimumWidth
Definition: SimpleWindow.h:343
FEVV::MdiArea
MdiArea class.
Definition: MdiArea.h:30
QtHelpers.h
FEVV::SimpleWindow::on_actionRender_Line_triggered
void on_actionRender_Line_triggered()
Definition: SimpleWindow.inl:1853
FEVV::SimpleWindow::on_actionLighting_triggered
void on_actionLighting_triggered()
Definition: SimpleWindow.inl:1976
FEVV::SimpleWindow::on_actionRender_Mode_triggered
void on_actionRender_Mode_triggered()
Definition: SimpleWindow.inl:2007
FEVV::SimpleWindow::onItemChanged
void onItemChanged(QListWidgetItem *_item, QListWidgetItem *_item_old)
Definition: SimpleWindow.inl:2318
FEVV::SimpleWindow::sortModelList
void sortModelList()
Definition: SimpleWindow.inl:657
BaseWindowQt.h
FEVV::SimpleWindow::open_only_pts_mode
bool open_only_pts_mode
Definition: SimpleWindow.h:377
FEVV::SimpleWindow::ctrl_drag
bool ctrl_drag
Definition: SimpleWindow.h:389
FEVV::SimpleWindow::shift_drag
bool shift_drag
Definition: SimpleWindow.h:387
FEVV::SimpleWindow::openLocation
QString openLocation
Definition: SimpleWindow.h:342
FEVV::SimpleViewer
SimpleViewer is a specialization of osgViewer::CompositeViewer. This class is a widget where we are a...
Definition: SimpleViewer.h:180
FEVV::SimpleWindow::on_actionCopy_Viewpoint_triggered
void on_actionCopy_Viewpoint_triggered()
Definition: SimpleWindow.inl:2069
FEVV::SimpleWindow::pluginFileNames
QStringList pluginFileNames
Definition: SimpleWindow.h:331
FEVV::SimpleWindow::on_actionClose_window_triggered
void on_actionClose_window_triggered()
Definition: SimpleWindow.inl:1328
SimpleCheckBox.h
FEVV::SimpleWindow::onModificationParam
void onModificationParam(std::string _pluginName, BasePlugin *_plugin)
Definition: SimpleWindow.inl:505
FEVV::SimpleWindow::on_actionShow_CustomVectors_Vertices_triggered
void on_actionShow_CustomVectors_Vertices_triggered()
Definition: SimpleWindow.inl:2136
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::SimpleWindow::setParam
void setParam(std::string _name, int *_value, std::string _pluginName, Plugin *_plugin) override
Definition: SimpleWindow.inl:371
FEVV::SimpleWindow::activate_space_mode
void activate_space_mode()
Definition: SimpleWindow.inl:1461
FEVV::SimpleWindow::on_actionChange_viewer_mode_triggered
void on_actionChange_viewer_mode_triggered()
Definition: SimpleWindow.inl:1395
FEVV::SimpleWindow::saveLocation
QString saveLocation
Definition: SimpleWindow.h:342
FEVV::SimpleWindow::applyPlugin
void applyPlugin()
Definition: SimpleWindow.inl:636
FEVV::SimpleWindow::populateMenus
void populateMenus(QObject *plugin)
Definition: SimpleWindow.inl:601
FEVV::SimpleWindow::createNewViewer
FEVV::SimpleViewer * createNewViewer(void)
Create a new empty viewer.
Definition: SimpleWindow.inl:2416
FEVV::SimpleWindow::onAddBall
void onAddBall()
Definition: SimpleWindow.inl:2287
FEVV::SimpleWindow::updateActiveChildTitle
void updateActiveChildTitle()
Definition: SimpleWindow.inl:1341
FEVV::SimpleWindow::loadQtPlugins
void loadQtPlugins()
Definition: SimpleWindow.inl:547
FEVV::SimpleWindow::openRecentFile
void openRecentFile()
Open a recent file (from menu).
Definition: SimpleWindow.inl:1045
FEVV::SimpleWindow::pre_actionHG
void pre_actionHG(Adapter::Viewer *viewer, char t='D', char t2='_')
Definition: SimpleWindow.inl:1830
FEVV::SimpleWindow::model
QFileSystemModel * model
Definition: SimpleWindow.h:338
FEVV::SimpleWindow::on_actionShow_Axis_triggered
void on_actionShow_Axis_triggered()
Definition: SimpleWindow.inl:2094
FEVV::SimpleWindow::separatorAct_menuFile
QAction * separatorAct_menuFile
separator in file menu
Definition: SimpleWindow.h:369
FEVV::SimpleWindow::recent
bool recent
Definition: SimpleWindow.h:391
FEVV::SimpleWindow::enableSpaceTimeMenus
void enableSpaceTimeMenus()
Definition: SimpleWindow.inl:682
FEVV::SimpleWindow::on_actionNew_triggered
void on_actionNew_triggered()
Definition: SimpleWindow.inl:807
FEVV::SimpleWindow::~SimpleWindow
~SimpleWindow()
Definition: SimpleWindow.inl:91
FEVV::SimpleWindow::on_actionFace_Color_triggered
void on_actionFace_Color_triggered()
Definition: SimpleWindow.inl:1946
FEVV::SimpleWindow::onGrab
void onGrab()
Definition: SimpleWindow.inl:1525
FEVV::SimpleWindow::matrixVP
osg::Matrix matrixVP
Definition: SimpleWindow.h:396
FEVV::SimpleWindow::ctrl_pressed
bool ctrl_pressed
Definition: SimpleWindow.h:379
FEVV::SimpleWindow::on_actionSmoothFlat_Shading_triggered
void on_actionSmoothFlat_Shading_triggered()
Definition: SimpleWindow.inl:1991
FEVV::SimpleWindow::writeSettings
void writeSettings()
Write settings: folder locations (tree/open/save), mainwindow (pos, size, state), recent files list....
Definition: SimpleWindow.inl:2463
FEVV::SimpleWindow::getMdiArea
MdiArea * getMdiArea()
Definition: SimpleWindow.h:169
FEVV::SimpleWindow::on_actionTexture_Mode_triggered
void on_actionTexture_Mode_triggered()
Definition: SimpleWindow.inl:1961
FEVV::SimpleWindow::init
void init() override
Definition: SimpleWindow.inl:194
PluginDialog.hpp
FEVV::SimpleWindow::open_SPACE_TIME
void open_SPACE_TIME(FEVV::SimpleViewer *viewer, const std::vector< std::string > &filenames)
Open meshes in a viewer with datastructure HalfedgeGraph.
Definition: SimpleWindow.inl:897
FEVV::SimpleWindow::on_actionSuperimpose_Vertices_bigger_triggered
void on_actionSuperimpose_Vertices_bigger_triggered()
Definition: SimpleWindow.inl:1899
FEVV::SimpleWindow::activeMdiChild
QWidget * activeMdiChild()
Definition: SimpleWindow.inl:2439
FEVV::SimpleWindow::on_actionPaste_Viewpoint_triggered
void on_actionPaste_Viewpoint_triggered()
Definition: SimpleWindow.inl:2081
FEVV::SimpleWindow::on_actionClose_triggered
void on_actionClose_triggered()
Definition: SimpleWindow.inl:1279
FEVV::SimpleWindow::readSettings
void readSettings()
Read settings: folder locations (tree/open/save), mainwindow (pos, size, state), recent files list....
Definition: SimpleWindow.inl:2489
FEVV::SimpleWindow::on_actionDyn_Last_triggered
void on_actionDyn_Last_triggered()
Definition: SimpleWindow.inl:2273
FEVV::SimpleWindow::tree
QTreeView * tree
Definition: SimpleWindow.h:340
FEVV::SimpleWindow::on_actionVertex_Color_triggered
void on_actionVertex_Color_triggered()
Definition: SimpleWindow.inl:1931
FEVV::SimpleWindow::centerHG
void centerHG(FEVV::SimpleViewer *viewer)
Definition: SimpleWindow.inl:2039
FEVV::SimpleWindow::recentFileActs
QAction * recentFileActs[MaxRecentFiles]
tab of mesh files recent list
Definition: SimpleWindow.h:371
FEVV::SimpleWindow::proxyModel
QSortFilterProxyModel * proxyModel
Definition: SimpleWindow.h:339
FEVV::BaseAdapterVisuQt
Definition: BaseAdapterVisuQt.h:22
FEVV::SimpleWindow::closeEvent
void closeEvent(QCloseEvent *event) override
Definition: SimpleWindow.inl:1293
FEVV::SimpleWindow::setCurrentFile
void setCurrentFile(const QString &fileName)
Set a mesh filename in recent files list.
Definition: SimpleWindow.inl:1062
FEVV::SimpleWindow::MaxRecentFiles
@ MaxRecentFiles
Definition: SimpleWindow.h:370
FEVV::SimpleWindow::clean_closure
bool clean_closure
Definition: SimpleWindow.h:394
FEVV::DataStructures::AIF::AIFMesh
This class represents an AIF structure. AIF structure can deal with both manifold and non-manifold su...
Definition: AIFMesh.hpp:47
FEVV::SimpleWindow::on_actionSuperimpose_Vertices_triggered
void on_actionSuperimpose_Vertices_triggered()
Definition: SimpleWindow.inl:1883
FEVV::BasePlugin
Definition: BasePlugin.h:38
FEVV::BaseWindowQt
Definition: BaseWindowQt.h:21
SimpleWindow.inl
FEVV::SimpleWindow::on_actionShow_Translation_Draggers_triggered
void on_actionShow_Translation_Draggers_triggered()
Definition: SimpleWindow.inl:2203
FEVV::SimpleWindow::notify
void notify() override
Definition: SimpleWindow.inl:663
PluginInterface.h
FEVV::SimpleWindow::pluginsDir
QDir pluginsDir
Definition: SimpleWindow.h:330
FEVV::SimpleWindow::on_actionDyn_First_triggered
void on_actionDyn_First_triggered()
Definition: SimpleWindow.inl:2231
FEVV::SimpleWindow::on_actionDyn_Previous_triggered
void on_actionDyn_Previous_triggered()
Definition: SimpleWindow.inl:2245
FEVV::SimpleWindow::strippedName
QString strippedName(const QString &fullFileName)
Return the filename of a mesh without path.
Definition: SimpleWindow.inl:1080
FEVV::BaseAdapterVisu::Viewer
BaseViewer Viewer
Definition: BaseAdapterVisu.h:29
FEVV::SimpleWindow::on_actionOpen_SPACE_TIME
void on_actionOpen_SPACE_TIME(FEVV::SimpleViewer *viewer)
Open button/menu callback function.
Definition: SimpleWindow.inl:815
FEVV::SimpleWindow::on_actionAbout_MEPP_Help_triggered
void on_actionAbout_MEPP_Help_triggered()
Definition: SimpleWindow.inl:1480
FEVV::SimpleWindow::ui
Ui::MainWindow ui
Definition: SimpleWindow.h:381
FEVV::SimpleWindow::actionHG
void actionHG(FEVV::SimpleViewer *viewer, char t, char t2)
Definition: SimpleWindow.inl:1536
FEVV::SimpleWindow::getSelectedViewers
std::vector< Adapter::Viewer * > getSelectedViewers() override
Definition: SimpleWindow.inl:2401
SimpleLineEdit.h
FEVV::SimpleWindow::on_actionShow_Grid_triggered
void on_actionShow_Grid_triggered()
Definition: SimpleWindow.inl:2107
FEVV::SimpleWindow::on_actionSaveAs_triggered
void on_actionSaveAs_triggered()
Definition: SimpleWindow.inl:1264
FEVV::SimpleWindow::activate_time_mode
void activate_time_mode()
Definition: SimpleWindow.inl:1442
FEVV::SimpleWindow::on_actionShow_Vertex_Normals_triggered
void on_actionShow_Vertex_Normals_triggered()
Definition: SimpleWindow.inl:2120
FEVV::SimpleWindow::update
void update(bool pick=false)
Definition: SimpleWindow.inl:676
FEVV::SimpleWindow::on_actionDyn_Next_triggered
void on_actionDyn_Next_triggered()
Definition: SimpleWindow.inl:2259
FEVV::SimpleWindow::on_actionShow_Rotation_Draggers_triggered
void on_actionShow_Rotation_Draggers_triggered()
Definition: SimpleWindow.inl:2217
FEVV::SimpleWindow::on_actionRender_Fill_triggered
void on_actionRender_Fill_triggered()
Definition: SimpleWindow.inl:1868
FEVV::SimpleWindow::alt_drag
bool alt_drag
Definition: SimpleWindow.h:388