18 #if(FEVV_USE_QT5) // Qt6 in fact...
21 #include <QDesktopWidget>
24 #include <QCloseEvent>
26 #include <boost/assert.hpp>
29 #include <QApplication>
30 #include <QFileDialog>
37 #include <QPluginLoader>
42 #ifndef Q_MOC_RUN // MT : very important to avoid the error : ' Parse error at
53 #define STEP_SPACE 0. // TEMP
55 #define ORGANIZATION QObject::tr("LIRIS")
56 #define APPLICATION QObject::tr("MEPP2")
59 #ifndef Q_MOC_RUN // MT : very important to avoid the error : ' Parse error at
67 #endif //FEVV_USE_CGAL
77 Qt::WindowFlags _flags)
81 std::cout <<
"*** this=" <<
this <<
" entering " << __func__ << std::endl;
87 std::cout <<
"*** this=" <<
this <<
" leaving " << __func__ << std::endl;
94 std::cout <<
"*** this=" <<
this <<
" entering " << __func__ << std::endl;
97 if(mdiArea !=
nullptr)
108 for (
int i = 0; i < MaxRecentFiles; ++i)
110 delete recentFileActs[i];
114 std::cout <<
"*** this=" <<
this <<
" leaving " << __func__ << std::endl;
129 "is not implemented. See attach(AdapterQt) instead.",
130 "SimpleWindow::attach(Adapter)");
138 "The given adapter is null.",
139 "SimpleWindow::attach(AdapterQt,bool)"))
144 adapters.push_back(_adapter);
149 _adapter->setMinimumSize(300, 200);
150 mdiArea->addSubWindow(_adapter);
154 unsigned int nbAdapters = adapters.size();
155 unsigned int nbLines = (
unsigned int)round(std::sqrt(nbAdapters));
156 unsigned int nbColumns = (
unsigned int)ceil((
double)nbAdapters / nbLines);
158 for(
unsigned int iLines = 0; iLines < nbLines; ++iLines)
160 for(
unsigned int iColumns = 0; iColumns < nbColumns; ++iColumns)
162 unsigned int index = iLines * nbColumns + iColumns;
163 if(index >= nbAdapters)
167 ui.gridLayout->addWidget(
168 static_cast< AdapterQt *
>(adapters[index]), iLines, iColumns);
203 !bIsInit,
"is already init. Leaving...",
"SimpleWindow::init"))
208 setlocale(LC_ALL,
"C");
213 clean_closure =
true;
214 connect(&timerQuit, SIGNAL(timeout()),
this, SLOT(close()));
215 timerQuit.start(10000);
225 setMinimumSize(_width, _height);
226 resize(_width, _height);
230 std::srand(std::time(0));
234 SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
236 SLOT(onItemChanged(QListWidgetItem *, QListWidgetItem *)));
243 menuPlugins = ui.menuPlugins;
244 menuPlugins->addAction(
"Plugins information",
this, SLOT(aboutPlugins()));
247 ui.menuHelp->addSeparator();
248 ui.menuHelp->addAction(
"Screenshot",
this, SLOT(onGrab()));
252 ui.applyButton, SIGNAL(clicked(
bool)),
this, SLOT(onApplyButton()));
253 ui.applyButton->setEnabled(
false);
255 ui.listParams->setVisible(
false);
267 ui.gridLayout->addWidget(mdiArea, 0, 0);
270 ui.actionTile, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows()));
271 connect(ui.actionCascade,
274 SLOT(cascadeSubWindows()));
280 mdiArea->setAcceptDrops(
true);
281 mdiArea->setMainWindow(
this);
288 dockDirView =
new QDockWidget(
QObject::tr(
" Directory View"),
this);
289 dockDirView->setObjectName(
"dockDirView");
290 dockDirView->setMinimumWidth(m_dockDirView_MinimumWidth);
291 this->addDockWidget(Qt::RightDockWidgetArea, dockDirView);
293 model =
new QFileSystemModel;
295 filters <<
"*.obj" <<
"*.off" <<
"*.coff" <<
"*.ply" <<
"*.msh";
297 filters <<
"*.vtk" <<
"*.vtp" <<
"*.vtu";
309 model->setNameFilters(filters);
310 model->setNameFilterDisables(
false);
312 proxyModel =
new QSortFilterProxyModel;
313 proxyModel->setSourceModel(model);
315 tree =
new QTreeView();
316 tree->setModel(proxyModel);
317 tree->setSortingEnabled(
true);
319 tree->setColumnHidden(2,
true);
320 tree->setColumnWidth(0, 320);
321 tree->sortByColumn(0, Qt::AscendingOrder);
324 QModelIndex index = model->setRootPath(treeLocation);
325 QModelIndex proxyIndex = proxyModel->mapFromSource(index);
327 tree->scrollTo(proxyIndex);
328 tree->setExpanded(proxyIndex,
true);
329 tree->setCurrentIndex(proxyIndex);
331 tree->setSelectionMode(QAbstractItemView::ExtendedSelection);
332 tree->setDragEnabled(
true);
334 dockDirView->setWidget(tree);
338 for (
int i = 0; i < MaxRecentFiles; ++i)
340 recentFileActs[i] =
new QAction(
this);
341 recentFileActs[i]->setVisible(
false);
342 connect(recentFileActs[i], SIGNAL(triggered()),
this, SLOT(openRecentFile()));
345 QMenu *menuFile = ui.menuFile;
346 separatorAct_menuFile = menuFile->addSeparator();
347 for (
int i = 0; i < MaxRecentFiles; ++i)
348 menuFile->addAction(recentFileActs[i]);
350 updateRecentFileActions();
378 QLabel* testLabel =
new QLabel( ui.listParams );
379 testLabel->setObjectName(QString::fromUtf8(
"label"));
380 testLabel->setText(QString::fromUtf8(_name.c_str()));
385 testValue->setObjectName(QString::fromUtf8(
"value"));
386 testValue->setText(QString::fromUtf8(std::to_string(*_value).c_str()));
387 testValue->
setParams(_value, _pluginName, _plugin);
389 QObject::connect(testValue, SIGNAL(textChanged(QString)), testValue, SLOT(modificationSlot()));
390 QObject::connect(testValue, SIGNAL(modificationSignal(std::string,
BasePlugin*)),
this, SLOT(onModificationParam(std::string,
BasePlugin*)));
392 QObject* p =
dynamic_cast< QObject*
>(_plugin);
393 if (p) QObject::connect(p, SIGNAL(resetSignal()), testValue, SLOT(resetSlot()));
395 ui.formLayout->addRow( testLabel, testValue );
406 QLabel* testLabel =
new QLabel( ui.listParams );
407 testLabel->setObjectName(QString::fromUtf8(
"label"));
408 testLabel->setText(QString::fromUtf8(_name.c_str()));
411 testValue->setObjectName(QString::fromUtf8(
"value"));
412 testValue->setText(QString::fromUtf8(std::to_string(*_value).c_str()));
413 testValue->
setParams(_value, _pluginName, _plugin);
415 QObject::connect(testValue, SIGNAL(textChanged(QString)), testValue, SLOT(modificationSlot()));
416 QObject::connect(testValue, SIGNAL(modificationSignal(std::string,
BasePlugin*)),
this, SLOT(onModificationParam(std::string,
BasePlugin*)));
418 QObject* p =
dynamic_cast< QObject*
>(_plugin);
419 if (p) QObject::connect(p, SIGNAL(resetSignal()), testValue, SLOT(resetSlot()));
421 ui.formLayout->addRow( testLabel, testValue );
432 QLabel* testLabel =
new QLabel( ui.listParams );
433 testLabel->setObjectName(QString::fromUtf8(
"label"));
434 testLabel->setText(QString::fromUtf8(_name.c_str()));
437 testValue->setObjectName(QString::fromUtf8(
"value"));
438 testValue->setText(QString::fromUtf8(std::to_string(*_value).c_str()));
439 testValue->
setParams(_value, _pluginName, _plugin);
441 QObject::connect(testValue, SIGNAL(textChanged(QString)), testValue, SLOT(modificationSlot()));
442 QObject::connect(testValue, SIGNAL(modificationSignal(std::string,
BasePlugin*)),
this, SLOT(onModificationParam(std::string,
BasePlugin*)));
444 QObject* p =
dynamic_cast< QObject*
>(_plugin);
445 if (p) QObject::connect(p, SIGNAL(resetSignal()), testValue, SLOT(resetSlot()));
447 ui.formLayout->addRow( testLabel, testValue );
458 QLabel* testLabel =
new QLabel( ui.listParams );
459 testLabel->setObjectName(QString::fromUtf8(
"label"));
460 testLabel->setText(QString::fromUtf8(_name.c_str()));
463 testValue->setObjectName(QString::fromUtf8(
"value"));
464 Qt::CheckState state = (*_value) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked;
465 testValue->setCheckState(state);
466 testValue->
setParams(_value, _pluginName, _plugin);
468 QObject::connect(testValue, SIGNAL(stateChanged(
int)), testValue, SLOT(modificationSlot()));
469 QObject::connect(testValue, SIGNAL(modificationSignal(std::string,
BasePlugin*)),
this, SLOT(onModificationParam(std::string,
BasePlugin*)));
471 QObject* p =
dynamic_cast< QObject*
>(_plugin);
472 if (p) QObject::connect(p, SIGNAL(resetSignal()), testValue, SLOT(resetSlot()));
474 ui.formLayout->addRow( testLabel, testValue );
485 QLabel* testLabel =
new QLabel( ui.listParams );
486 testLabel->setObjectName(QString::fromUtf8(
"label"));
487 testLabel->setText(QString::fromUtf8(_name.c_str()));
490 testValue->setObjectName(QString::fromUtf8(
"value"));
491 testValue->setText(QString::fromUtf8(_value->c_str()));
492 testValue->
setParams(_value, _pluginName, _plugin);
494 QObject::connect(testValue, SIGNAL(textChanged(QString)), testValue, SLOT(modificationSlot()));
495 QObject::connect(testValue, SIGNAL(modificationSignal(std::string,
BasePlugin*)),
this, SLOT(onModificationParam(std::string,
BasePlugin*)));
497 QObject* p =
dynamic_cast< QObject*
>(_plugin);
498 if (p) QObject::connect(p, SIGNAL(resetSignal()), testValue, SLOT(resetSlot()));
500 ui.formLayout->addRow( testLabel, testValue );
509 if(_pluginName ==
"")
513 if(stackPlugins.find(_pluginName) == stackPlugins.end())
515 stackPlugins.insert({_pluginName, _plugin});
516 ui.applyButton->setEnabled(
true);
532 for(
auto funct : stackPlugins)
534 for(
auto w: adapters)
537 w->apply(funct.second);
541 stackPlugins.clear();
542 ui.applyButton->setEnabled(
false);
549 foreach(QObject *plugin, QPluginLoader::staticInstances())
551 populateMenus(plugin);
556 pluginsDir = QDir( QApplication::applicationDirPath());
558 #if defined(Q_OS_WIN)
561 #elif defined(Q_OS_MAC)
562 if(pluginsDir.dirName() ==
"MacOS")
571 foreach(QString fileName, pluginsDir.entryList(QDir::Files))
573 if( QLibrary::isLibrary(fileName))
575 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
576 QObject *plugin = loader.instance();
579 menuPlugins->addSeparator();
580 populateMenus(plugin);
581 pluginFileNames += fileName;
585 qobject_cast< Generic_PluginInterface * >(plugin);
586 mepp_qt_plugin->
init(
this);
591 this->attachPlugin(mepp_plugin);
597 menuPlugins->setEnabled(!menuPlugins->actions().isEmpty());
604 qobject_cast< Generic_PluginInterface * >(plugin);
610 SLOT(applyPlugin()));
616 const QStringList &texts,
619 QActionGroup *actionGroup)
621 foreach(QString text, texts)
623 QAction *action =
new QAction(text, plugin);
624 connect(action, SIGNAL(triggered()),
this, member);
625 menu->addAction(action);
629 action->setCheckable(
true);
630 actionGroup->addAction(action);
638 QAction *action = qobject_cast< QAction * >(sender());
641 qobject_cast< Generic_PluginInterface * >(action->parent());
651 PluginDialog dialog(pluginsDir.path(), pluginFileNames,
this);
659 ui.listModels->sortItems(Qt::AscendingOrder);
666 "is not valid (see init() or attach()). Leaving...",
667 "SimpleWindow::notify"))
678 updateModelList(pick);
696 ui.listModels->clear();
697 if(adapters.size() > 0)
699 for(
unsigned int aa = 0; aa < adapters.size(); ++aa)
701 QListWidgetItem *pickitem =
nullptr;
703 Viewer *viewer =
static_cast< Viewer *
>(adapters[aa]->getViewer());
704 Viewer::DataModelVector *result = viewer->
getDataModel();
706 if(result->size() > 0)
708 for(
unsigned int rr = 0; rr < result->size(); ++rr)
710 if((*result)[rr].type == Helpers::DataType::MODEL)
712 QListWidgetItem *item =
new QListWidgetItem(
713 QString::fromUtf8((*result)[rr].name.c_str()));
715 variant.setValue((*result)[rr]);
716 item->setData(Qt::UserRole, variant);
718 ui.listModels->insertItem(0, item);
728 if((*result)[rr].viewer->isNodeSelected(
747 if(pickitem !=
nullptr)
750 ui.listModels->setCurrentItem(pickitem);
755 ui.listModels->setCurrentRow(0);
783 template<
typename MeshT >
790 bool _recomputeNT_if_redraw,
791 std::string _mesh_filename,
792 bool _recreateOSGobj_if_redraw,
799 _recomputeNT_if_redraw,
801 _recreateOSGobj_if_redraw,
809 QMessageBox::information(
this,
"",
QObject::tr(
"New - Not yet implemented."));
813 template<
typename HalfedgeGraph >
817 std::vector< std::string > files;
821 std::string ds_name =
822 FEVV::getDatastructureName(
static_cast< HalfedgeGraph *
>(
nullptr));
824 QString allExtensions;
826 if(ds_name ==
"CGALPOINTSET")
828 allExtensions =
"XYZ/OFF/PLY files (*.xyz *.off *.ply);;"
829 "XYZ files (*.xyz);;"
830 "OFF files (*.off);;"
833 else if(ds_name ==
"PCLPOINTCLOUD")
835 allExtensions =
"XYZ/PCD/PLY files (*.xyz *.pcd *.ply);;"
836 "XYZ files (*.xyz);;"
837 "PCD files (*.pcd);;"
842 QString defaultExtensions =
"OBJ/OFF files (*.obj *.off);;"
843 "OBJ files (*.obj);;"
844 "OFF files (*.off);;"
845 "COFF files (*.coff);;"
846 "PLY files (*.ply);;"
849 QString vtkExtensions =
"VTK Files (*.vtk);;"
850 "VTP files (*.vtp);;"
853 allExtensions = defaultExtensions;
855 allExtensions +=
";;" + vtkExtensions;
858 allExtensions +=
";;FBX files (*.fbx)";
863 QFileDialog::Option options = (QFileDialog::Option)0;
865 #if defined(__linux__) || defined(__APPLE__)
866 options = QFileDialog::DontUseNativeDialog;
869 QStringList files_qt =
870 QFileDialog::getOpenFileNames(
this,
878 for(
auto qstr: files_qt)
879 files.push_back(qstr.toStdString());
883 for(
auto qstr: drag_files)
884 files.push_back(qstr.toStdString());
887 shift_drag=alt_drag=ctrl_drag=
false;
891 open_SPACE_TIME< HalfedgeGraph >(viewer, files);
895 template<
typename HalfedgeGraph >
898 const std::vector< std::string >& files)
902 for(
auto filename: files)
904 HalfedgeGraph *mesh =
new HalfedgeGraph;
909 QApplication::setOverrideCursor(Qt::WaitCursor);
910 statusBar()->showMessage(
QObject::tr(
"Open mesh file...") );
916 filename, *mesh, *p_pmaps_bag, open_only_pts_mode);
921 if(viewer ==
nullptr || ctrl_pressed)
922 viewer = createNewViewer();
937 openLocation = QFileInfo(QString::fromStdString(filename)).absolutePath();
939 setCurrentFile(QString::fromStdString(filename));
941 catch(
const std::exception& e)
943 std::cout << e.what() <<
'\n';
944 QMessageBox::warning(
952 updateActiveChildTitle();
955 QApplication::restoreOverrideCursor();
963 bool shift_pressed, alt_pressed;
966 if ( (drag==
false) || ((drag==
true) && (recent==
true)) )
968 shift_pressed = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
969 alt_pressed = QApplication::keyboardModifiers().testFlag(Qt::AltModifier);
970 ctrl_pressed = QApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
974 shift_pressed = shift_drag;
975 alt_pressed = alt_drag;
976 ctrl_pressed = ctrl_drag;
981 open_only_pts_mode =
true;
983 open_only_pts_mode =
false;
993 if( activeMdiChild() && (!shift_pressed) && (!ctrl_pressed) )
1000 assert(viewer !=
nullptr);
1005 if(mesh_type ==
"NONE")
1008 shift_drag=alt_drag=ctrl_drag=
false;
1016 #ifdef FEVV_USE_CGAL
1017 if(mesh_type ==
"POLYHEDRON")
1018 on_actionOpen_SPACE_TIME< FEVV::MeshPolyhedron >(viewer);
1019 else if(mesh_type ==
"SURFACEMESH")
1020 on_actionOpen_SPACE_TIME< FEVV::MeshSurface >(viewer);
1021 else if(mesh_type ==
"LCC")
1022 on_actionOpen_SPACE_TIME< FEVV::MeshLCC >(viewer);
1023 else if(mesh_type ==
"CGALPOINTSET")
1024 on_actionOpen_SPACE_TIME< FEVV::CGALPointSet >(viewer);
1027 #ifdef FEVV_USE_OPENMESH
1028 if(mesh_type ==
"OPENMESH")
1029 on_actionOpen_SPACE_TIME< FEVV::MeshOpenMesh >(viewer);
1033 if(mesh_type ==
"AIF")
1034 on_actionOpen_SPACE_TIME< FEVV::MeshAIF >(viewer);
1038 if(mesh_type ==
"PCLPOINTCLOUD")
1039 on_actionOpen_SPACE_TIME< FEVV::PCLPointCloud >(viewer);
1047 QAction *action = qobject_cast<QAction *>(sender());
1055 drag_files << action->data().toString();
1057 on_actionOpen_triggered();
1064 QSettings settings(QString(
APPLICATION+
".ini").toLower(), QSettings::IniFormat);
1065 QStringList files = settings.value(
"recentFileList").toStringList();
1067 QString unixFileName = QDir::fromNativeSeparators(fileName);
1069 files.removeAll(unixFileName);
1070 files.prepend(unixFileName);
1071 while (files.size() > MaxRecentFiles)
1074 settings.setValue(
"recentFileList", files);
1076 updateRecentFileActions();
1082 return QFileInfo(fullFileName).fileName();
1088 QSettings settings(QString(
APPLICATION+
".ini").toLower(), QSettings::IniFormat);
1089 QStringList files = settings.value(
"recentFileList").toStringList();
1091 int numRecentFiles = qMin(files.size(), (
int)MaxRecentFiles);
1093 for (
int i = 0; i < numRecentFiles; ++i)
1095 QString text =
QObject::tr(
"&%1 %2").arg(i + 1).arg(strippedName(files[i]));
1096 recentFileActs[i]->setText(text);
1097 recentFileActs[i]->setData(files[i]);
1098 recentFileActs[i]->setVisible(
true);
1100 for (
int j = numRecentFiles; j < MaxRecentFiles; ++j)
1101 recentFileActs[j]->setVisible(
false);
1103 separatorAct_menuFile->setVisible(numRecentFiles > 0);
1113 QString defaultExtensions =
"OBJ files (*.obj);;"
1114 "OFF files (*.off);;"
1115 "COFF files (*.coff);;"
1116 "PLY files (*.ply);;"
1117 "MSH files (*.msh)";
1119 QString vtkExtensions =
"VTK files (*.vtk);;"
1120 "VTP files (*.vtp);;"
1121 "VTU files (*.vtu)";
1123 QString cgalpointsetExtensions =
"XYZ files (*.xyz);;"
1124 "OFF files (*.off);;"
1125 "PLY files (*.ply)";
1127 QString pclpointcloudExtensions =
"PCD files (*.pcd);;"
1128 "PLY files (*.ply)";
1132 std::vector< FEVV::PMapsContainer * > properties_maps =
1135 for(
unsigned i = 0; i < meshes.
size(); i++)
1137 QString allExtensions;
1139 if(meshes[i].second ==
"CGALPOINTSET")
1141 allExtensions = cgalpointsetExtensions;
1143 else if(meshes[i].second ==
"PCLPOINTCLOUD")
1145 allExtensions = pclpointcloudExtensions;
1149 allExtensions = defaultExtensions;
1151 allExtensions +=
";;" + vtkExtensions;
1157 QFileDialog::Option options = (QFileDialog::Option)0;
1160 options = QFileDialog::DontUseNativeDialog;
1163 QString fileName = QFileDialog::getSaveFileName(
1172 if(suffix.indexOf(
".obj") >= 0)
1174 else if(suffix.indexOf(
".off") >= 0)
1176 else if(suffix.indexOf(
".coff") >= 0)
1177 fileName +=
".coff";
1178 else if(suffix.indexOf(
".ply") >= 0)
1180 else if(suffix.indexOf(
".msh") >= 0)
1182 else if(suffix.indexOf(
".vtk") >= 0)
1184 else if(suffix.indexOf(
".vtp") >= 0)
1186 else if(suffix.indexOf(
".vtu") >= 0)
1188 else if(suffix.indexOf(
".xyz") >= 0)
1190 else if(suffix.indexOf(
".pcd") >= 0)
1194 if(!fileName.isEmpty())
1196 #ifdef FEVV_USE_CGAL
1197 if(meshes[i].second ==
"POLYHEDRON")
1202 *(properties_maps[i]));
1204 if(meshes[i].second ==
"SURFACEMESH")
1209 *(properties_maps[i]));
1211 if(meshes[i].second ==
"LCC")
1213 auto mesh_ptr =
static_cast< FEVV::MeshLCC*
>(meshes[i].first);
1216 *(properties_maps[i]));
1218 if(meshes[i].second ==
"CGALPOINTSET")
1223 *(properties_maps[i]));
1225 #endif //FEVV_USE_CGAL
1227 #ifdef FEVV_USE_OPENMESH
1228 if(meshes[i].second ==
"OPENMESH")
1233 *(properties_maps[i]));
1235 #endif //FEVV_USE_OPENMESH
1238 if(meshes[i].second ==
"AIF")
1240 auto mesh_ptr =
static_cast< FEVV::MeshAIF*
>(meshes[i].first);
1243 *(properties_maps[i]));
1245 #endif //FEVV_USE_AIF
1248 if(meshes[i].second ==
"PCLPOINTCLOUD")
1253 *(properties_maps[i]));
1255 #endif //FEVV_USE_PCL
1257 saveLocation = QFileInfo(fileName).absolutePath();
1266 for(
unsigned i = 0; i < adapters.size(); i++)
1268 if(adapters[i]->isSelected())
1282 mdiArea->closeActiveSubWindow();
1288 clean_closure =
true;
1307 mdiArea->closeAllSubWindows();
1309 if(activeMdiChild())
1330 on_actionClose_triggered();
1337 mdiArea->closeAllSubWindows();
1343 if(activeMdiChild())
1352 QString sRender, sMode;
1354 if(Render == RenderMode::RENDER_LEGACY)
1356 else if(Render == RenderMode::RENDER_SHADERS_DIRECT_LIGHTING)
1357 sRender =
"SHADERS (DIRECT LIGHTING)";
1359 sRender =
"SHADERS (INDIRECT LIGHTING)";
1368 bavQt->setWindowTitle(
1369 bavQt->windowTitle().left(bavQt->windowTitle().indexOf(
'>') + 1) +
1370 QObject::tr(
" - Mode : %1 - Render : %2").arg(sMode).arg(sRender));
1379 if(mdiArea->viewMode() == MdiArea::SubWindowView)
1381 mdiArea->setViewMode(MdiArea::TabbedView);
1382 ui.actionChange_MDI_view_mode->setText(
1383 QObject::tr(
"Change MDI view mode (-> to subwindow view)"));
1387 mdiArea->setViewMode(MdiArea::SubWindowView);
1388 ui.actionChange_MDI_view_mode->setText(
1389 QObject::tr(
"Change MDI view mode (-> to tabbed view)"));
1397 if(activeMdiChild())
1436 updateActiveChildTitle();
1444 if(activeMdiChild())
1455 updateActiveChildTitle();
1463 if(activeMdiChild())
1474 updateActiveChildTitle();
1487 "3D MEsh Processing Platform<br>"
1488 "Copyright (c) 2016-2022 University of Lyon and CNRS (France)<br>"
1490 "LIRIS ORIGAMI / MEPP-team<br>"
1492 "<b>GitHub: <a href=\"https://github.com/MEPP-team/MEPP2\">see online "
1493 "repository</a></b><br>"
1495 "<b>Developer documentation: <a "
1496 "href=\"http://liris.cnrs.fr/mepp/doc/nightly/\">see online "
1503 "<b>OPEN</b> in a new viewer:"
1505 " -> <b>shift + 'Open' menu</b> (or <b>shift</b>* during 'drag & drop')<br>"
1507 "<b>*</b> on Windows, <b>shift</b> is replaced by <b>RIGHT mouse button</b> during 'drag & drop'<br>"
1510 "Viewer -> <b>SELECT</b> mesh : <b>shift</b><br>"
1512 "Viewer -> <b>TRANSLATE</b> mesh : <b>T</b> (Translation "
1513 "draggers must be shown, see toolbar)<br>"
1514 "Viewer -> <b>ROTATE</b> mesh : <b>R</b> (Rotation draggers "
1515 "must be shown, see toolbar)<br>"
1517 "Viewer -> <b>OSG</b> instrumentation : <b>S</b><br>"
1521 " <br>"));
1528 QApplication::primaryScreen()->grabWindow(0).save(
1549 viewer->
grid->setNodeMask(viewer->
m_ShowGrid ? 0xffffffff : 0x0);
1564 std::vector< osg::Geode * > geodes = viewer->
getGeodes();
1573 std::vector< osg::Geode * > geodesSelected =
1575 for(
unsigned i = 0; i < geodesSelected.size(); i++)
1591 std::vector< osg::Geode * > geodes = viewer->
getGeodes();
1594 #pragma GCC diagnostic push
1595 #pragma GCC diagnostic warning "-Wsign-compare"
1597 if(geodes.size() >= 1 && viewer->
current_i_time < (
int)(geodes.size() - 1))
1599 #pragma GCC diagnostic pop
1607 std::vector< osg::Geode * > geodesSelected =
1609 for(
unsigned i = 0; i < geodesSelected.size(); i++)
1625 std::vector< osg::Geode * > geodes = viewer->
getGeodes();
1630 for(
unsigned i = 0; i < geodes.size(); i++)
1650 for(
unsigned i = 0; i < geodesSelected.size(); i++)
1670 std::vector< osg::Group * > draggers1 = viewer->
getDraggers1();
1671 std::vector< osg::Group * > draggers2 = viewer->
getDraggers2();
1673 for(
unsigned i = 0; i < geodes.size(); i++)
1674 geodes[i]->setNodeMask(0xffffffff);
1675 for(
unsigned i = 0; i < draggers1.size(); i++)
1678 for(
unsigned i = 0; i < draggers2.size(); i++)
1689 std::vector< osg::Group * > draggers1 = viewer->
getDraggers1();
1693 for(
unsigned i = 0; i < draggers1.size(); i++)
1694 draggers1[i]->setNodeMask(0x0);
1696 if(draggers1.size())
1702 for(
unsigned i = 0; i < draggers1.size(); i++)
1709 std::vector< osg::Group * > draggers2 = viewer->
getDraggers2();
1713 for(
unsigned i = 0; i < draggers2.size(); i++)
1714 draggers2[i]->setNodeMask(0x0);
1716 if(draggers2.size())
1722 for(
unsigned i = 0; i < draggers2.size(); i++)
1730 std::vector< std::string > meshes_names = viewer->
getMeshesNames();
1731 std::vector< FEVV::PMapsContainer * > properties_maps =
1734 for(
unsigned i = 0; i < meshes.
size(); i++)
1736 #ifdef FEVV_USE_CGAL
1737 if(meshes[i].second ==
"POLYHEDRON")
1740 draw_or_redraw_mesh(mesh_ptr,
1748 if(meshes[i].second ==
"SURFACEMESH")
1751 draw_or_redraw_mesh(mesh_ptr,
1759 if(meshes[i].second ==
"LCC")
1761 auto mesh_ptr =
static_cast< FEVV::MeshLCC*
>(meshes[i].first);
1762 draw_or_redraw_mesh(mesh_ptr,
1770 if(meshes[i].second ==
"CGALPOINTSET")
1773 draw_or_redraw_mesh(mesh_ptr,
1781 #endif //FEVV_USE_CGAL
1783 #ifdef FEVV_USE_OPENMESH
1784 if(meshes[i].second ==
"OPENMESH")
1787 draw_or_redraw_mesh(mesh_ptr,
1795 #endif //FEVV_USE_OPENMESH
1798 if(meshes[i].second ==
"AIF")
1800 auto mesh_ptr =
static_cast< FEVV::MeshAIF*
>(meshes[i].first);
1801 draw_or_redraw_mesh(mesh_ptr,
1809 #endif //FEVV_USE_AIF
1812 if(meshes[i].second ==
"PCLPOINTCLOUD")
1815 draw_or_redraw_mesh(mesh_ptr,
1823 #endif //FEVV_USE_PCL
1832 auto viewer =
dynamic_cast< SimpleViewer *
>(base_viewer);
1833 actionHG(viewer, t, t2);
1840 if(activeMdiChild())
1855 if(activeMdiChild())
1870 if(activeMdiChild())
1885 if(activeMdiChild())
1901 if(activeMdiChild())
1917 if(activeMdiChild())
1933 if(activeMdiChild())
1948 if(activeMdiChild())
1963 if(activeMdiChild())
1978 if(activeMdiChild())
1993 if(activeMdiChild())
2009 if(activeMdiChild())
2014 #if defined(__APPLE__)
2015 QMessageBox::information(
2018 QObject::tr(
"Only legacy rendering is available under OS X."));
2031 updateActiveChildTitle();
2046 for(
unsigned i = 0; i < meshes.
size(); i++)
2056 for(
unsigned i = 0; i < adapters.size(); i++)
2058 if(adapters[i]->isSelected())
2071 if(activeMdiChild())
2083 if(activeMdiChild())
2096 if(activeMdiChild())
2109 if(activeMdiChild())
2122 if(activeMdiChild())
2138 if(activeMdiChild())
2151 #if 0 //TODO-elo-rm-?-ask_MTO
2152 template<
typename HalfedgeGraph >
2162 #if 0 //TODO-elo-rm-?-ask_MTO
2164 FEVV::SimpleWindow::on_actionShow_Selected_triggered()
2166 for(
unsigned i = 0; i < adapters.size(); i++)
2168 if(adapters[i]->isSelected())
2170 BaseAdapterVisu *bav = adapters[i];
2171 bav->getViewer()->m_ShowSelected = !(bav->getViewer()->m_ShowSelected);
2173 #ifdef FEVV_USE_CGAL
2174 if(
dynamic_cast< SimpleViewer< FEVV::MeshPolyhedron > *
>(
2176 showSelectedHG(
dynamic_cast< SimpleViewer< FEVV::MeshPolyhedron > *
>(
2178 else if(
dynamic_cast< SimpleViewer< FEVV::MeshSurface > *
>(
2180 showSelectedHG(
dynamic_cast< SimpleViewer< FEVV::MeshSurface > *
>(
2182 else if(
dynamic_cast< SimpleViewer< FEVV::MeshLCC > *
>(bav->getViewer()))
2184 dynamic_cast< SimpleViewer< FEVV::MeshLCC > *
>(bav->getViewer()));
2186 #ifdef FEVV_USE_OPENMESH
2187 if(
dynamic_cast< SimpleViewer< FEVV::MeshOpenMesh > *
>(bav->getViewer()))
2188 showSelectedHG(
dynamic_cast< SimpleViewer< FEVV::MeshOpenMesh > *
>(
2192 if(
dynamic_cast< SimpleViewer< FEVV::MeshAIF > *
>(bav->getViewer()))
2194 dynamic_cast< SimpleViewer< FEVV::MeshAIF > *
>(bav->getViewer()));
2205 if(activeMdiChild())
2219 if(activeMdiChild())
2233 if(activeMdiChild())
2240 pre_actionHG(bavQt->
getViewer(),
'-',
'-');
2247 if(activeMdiChild())
2261 if(activeMdiChild())
2275 if(activeMdiChild())
2282 pre_actionHG(bavQt->
getViewer(),
'+',
'+');
2290 "is not valid (see init() or attach()). Leaving...",
2291 "SimpleWindow::onAddBall"))
2296 if(adapters.size() > 0)
2298 int x = (std::rand() % 20) - 10;
2299 int y = (std::rand() % 20) - 10;
2300 int z = (std::rand() % 20) - 10;
2302 std::cout <<
"Adding a ball in {" << x <<
"," << y <<
"," << z <<
"}"
2313 "Ball [" + bavQt->windowTitle().toStdString() + std::string(
"]")));
2319 QListWidgetItem *_item_old)
2326 QVariant variant = _item_old->data(Qt::UserRole);
2327 Viewer::DataModel data = variant.value< Viewer::DataModel >();
2328 if(data.type == Helpers::DataType::MODEL && data.node !=
nullptr)
2331 data.viewer->setSelected(
false);
2332 for_each(adapters.begin(), adapters.end(), [&data](
Adapter *w) {
2333 if(w->getViewer() == data.viewer)
2335 w->setSelected(false);
2344 QVariant variant = _item->data(Qt::UserRole);
2345 Viewer::DataModel data = variant.value< Viewer::DataModel >();
2346 if(data.type == Helpers::DataType::MODEL && data.node !=
nullptr)
2348 data.viewer->setNodeSelected(data.node,
true);
2349 data.viewer->setSelected(
true);
2350 for_each(adapters.begin(), adapters.end(), [&data](Adapter *w) {
2351 if(w->getViewer() == data.viewer)
2353 w->setSelected(true);
2357 dynamic_cast< SimpleWindow * >(w->getViewer()->getWindow());
2358 MdiArea *_mdiArea = sw->mdiArea;
2361 BaseAdapterVisuQt *bavQt = dynamic_cast< BaseAdapterVisuQt * >(w);
2362 QList< QMdiSubWindow * > listMdiSubW = _mdiArea->subWindowList();
2364 for(int MdiSubW = 0; MdiSubW < listMdiSubW.size(); ++MdiSubW)
2366 BaseAdapterVisuQt *bavQtMdiSubW =
2367 dynamic_cast< BaseAdapterVisuQt * >(
2368 listMdiSubW.at(MdiSubW)->widget());
2369 if(bavQtMdiSubW->getViewer() == bavQt->getViewer())
2371 _mdiArea->setActiveSubWindow(listMdiSubW.at(MdiSubW));
2386 inline std::vector< FEVV::SimpleWindow::Adapter * >
2389 std::vector< Adapter * > result;
2390 for_each(adapters.begin(), adapters.end(), [&result](
Adapter *w) {
2393 result.push_back(w);
2400 inline std::vector< FEVV::SimpleWindow::Adapter::Viewer * >
2403 std::vector< Adapter::Viewer * > result;
2404 for_each(adapters.begin(), adapters.end(), [&result](
Adapter *w) {
2407 result.push_back(w->getViewer());
2421 .arg((qlonglong)adapter, 0, 16));
2422 adapter->setWindowIcon(QIcon(
":/logo/resources/MEPP.png"));
2424 adapter->attach(viewer);
2429 enableSpaceTimeMenus();
2430 this->attach(adapter,
USE_MDI);
2432 if(this->getMdiArea())
2433 this->getMdiArea()->tileSubWindows();
2443 if(QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
2444 return qobject_cast< QWidget * >(activeSubWindow->widget());
2448 for(
unsigned i = 0; i < adapters.size(); i++)
2450 if(adapters[i]->isSelected())
2454 return qobject_cast< QWidget * >(bavQt);
2465 QSettings settings(QString(
APPLICATION+
".ini").toLower(), QSettings::IniFormat);
2468 QFileInfo fileInfo = model->fileInfo(proxyModel->mapToSource(tree->currentIndex()));
2469 if (fileInfo.isFile())
2470 path = fileInfo.absolutePath();
2472 path = fileInfo.absoluteFilePath();
2473 settings.setValue(
"treeLocation", path);
2475 settings.setValue(
"openLocation", openLocation);
2476 settings.setValue(
"saveLocation", saveLocation);
2478 settings.beginGroup(
"MainWindow");
2479 settings.setValue(
"pos", pos());
2480 settings.setValue(
"size", size());
2482 settings.setValue(
"state", saveState());
2484 settings.setValue(
"dockDirView_MinimumWidth", m_dockDirView_MinimumWidth);
2485 settings.endGroup();
2492 QSettings settings(QString(
APPLICATION+
".ini").toLower(), QSettings::IniFormat);
2494 treeLocation = settings.value(
"treeLocation", QDir::currentPath()).toString();
2496 openLocation = settings.value(
"openLocation", QDir::currentPath()).toString();
2497 saveLocation = settings.value(
"saveLocation", QDir::currentPath()).toString();
2499 settings.beginGroup(
"MainWindow");
2500 #if(FEVV_USE_QT5) // Qt6 in fact...
2501 QScreen *screen = QGuiApplication::primaryScreen();
2502 QRect screen_size = screen->availableGeometry();
2504 QRect screen_size = QDesktopWidget().availableGeometry();
2506 int win_w = screen_size.width() * 0.9;
2507 int win_h = screen_size.height() * 0.8;
2508 int pos_x = (screen_size.width() - win_w) / 2;
2509 int pos_y = (screen_size.height() - win_h) / 2;
2511 move(settings.value(
"pos", QPoint(pos_x, pos_y)).toPoint());
2512 resize(settings.value(
"size", QSize(win_w, win_h)).toSize());
2514 if(!settings.value(
"state").isNull())
2515 restoreState(settings.value(
"state").toByteArray());
2517 m_dockDirView_MinimumWidth = settings.value(
"dockDirView_MinimumWidth", 320).toInt();
if (m_dockDirView_MinimumWidth < 1) m_dockDirView_MinimumWidth=320;
2518 settings.endGroup();