MEPP2 Project
MdiArea.inl
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 #include <QMimeData>
12 
13 #include <QUrl>
14 
15 #include <iostream>
16 
18 
19 inline FEVV::MdiArea::MdiArea(QWidget *parent) : QMdiArea(parent)
20 {
21  bType = bNone;
22 }
23 
24 inline void
25 FEVV::MdiArea::dragEnterEvent(QDragEnterEvent *event)
26 {
27  //std::cout << "dragEnterEvent called" << std::endl;
28  if (event->mimeData()->hasUrls()) // hasFormat("text/uri-list")
29  {
30 // ---------------------------------------------------
31 #ifdef __linux__
32  // new
33  m_mw->activateWindow();
34  m_mw->raise();
35  // new
36 
37  bType=bLeft;
38  if (event->mouseButtons() & Qt::RightButton)
39  bType=bRight;
40 #endif
41 #ifdef _MSC_VER
42  // new
43  m_mw->activateWindow();
44  m_mw->raise();
45  // new
46 
47  bType=bLeft;
48  if (event->mouseButtons() & Qt::RightButton)
49  bType=bRight;
50 #endif
51 // ---------------------------------------------------
52 
53  //std::cout << "acceptProposedAction" << std::endl;
54  event->acceptProposedAction();
55  }
56 }
57 
58 inline void
59 FEVV::MdiArea::dropEvent(QDropEvent *event)
60 {
61  //std::cout << "dropEvent called" << std::endl;
62 
63 // ---------------------------------------------------
64 #ifdef __APPLE__
65  // new
66  m_mw->activateWindow();
67  m_mw->raise();
68  // new
69 
70  bType=bLeft;
71  if (event->keyboardModifiers() & Qt::MetaModifier)
72  bType=bRight;
73 #endif
74 /*#ifdef _MSC_VER
75  // new
76  m_mw->activateWindow();
77  m_mw->raise();
78  // new
79 
80  bType=bLeft;
81  if (event->mouseButtons() & Qt::RightButton)
82  bType=bRight;
83 #endif*/
84 // ---------------------------------------------------
85 
86  QList<QUrl> urls;
87  urls = event->mimeData()->urls();
88 
89  m_mw->drag_files.clear();
90 
91  for (int i=0; i<urls.size(); i++)
92  {
93  QFileInfo fi(urls[i].toLocalFile());
94  QString ext = fi.suffix();
95 
96  if ( (ext.toLower()=="obj") || (ext.toLower()=="off") || (ext.toLower()=="coff") || (ext.toLower()=="ply") || (ext.toLower()=="msh")
97 #ifdef FEVV_USE_VTK
98  || (ext.toLower()=="vtk") || (ext.toLower()=="vtp") || (ext.toLower()=="vtu")
99 #endif
100 #ifdef FEVV_USE_FBX
101  || (ext.toLower()=="fbx")
102 #endif
103 // Point clouds
104 #ifdef FEVV_USE_CGAL
105  || (ext.toLower()=="xyz")// CGALPOINTSET
106 #endif
107 #ifdef FEVV_USE_PCL
108  || (ext.toLower()=="pcd")// PCLPOINTCLOUD
109 #endif
110  )
111  {
112  QString sFile = urls[i].toLocalFile();
113  m_mw->drag_files << sFile;
114 
115  //std::cout << "File: " << sFile.toStdString() << std::endl;
116  }
117  }
118 
119  if (! m_mw->drag_files.isEmpty())
120  {
121  m_mw->drag=true;
122  m_mw->recent=false; // here only for 'protection'
123 
124 #ifdef _MSC_VER
125  if (bType==bRight)
126  m_mw->shift_drag = true;
127  else
128  m_mw->shift_drag = false;
129 #else
130  if (event->keyboardModifiers() & Qt::ShiftModifier)
131  m_mw->shift_drag = true;
132 #endif
133  if (event->keyboardModifiers() & Qt::AltModifier)
134  m_mw->alt_drag = true;
135  if (event->keyboardModifiers() & Qt::ControlModifier)
136  m_mw->ctrl_drag = true;
137 
138  //std::cout << "acceptProposedAction" << std::endl;
139  event->acceptProposedAction();
140 
141  m_mw->on_actionOpen_triggered();
142  }
143 }
FEVV::MdiArea::bType
int bType
mouse bouton type (bNone, bLeft, bRight)
Definition: MdiArea.h:66
FEVV::bRight
@ bRight
Definition: MdiArea.h:23
SimpleWindow.h
FEVV::MdiArea::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event)
Accept a drop mesh file in this zone.
Definition: MdiArea.inl:25
FEVV::bLeft
@ bLeft
Definition: MdiArea.h:23
FEVV::bNone
@ bNone
Definition: MdiArea.h:23
FEVV::MdiArea::dropEvent
void dropEvent(QDropEvent *event)
Load drop mesh file.
Definition: MdiArea.inl:59
FEVV::MdiArea::MdiArea
MdiArea(QWidget *parent)
Constructor.
Definition: MdiArea.inl:19