NorMIT-nav  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxToolManagerWidget.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #include <cxToolManagerWidget.h>
34 
35 #include <QGridLayout>
36 #include <QPushButton>
37 
38 #include "cxTrackingService.h"
39 
40 namespace cx
41 {
42 
44  BaseWidget(parent, "ToolManagerWidget", "ToolManager debugger"),
45  mConfigureButton(new QPushButton("Configure")),
46  mDeConfigureButton(new QPushButton("Deconfigure")),
47  mInitializeButton(new QPushButton("Initialize")),
48  mUnInitializeButton(new QPushButton("Uninitialize")),
49  mStartTrackingButton(new QPushButton("Start Tracking")),
50  mStopTrackingButton(new QPushButton("Stop Tracking"))
51 {
52  this->setToolTip("ToolManager debugging utilities");
53  //connect
54  connect(mConfigureButton, SIGNAL(clicked(bool)), this, SLOT(configureClickedSlot(bool)));
55  connect(mDeConfigureButton, SIGNAL(clicked(bool)), this, SLOT(deconfigureClickedSlot(bool)));
56  connect(mInitializeButton, SIGNAL(clicked(bool)), this, SLOT(initializeClickedSlot(bool)));
57  connect(mUnInitializeButton, SIGNAL(clicked(bool)), this, SLOT(uninitializeClickedSlot(bool)));
58  connect(mStartTrackingButton, SIGNAL(clicked(bool)), this, SLOT(startTrackingClickedSlot(bool)));
59  connect(mStopTrackingButton, SIGNAL(clicked(bool)), this, SLOT(stopTrackingClickedSlot(bool)));
60 
61  connect(trackingService().get(), &TrackingService::stateChanged, this, &ToolManagerWidget::updateButtonStatusSlot);
62 
63  //layout
64  QGridLayout* layout = new QGridLayout(this);
65  layout->addWidget(mConfigureButton, 0, 0);
66  layout->addWidget(mDeConfigureButton, 0, 1);
67  layout->addWidget(mInitializeButton, 1, 0);
68  layout->addWidget(mUnInitializeButton, 1, 1);
69  layout->addWidget(mStartTrackingButton, 2, 0);
70  layout->addWidget(mStopTrackingButton, 2, 1);
71 
72  this->updateButtonStatusSlot();
73 }
74 
76 {
77 }
78 
79 void ToolManagerWidget::configureClickedSlot(bool checked)
80 {
82 }
83 
84 void ToolManagerWidget::deconfigureClickedSlot(bool checked)
85 {
86  trackingService()->setState(Tool::tsNONE);
87 }
88 
89 void ToolManagerWidget::initializeClickedSlot(bool checked)
90 {
92 }
93 
94 void ToolManagerWidget::uninitializeClickedSlot(bool checked)
95 {
97 }
98 
99 void ToolManagerWidget::startTrackingClickedSlot(bool checked)
100 {
101  trackingService()->setState(Tool::tsTRACKING);
102 }
103 
104 void ToolManagerWidget::stopTrackingClickedSlot(bool checked)
105 {
107 }
108 
109 void ToolManagerWidget::updateButtonStatusSlot()
110 {
111  mConfigureButton->setEnabled(trackingService()->getState() < Tool::tsCONFIGURED);
112  mDeConfigureButton->setEnabled(trackingService()->getState() >= Tool::tsCONFIGURED);
113 
114  mInitializeButton->setEnabled(trackingService()->getState() < Tool::tsINITIALIZED);
115  mUnInitializeButton->setEnabled(trackingService()->getState() >= Tool::tsINITIALIZED);
116 
117  mStartTrackingButton->setEnabled(trackingService()->getState() < Tool::tsTRACKING);
118  mStopTrackingButton->setEnabled(trackingService()->getState() >= Tool::tsTRACKING);
119 
120 }
121 
122 }
configured with basic info
Definition: cxTool.h:96
ToolManagerWidget(QWidget *parent=NULL)
not available
Definition: cxTool.h:95
connected to hardware, if any, ready to use
Definition: cxTool.h:97
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
emitting tracking data
Definition: cxTool.h:98
cxLogicManager_EXPORT TrackingServicePtr trackingService()