CoinViewer.cpp
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
24#include "CoinViewer.h"
25
27
28namespace armarx
29{
30
31
32 CoinViewer::CoinViewer(QWidget* parent,
33 const char* name,
34 SbBool embed,
35 SoQtFullViewer::BuildFlag flag,
36 SoQtViewer::Type type) :
37 SoQtExaminerViewer(parent, name, embed, flag, type),
39 {
40 }
41
42 CoinViewer::~CoinViewer() = default;
43
44 void
46 {
47 mutex = m;
48 }
49
50 auto
52 {
54
55 if (mutex)
56 {
57 l.reset(new RecursiveMutexLock(*mutex));
58 }
59
60 return l;
61 }
62
63 void
65 {
66 // require lock
67 clock_t start = clock();
68 auto l = getScopedLock();
69 clock_t end = clock();
70 long timeMS = (long)(((float)(end - start) / (float)CLOCKS_PER_SEC) * 1000.0);
71
72 if (timeMS > 50)
73 {
74 ARMARX_IMPORTANT_S << " Redraw lock time:" << timeMS;
75 }
76
77 // Render normal scenegraph.
78 SoQtExaminerViewer::actualRedraw();
79 }
80} // 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
#define ARMARX_IMPORTANT_S
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:210
This file offers overloads of toIce() and fromIce() functions for STL container types.
auto make_shared(Args &&... args)