CustusX  15.3.4-beta
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  //connect
53  connect(mConfigureButton, SIGNAL(clicked(bool)), this, SLOT(configureClickedSlot(bool)));
54  connect(mDeConfigureButton, SIGNAL(clicked(bool)), this, SLOT(deconfigureClickedSlot(bool)));
55  connect(mInitializeButton, SIGNAL(clicked(bool)), this, SLOT(initializeClickedSlot(bool)));
56  connect(mUnInitializeButton, SIGNAL(clicked(bool)), this, SLOT(uninitializeClickedSlot(bool)));
57  connect(mStartTrackingButton, SIGNAL(clicked(bool)), this, SLOT(startTrackingClickedSlot(bool)));
58  connect(mStopTrackingButton, SIGNAL(clicked(bool)), this, SLOT(stopTrackingClickedSlot(bool)));
59 
60  connect(trackingService().get(), &TrackingService::stateChanged, this, &ToolManagerWidget::updateButtonStatusSlot);
61 
62  //layout
63  QGridLayout* layout = new QGridLayout(this);
64  layout->addWidget(mConfigureButton, 0, 0);
65  layout->addWidget(mDeConfigureButton, 0, 1);
66  layout->addWidget(mInitializeButton, 1, 0);
67  layout->addWidget(mUnInitializeButton, 1, 1);
68  layout->addWidget(mStartTrackingButton, 2, 0);
69  layout->addWidget(mStopTrackingButton, 2, 1);
70 
71  this->updateButtonStatusSlot();
72 }
73 
75 {
76 }
77 
79 {
80  return "<html>"
81  "<h3>ToolManager debugging utilities.</h3>"
82  "<p>Lets you test different aspects of the toolmanager.</p>"
83  "<p><i></i></p>"
84  "</html>";
85 }
86 
87 void ToolManagerWidget::configureClickedSlot(bool checked)
88 {
90 }
91 
92 void ToolManagerWidget::deconfigureClickedSlot(bool checked)
93 {
94  trackingService()->setState(Tool::tsNONE);
95 }
96 
97 void ToolManagerWidget::initializeClickedSlot(bool checked)
98 {
100 }
101 
102 void ToolManagerWidget::uninitializeClickedSlot(bool checked)
103 {
104  trackingService()->setState(Tool::tsCONFIGURED);
105 }
106 
107 void ToolManagerWidget::startTrackingClickedSlot(bool checked)
108 {
109  trackingService()->setState(Tool::tsTRACKING);
110 }
111 
112 void ToolManagerWidget::stopTrackingClickedSlot(bool checked)
113 {
115 }
116 
117 void ToolManagerWidget::updateButtonStatusSlot()
118 {
119  mConfigureButton->setEnabled(trackingService()->getState() < Tool::tsCONFIGURED);
120  mDeConfigureButton->setEnabled(trackingService()->getState() >= Tool::tsCONFIGURED);
121 
122  mInitializeButton->setEnabled(trackingService()->getState() < Tool::tsINITIALIZED);
123  mUnInitializeButton->setEnabled(trackingService()->getState() >= Tool::tsINITIALIZED);
124 
125  mStartTrackingButton->setEnabled(trackingService()->getState() < Tool::tsTRACKING);
126  mStopTrackingButton->setEnabled(trackingService()->getState() >= Tool::tsTRACKING);
127 
128 }
129 
130 }
configured with basic info
Definition: cxTool.h:81
ToolManagerWidget(QWidget *parent=NULL)
not available
Definition: cxTool.h:80
connected to hardware, if any, ready to use
Definition: cxTool.h:82
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
emitting tracking data
Definition: cxTool.h:83
cxLogicManager_EXPORT TrackingServicePtr trackingService()
virtual QString defaultWhatsThis() const
Returns a short description of what this widget will do for you.