MEPP2 Project
BaseViewer.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 "Visualization/BaseAdapterVisu.h"
14 // #include "Visualization/BaseWindow.h"
15 
16 #include "Base/Color.hpp"
17 #include "Base/Assert.h"
18 
19 // Generic mesh iterators
20 #include <boost/graph/graph_traits.hpp>
21 #include <boost/graph/properties.hpp>
22 #include <osg/PrimitiveSet>
24 
25 namespace FEVV {
26 
28  RENDER_POINTS = osg::PrimitiveSet::POINTS,
29  RENDER_LINES = osg::PrimitiveSet::LINE_LOOP,
30  RENDER_FILL = osg::PrimitiveSet::POLYGON
31 };
32 
33 enum class RenderMode {
34  RENDER_LEGACY = 0,
35  RENDER_SHADERS_DIRECT_LIGHTING = 1,
37 };
38 
39 class BaseAdapterVisu;
40 class BaseWindow;
41 
43 {
44 public:
45  using Window = BaseWindow;
47 
48 public:
53  {
54 #ifdef DEBUG_VISU2
55  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
56 #endif
57 
62 
63  m_UseVertexColor = false;
64  m_UseFaceColor = false;
65  m_UseTexture = false;
66 
67  m_Lighting = true;
68  m_SmoothFlat_Shading = true;
69  m_RenderMode = RenderMode::RENDER_LEGACY;
70 
71  m_ShowAxis = false;
72  m_ShowGrid = false;
73  m_Show_Vertex_Normals = false;
75  m_ShowSelected = true;
76 
77  //
78 
79  m_ShowTranslateDragger = false;
80  m_ShowRotateDragger = false;
81 
82  //
83 
84  m_redraw = false;
87  m_step = 0.;
88 
89  //
90 
91  m_space_time = false;
93 
94  m_time = false;
95 
96 #ifdef DEBUG_VISU2
97  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
98 #endif
99  }
100 
101  virtual ~BaseViewer()
102  {
103 #ifdef DEBUG_VISU2
104  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
105 #endif
106 
107 #ifdef DEBUG_VISU2
108  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
109 #endif
110  }
111 
112  virtual void init() = 0;
113 
114  virtual bool isInit() const = 0;
115 
116  virtual bool isValid() const = 0;
117 
118  virtual bool isSelected() const { return bIsSelected; }
119 
120  virtual void setSelected(const bool _isSelected)
121  {
122  bIsSelected = _isSelected;
123  }
124 
130  // virtual void attach( Adapter* _adapter ) = 0;
131  void attach(Window *_window)
132  {
133  Assert::check(_window != nullptr,
134  "The given window is null.",
135  "BaseViewer::attach(Window)");
136  myWindow = _window;
137  }
138 
139  void attach(Adapter *_adapter)
140  {
141  Assert::check(_adapter != nullptr,
142  "The given adapter is null.",
143  "BaseViewer::attach(Adapter)");
144  myAdapter = _adapter;
145  }
146 
152  virtual bool changeBackgroundColor(const Color &_color) = 0;
153 
161  virtual bool saveScreenshot(const std::string &_name) = 0;
162 
163  Adapter *getAdapter() { return myAdapter; }
164  Window *getWindow() { return myWindow; }
165 
166 protected:
167  Window *myWindow = nullptr;
168  Adapter *myAdapter = nullptr;
169 
170  bool bIsInit = false;
171  bool bIsSelected = false;
172 
173 public:
178 
182 
186 
192 
193  //
194 
197 
198  //
199 
200  bool m_redraw;
203  float m_step;
204 
205  //
206 
209 
210  bool m_time;
211 };
212 
213 } // namespace FEVV
FEVV::BaseViewer::m_RenderMode
RenderMode m_RenderMode
Definition: BaseViewer.h:185
FEVV::BaseViewer::~BaseViewer
virtual ~BaseViewer()
Definition: BaseViewer.h:101
FEVV::BaseViewer::m_Show_Vertex_Normals
bool m_Show_Vertex_Normals
Definition: BaseViewer.h:189
FEVV::BaseViewer::myWindow
Window * myWindow
Definition: BaseViewer.h:167
FEVV::RenderMode::RENDER_LEGACY
@ RENDER_LEGACY
FEVV::BaseViewer::saveScreenshot
virtual bool saveScreenshot(const std::string &_name)=0
FEVV::BaseViewer::m_SmoothFlat_Shading
bool m_SmoothFlat_Shading
Definition: BaseViewer.h:184
FEVV::BaseViewer::getAdapter
Adapter * getAdapter()
Definition: BaseViewer.h:163
FEVV::BaseViewer::BaseViewer
BaseViewer()
Definition: BaseViewer.h:52
FEVV::BaseViewer
Definition: BaseViewer.h:43
FEVV::BaseViewer::m_step
float m_step
Definition: BaseViewer.h:203
FEVV::BaseViewer::bIsInit
bool bIsInit
Definition: BaseViewer.h:170
FEVV::BaseViewer::isInit
virtual bool isInit() const =0
FEVV::BaseViewer::getWindow
Window * getWindow()
Definition: BaseViewer.h:164
FEVV::BaseViewer::m_redraw
bool m_redraw
Definition: BaseViewer.h:200
FEVV::RENDER_LINES
@ RENDER_LINES
Definition: BaseViewer.h:29
FEVV::BaseViewer::m_space_time
bool m_space_time
Definition: BaseViewer.h:207
FEVV::BaseViewer::changeBackgroundColor
virtual bool changeBackgroundColor(const Color &_color)=0
FEVV::BaseAdapterVisu
Definition: BaseAdapterVisu.h:27
FEVV::BaseViewer::attach
void attach(Window *_window)
Definition: BaseViewer.h:131
FEVV::BaseViewer::m_Lighting
bool m_Lighting
Definition: BaseViewer.h:183
FEVV::BaseViewer::myAdapter
Adapter * myAdapter
Definition: BaseViewer.h:168
FEVV::BaseViewer::m_UseFaceColor
bool m_UseFaceColor
Definition: BaseViewer.h:180
FEVV::BaseViewer::m_ShowGrid
bool m_ShowGrid
Definition: BaseViewer.h:188
FEVV::BaseViewer::m_ShowSelected
bool m_ShowSelected
Definition: BaseViewer.h:191
FEVV::BaseViewer::attach
void attach(Adapter *_adapter)
Definition: BaseViewer.h:139
FEVV::BaseViewer::m_space_time_changeColorMode
bool m_space_time_changeColorMode
Definition: BaseViewer.h:208
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::BaseViewer::bIsSelected
bool bIsSelected
Definition: BaseViewer.h:171
FEVV::BaseViewer::m_recreateOSGobj_if_redraw
bool m_recreateOSGobj_if_redraw
Definition: BaseViewer.h:202
FEVV::BaseViewer::init
virtual void init()=0
FEVV::Color
Definition: Color.hpp:18
Geometry_traits.h
FEVV::BaseViewer::isValid
virtual bool isValid() const =0
FEVV::BaseViewer::m_recomputeNT_if_redraw
bool m_recomputeNT_if_redraw
Definition: BaseViewer.h:201
FEVV::BaseViewer::setSelected
virtual void setSelected(const bool _isSelected)
Definition: BaseViewer.h:120
FEVV::BaseViewer::m_RenderSuperimposedEdges
bool m_RenderSuperimposedEdges
Definition: BaseViewer.h:177
FEVV::BaseViewer::m_RenderSuperimposedVertices
bool m_RenderSuperimposedVertices
Definition: BaseViewer.h:175
FEVV::Assert::check
static bool check(const bool _check, const std::string &_message, const std::string &_where="")
Definition: Assert.h:70
FEVV::RENDER_POINTS
@ RENDER_POINTS
Definition: BaseViewer.h:28
FEVV::BaseViewer::m_UseTexture
bool m_UseTexture
Definition: BaseViewer.h:181
FEVV::RENDER_FILL
@ RENDER_FILL
Definition: BaseViewer.h:30
FEVV::BaseViewer::m_UseVertexColor
bool m_UseVertexColor
Definition: BaseViewer.h:179
FEVV::BaseViewer::m_Show_CustomVectors_Vertices
bool m_Show_CustomVectors_Vertices
Definition: BaseViewer.h:190
FEVV::BaseViewer::m_ShowTranslateDragger
bool m_ShowTranslateDragger
Definition: BaseViewer.h:195
Color.hpp
FEVV::BaseViewer::m_RenderSuperimposedVertices_Big
bool m_RenderSuperimposedVertices_Big
Definition: BaseViewer.h:176
FEVV::BaseViewer::m_ShowAxis
bool m_ShowAxis
Definition: BaseViewer.h:187
FEVV::BaseViewer::m_ShowRotateDragger
bool m_ShowRotateDragger
Definition: BaseViewer.h:196
FEVV::BaseWindow
Definition: BaseWindow.h:25
FEVV::BaseViewer::m_time
bool m_time
Definition: BaseViewer.h:210
FEVV::BaseViewer::m_RenderMethod
RenderMethod m_RenderMethod
Definition: BaseViewer.h:174
FEVV::BaseViewer::isSelected
virtual bool isSelected() const
Definition: BaseViewer.h:118
FEVV::RenderMode
RenderMode
Definition: BaseViewer.h:33
Assert.h
FEVV::RenderMethod
RenderMethod
Definition: BaseViewer.h:27