MEPP2 Project
SimpleAdapterVisu.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 #include <QWidget>
14 #include <QMdiArea>
15 #include <QTimer>
16 
17 #if(FEVV_USE_QT5) // FOR_QT6
18 #include <osgQOpenGL/osgQOpenGLWidget> // not used ?
19 #include <osgQOpenGL/osgQOpenGLWindow>
20 #else
21 #include <osgQt/GraphicsWindowQt>
22 // #include <osgViewer/GraphicsWindow>
23 #endif
24 
25 #if __GNUC__ >= 9
26 #pragma GCC diagnostic push
27 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
28 #endif
29 
30 #include <osgViewer/ViewerEventHandlers>
31 
32 #if __GNUC__ >= 9
33 #pragma GCC diagnostic pop
34 #endif
35 
36 #ifndef Q_MOC_RUN // MT : very important to avoid the error : ' Parse error at
37  // "BOOST_JOIN" ' -> (qt4 pb with boost)
39 #endif
40 
41 namespace FEVV {
42 
51 {
52  // Q_OBJECT
53 public:
64  SimpleAdapterVisu(QWidget *_parent = 0, Qt::WindowFlags _f = Qt::Widget);
65 
67  {
68 #ifdef DEBUG_VISU2
69  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
70 #endif
71 
72  // std::cout << "-> ~SimpleAdapterVisu BEGIN" << std::endl;
73  delete myViewer;
74 
75  // std::cout << "-> ~SimpleAdapterVisu END" << std::endl << std::endl;
76 
77 #ifdef DEBUG_VISU2
78  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
79 #endif
80  }
81 
82  void init() override;
83 
84  void init(const bool _useMdiWindows);
85 
86  bool isInit() const override;
87 
88  bool isValid() const override;
89 
90  void apply(Plugin *myPlugin) override;
91 
92  // void setActive( const bool val, const int freq = 1000 );
93 
94  // void attachMesh( HalfedgeGraph& _mesh );
95 
96 protected:
97 #if(FEVV_USE_QT5) // FOR_QT6
98  // empty
99 #else
100  virtual void paintEvent(QPaintEvent * /*event*/) override
101  {
102  static_cast< BaseViewerOSG * >(myViewer)->frame();
103  }
104 #endif
105 
111  bool eventFilter(QObject *obj, QEvent *event) override;
112  //virtual void keyPressEvent(QKeyEvent *event) override; // not used ?
113  //virtual void keyReleaseEvent(QKeyEvent *event) override; // not used ?
114  virtual bool event(QEvent *event) override;
115 
116 
117 #if(FEVV_USE_QT5) // FOR_QT6
118  // empty
119 #else
120  void addViewWidget(osg::ref_ptr< osgQt::GraphicsWindowQt > _gw,
121  osg::ref_ptr< osg::Node > _scene);
122 
123  osg::ref_ptr< osgQt::GraphicsWindowQt >
124  createGraphicsWindow(int _x,
125  int _y,
126  int _w,
127  int _h,
128  const std::string &_name = "",
129  bool _windowDecoration = false) const;
130 #endif
131 
132  // not used ?
133  //osgGA::EventQueue *getEventQueue() const;
134 
135 #if(FEVV_USE_QT5) // FOR_QT6
136 public:
137  osgQOpenGLWidget *my_osgQOpenGLWidget = nullptr; // not used ?
138  osgQOpenGLWindow *my_osgQOpenGLWindow = nullptr;
139 
140 protected:
141 #else
142 protected:
143  osgQt::GraphicsWindowQt *myGraphicsWindow = nullptr;
144 #endif
145 
146  QTimer timerUpdate;
147 
148  // std::vector< std::pair< HalfedgeGraph, bool > > meshes;
149 };
150 
151 } // namespace FEVV
152 
FEVV::SimpleAdapterVisu::paintEvent
virtual void paintEvent(QPaintEvent *) override
Definition: SimpleAdapterVisu.h:100
FEVV::SimpleAdapterVisu::createGraphicsWindow
osg::ref_ptr< osgQt::GraphicsWindowQt > createGraphicsWindow(int _x, int _y, int _w, int _h, const std::string &_name="", bool _windowDecoration=false) const
Definition: SimpleAdapterVisu.inl:261
BaseAdapterVisuQt.h
FEVV::SimpleAdapterVisu
SimpleAdapterVisu is a specialization of QWidget. This class is the widget added to a QMainWindow,...
Definition: SimpleAdapterVisu.h:51
FEVV::BaseViewerOSG
Definition: BaseViewerOSG.h:47
FEVV::SimpleAdapterVisu::addViewWidget
void addViewWidget(osg::ref_ptr< osgQt::GraphicsWindowQt > _gw, osg::ref_ptr< osg::Node > _scene)
Definition: SimpleAdapterVisu.inl:199
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
SimpleAdapterVisu.inl
FEVV::SimpleAdapterVisu::~SimpleAdapterVisu
~SimpleAdapterVisu()
Definition: SimpleAdapterVisu.h:66
FEVV::SimpleAdapterVisu::isInit
bool isInit() const override
Definition: SimpleAdapterVisu.inl:180
FEVV::SimpleAdapterVisu::init
void init() override
Definition: SimpleAdapterVisu.inl:49
FEVV::SimpleAdapterVisu::apply
void apply(Plugin *myPlugin) override
Definition: SimpleAdapterVisu.inl:477
FEVV::SimpleAdapterVisu::timerUpdate
QTimer timerUpdate
Definition: SimpleAdapterVisu.h:146
FEVV::BaseAdapterVisu::Plugin
BasePlugin Plugin
Definition: BaseAdapterVisu.h:30
FEVV::SimpleAdapterVisu::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Definition: SimpleAdapterVisu.inl:423
FEVV::BaseAdapterVisuQt
Definition: BaseAdapterVisuQt.h:22
FEVV::BaseAdapterVisu::myViewer
Viewer * myViewer
Definition: BaseAdapterVisu.h:173
FEVV::SimpleAdapterVisu::event
virtual bool event(QEvent *event) override
Definition: SimpleAdapterVisu.inl:389
FEVV::SimpleAdapterVisu::SimpleAdapterVisu
SimpleAdapterVisu(QWidget *_parent=0, Qt::WindowFlags _f=Qt::Widget)
Definition: SimpleAdapterVisu.inl:33
FEVV::SimpleAdapterVisu::myGraphicsWindow
osgQt::GraphicsWindowQt * myGraphicsWindow
Definition: SimpleAdapterVisu.h:143
FEVV::SimpleAdapterVisu::isValid
bool isValid() const override
Definition: SimpleAdapterVisu.inl:188