MEPP2 Project
BaseAdapterVisu.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 "Base/Assert.h"
14 
15 // #include "Visualization/BaseWindow.h"
18 
19 #include <functional>
20 
21 namespace FEVV {
22 
23 class BaseViewer;
24 class BasePlugin;
25 
27 {
28 public:
29  using Viewer = BaseViewer;
30  using Plugin = BasePlugin;
31 
32 public:
40  {
41 #ifdef DEBUG_VISU2
42  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
43 #endif
44 
45 #ifdef DEBUG_VISU2
46  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
47 #endif
48  }
49 
50  virtual ~BaseAdapterVisu()
51  {
52 #ifdef DEBUG_VISU2
53  std::cout << "*** this=" << this << " entering " << __func__ << std::endl;
54 #endif
55 
56 #ifdef DEBUG_VISU2
57  std::cout << "*** this=" << this << " leaving " << __func__ << std::endl;
58 #endif
59  }
60 
64  virtual void attach(Viewer *_viewer)
65  {
66  Assert::check(_viewer != nullptr,
67  "The given viewer is null.",
68  "BaseAdapterVisu::attach(Viewer)");
69  myViewer = _viewer;
70  _viewer->attach(this);
71  }
72 
78  // virtual void attach( Window* _window ) = 0;
79 
85  virtual void init() = 0;
86 
87  virtual bool isInit() const = 0;
88 
89  virtual bool isValid() const = 0;
90 
91  virtual bool isSelected() const
92  {
93  if(myViewer != nullptr)
94  {
95  return myViewer->isSelected();
96  }
97  else
98  {
99  Assert::check(myViewer == nullptr,
100  "myViewer is not attached.",
101  "SimpleWidget::setSelected");
102  return false;
103  }
104  }
105 
106  virtual void setSelected(const bool _isSelected)
107  {
108  if(myViewer != nullptr)
109  {
110  return myViewer->setSelected(_isSelected);
111  }
112  else
113  {
114  Assert::check(myViewer == nullptr,
115  "myViewer is not attached.",
116  "SimpleWidget::setSelected");
117  }
118  }
119 
120  // virtual bool hasWindow() const
121  // {
122  // return (myWindow != nullptr);
123  // }
124 
130  virtual Viewer *getViewer()
131  {
132  Assert::check(myViewer != nullptr,
133  "No viewer attached.",
134  "BaseAdapterVisu::getViewer()");
135  return myViewer;
136  }
137 
138  // virtual Viewer* getViewer( int _position ) = 0;
139 
140  // std::vector< Viewer* > getViewer()
141  // {
142  // return myViewers;
143  // }
144 
145  // virtual std::vector< Viewer* > getSelectedViewers() = 0;
146  // {
147  // std::vector< Viewer* > v_result;
148  // for( unsigned int iViewer = 0; iViewer < myViewers.size(); ++iViewer )
149  // {
150  // if( myViewers[ iViewer ]->isSelected() )
151  // {
152  // v_result.push_back( myViewers[ iViewer ] );
153  // }
154  // }
155  // return v_result;
156  // }
157 
158  // unsigned int getNbViewer()
159  // {
160  // return myViewers.size();
161  // }
162 
168  // virtual Window* getWindow() = 0;
169 
170  virtual void apply(Plugin *myPlugin) = 0;
171 
172 protected:
173  Viewer *myViewer = nullptr;
174  // Window* myWindow = nullptr;
175  bool bIsInit = false;
176  // bool bIsSelected = false;
177 };
178 
179 } // namespace FEVV
FEVV::BaseAdapterVisu::setSelected
virtual void setSelected(const bool _isSelected)
Definition: BaseAdapterVisu.h:106
FEVV::BaseAdapterVisu::bIsInit
bool bIsInit
Definition: BaseAdapterVisu.h:175
FEVV::BaseAdapterVisu::init
virtual void init()=0
FEVV::BaseViewer
Definition: BaseViewer.h:43
FEVV::BaseAdapterVisu::~BaseAdapterVisu
virtual ~BaseAdapterVisu()
Definition: BaseAdapterVisu.h:50
BasePlugin.h
FEVV::BaseAdapterVisu::getViewer
virtual Viewer * getViewer()
Definition: BaseAdapterVisu.h:130
FEVV::BaseAdapterVisu::attach
virtual void attach(Viewer *_viewer)
Definition: BaseAdapterVisu.h:64
FEVV::BaseAdapterVisu::isInit
virtual bool isInit() const =0
FEVV::BaseAdapterVisu
Definition: BaseAdapterVisu.h:27
FEVV::BaseViewer::attach
void attach(Window *_window)
Definition: BaseViewer.h:131
FEVV::BaseAdapterVisu::BaseAdapterVisu
BaseAdapterVisu()
Definition: BaseAdapterVisu.h:39
BaseViewer.h
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::BaseAdapterVisu::apply
virtual void apply(Plugin *myPlugin)=0
FEVV::BaseAdapterVisu::isValid
virtual bool isValid() const =0
FEVV::BaseViewer::setSelected
virtual void setSelected(const bool _isSelected)
Definition: BaseViewer.h:120
FEVV::Assert::check
static bool check(const bool _check, const std::string &_message, const std::string &_where="")
Definition: Assert.h:70
FEVV::BaseAdapterVisu::myViewer
Viewer * myViewer
Definition: BaseAdapterVisu.h:173
FEVV::BasePlugin
Definition: BasePlugin.h:38
FEVV::BaseAdapterVisu::isSelected
virtual bool isSelected() const
Definition: BaseAdapterVisu.h:91
FEVV::BaseViewer::isSelected
virtual bool isSelected() const
Definition: BaseViewer.h:118
Assert.h