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"
26 
27 
28 namespace 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)
38  , mutex(std::make_shared<RecursiveMutex>())
39  {
40  }
41 
43  = default;
44 
46  {
47  mutex = m;
48  }
49 
51  {
53 
54  if (mutex)
55  {
56  l.reset(new RecursiveMutexLock(*mutex));
57  }
58 
59  return l;
60  }
61 
63  {
64  // require lock
65  clock_t start = clock();
66  auto l = getScopedLock();
67  clock_t end = clock();
68  long timeMS = (long)(((float)(end - start) / (float)CLOCKS_PER_SEC) * 1000.0);
69 
70  if (timeMS > 50)
71  {
72  ARMARX_IMPORTANT_S << " Redraw lock time:" << timeMS;
73  }
74 
75  // Render normal scenegraph.
76  SoQtExaminerViewer::actualRedraw();
77  }
78 }
ARMARX_IMPORTANT_S
#define ARMARX_IMPORTANT_S
Definition: Logging.h:203
armarx::CoinViewer::RecursiveMutexLock
std::unique_lock< RecursiveMutex > RecursiveMutexLock
Definition: CoinViewer.h:53
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::make_shared
auto make_shared(Args &&...args)
Definition: ManagedIceObject.h:90
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
std
Definition: Application.h:66
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
Logging.h
armarx::CoinViewer::setMutex
void setMutex(RecursiveMutexPtr const &m)
Definition: CoinViewer.cpp:45
CoinViewer.h
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