CoinViewer.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Gui
17 * @author Nikolaus Vahrenkamp
18 * @date 2014
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 
26 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
27 
28 #include <memory>
29 #include <mutex>
30 
31 // project
32 namespace armarx
33 {
34 
35  /*!
36  * Basically this is a SoQtExaminerViewer, with the extension that you can specify a mutex that protects the drawing.
37  */
38  class CoinViewer :
39  public SoQtExaminerViewer
40  {
41 
42  public:
43  CoinViewer(QWidget* parent,
44  const char* name = NULL,
45  SbBool embed = TRUE,
46  SoQtFullViewer::BuildFlag flag = BUILD_ALL,
47  SoQtViewer::Type type = BROWSER);
48  ~CoinViewer() override;
49 
50  // This is all total madness. Why do we put mutexes and locks into shared pointers?
51  using RecursiveMutex = std::recursive_mutex;
52  using RecursiveMutexPtr = std::shared_ptr<RecursiveMutex>;
53  using RecursiveMutexLock = std::unique_lock<RecursiveMutex>;
54  using RecursiveMutexLockPtr = std::shared_ptr<RecursiveMutexLock>;
55 
56  /*!
57  * If set, the drawing is protected by this mutex. This overwrites the default mutex.
58  */
59  void setMutex(RecursiveMutexPtr const& m);
60 
61 
62  /*!
63  * \return This lock allows to safely access the viewer's scene graph.
64  */
66 
67  protected:
68 
69  /*!
70  * \brief actualRedraw Reimplement the redraw method in order to lock engine mutex
71  */
72  void actualRedraw(void) override;
73 
75  };
76 
77  using CoinViewerPtr = std::shared_ptr<CoinViewer>;
78 }
79 
armarx::CoinViewer::RecursiveMutexLock
std::unique_lock< RecursiveMutex > RecursiveMutexLock
Definition: CoinViewer.h:53
armarx::CoinViewer
Definition: CoinViewer.h:38
armarx::CoinViewer::~CoinViewer
~CoinViewer() override
armarx::CoinViewer::mutex
RecursiveMutexPtr mutex
Definition: CoinViewer.h:74
armarx::CoinViewer::RecursiveMutexPtr
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
Definition: CoinViewer.h:52
armarx::aron::similarity::FloatSimilarity::Type
Type
The Type enum.
Definition: FloatSimilarity.h:8
armarx::CoinViewer::CoinViewer
CoinViewer(QWidget *parent, const char *name=NULL, SbBool embed=TRUE, SoQtFullViewer::BuildFlag flag=BUILD_ALL, SoQtViewer::Type type=BROWSER)
Definition: CoinViewer.cpp:32
armarx::CoinViewer::RecursiveMutex
std::recursive_mutex RecursiveMutex
Definition: CoinViewer.h:51
armarx::CoinViewer::actualRedraw
void actualRedraw(void) override
actualRedraw Reimplement the redraw method in order to lock engine mutex
Definition: CoinViewer.cpp:62
armarx::CoinViewer::RecursiveMutexLockPtr
std::shared_ptr< RecursiveMutexLock > RecursiveMutexLockPtr
Definition: CoinViewer.h:54
armarx::CoinViewerPtr
std::shared_ptr< CoinViewer > CoinViewerPtr
Definition: CoinViewer.h:77
armarx::CoinViewer::setMutex
void setMutex(RecursiveMutexPtr const &m)
Definition: CoinViewer.cpp:45
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CoinViewer::getScopedLock
RecursiveMutexLockPtr getScopedLock()
Definition: CoinViewer.cpp:50