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 <memory>
27#include <mutex>
28
29#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
30
31// project
32namespace 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 : public SoQtExaminerViewer
39 {
40
41 public:
42 CoinViewer(QWidget* parent,
43 const char* name = NULL,
44 SbBool embed = TRUE,
45 SoQtFullViewer::BuildFlag flag = BUILD_ALL,
46 SoQtViewer::Type type = BROWSER);
47 ~CoinViewer() override;
48
49 // This is all total madness. Why do we put mutexes and locks into shared pointers?
50 using RecursiveMutex = std::recursive_mutex;
51 using RecursiveMutexPtr = std::shared_ptr<RecursiveMutex>;
52 using RecursiveMutexLock = std::unique_lock<RecursiveMutex>;
53 using RecursiveMutexLockPtr = std::shared_ptr<RecursiveMutexLock>;
54
55 /*!
56 * If set, the drawing is protected by this mutex. This overwrites the default mutex.
57 */
58 void setMutex(RecursiveMutexPtr const& m);
59
60
61 /*!
62 * \return This lock allows to safely access the viewer's scene graph.
63 */
65
66 protected:
67 /*!
68 * \brief actualRedraw Reimplement the redraw method in order to lock engine mutex
69 */
70 void actualRedraw(void) override;
71
73 };
74
75 using CoinViewerPtr = std::shared_ptr<CoinViewer>;
76} // namespace armarx
std::recursive_mutex RecursiveMutex
Definition CoinViewer.h:50
RecursiveMutexLockPtr getScopedLock()
std::shared_ptr< RecursiveMutexLock > RecursiveMutexLockPtr
Definition CoinViewer.h:53
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
Definition CoinViewer.h:51
std::unique_lock< RecursiveMutex > RecursiveMutexLock
Definition CoinViewer.h:52
~CoinViewer() override
CoinViewer(QWidget *parent, const char *name=NULL, SbBool embed=TRUE, SoQtFullViewer::BuildFlag flag=BUILD_ALL, SoQtViewer::Type type=BROWSER)
void setMutex(RecursiveMutexPtr const &m)
void actualRedraw(void) override
actualRedraw Reimplement the redraw method in order to lock engine mutex
RecursiveMutexPtr mutex
Definition CoinViewer.h:72
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< CoinViewer > CoinViewerPtr
Definition CoinViewer.h:75