Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include <cxToolManagerWidget.h>
13 
14 #include <QGridLayout>
15 #include <QPushButton>
16 
17 #include "cxTrackingService.h"
18 
19 namespace cx
20 {
21 
22 ToolManagerWidget::ToolManagerWidget(TrackingServicePtr trackingService, QWidget* parent) :
23  BaseWidget(parent, "tool_manager_widget", "ToolManager debugger"),
24  mConfigureButton(new QPushButton("Configure")),
25  mDeConfigureButton(new QPushButton("Deconfigure")),
26  mInitializeButton(new QPushButton("Initialize")),
27  mUnInitializeButton(new QPushButton("Uninitialize")),
28  mStartTrackingButton(new QPushButton("Start Tracking")),
29  mStopTrackingButton(new QPushButton("Stop Tracking")),
30  mTrackingService(trackingService)
31 {
32  this->setToolTip("ToolManager debugging utilities");
33  //connect
34  connect(mConfigureButton, SIGNAL(clicked(bool)), this, SLOT(configureClickedSlot(bool)));
35  connect(mDeConfigureButton, SIGNAL(clicked(bool)), this, SLOT(deconfigureClickedSlot(bool)));
36  connect(mInitializeButton, SIGNAL(clicked(bool)), this, SLOT(initializeClickedSlot(bool)));
37  connect(mUnInitializeButton, SIGNAL(clicked(bool)), this, SLOT(uninitializeClickedSlot(bool)));
38  connect(mStartTrackingButton, SIGNAL(clicked(bool)), this, SLOT(startTrackingClickedSlot(bool)));
39  connect(mStopTrackingButton, SIGNAL(clicked(bool)), this, SLOT(stopTrackingClickedSlot(bool)));
40 
41  connect(mTrackingService.get(), &TrackingService::stateChanged, this, &ToolManagerWidget::updateButtonStatusSlot);
42 
43  //layout
44  QGridLayout* layout = new QGridLayout(this);
45  layout->addWidget(mConfigureButton, 0, 0);
46  layout->addWidget(mDeConfigureButton, 0, 1);
47  layout->addWidget(mInitializeButton, 1, 0);
48  layout->addWidget(mUnInitializeButton, 1, 1);
49  layout->addWidget(mStartTrackingButton, 2, 0);
50  layout->addWidget(mStopTrackingButton, 2, 1);
51 
52  this->updateButtonStatusSlot();
53 }
54 
56 {
57 }
58 
59 void ToolManagerWidget::configureClickedSlot(bool checked)
60 {
61  Q_UNUSED(checked);
62  mTrackingService->setState(Tool::tsCONFIGURED);
63 }
64 
65 void ToolManagerWidget::deconfigureClickedSlot(bool checked)
66 {
67  Q_UNUSED(checked);
68  mTrackingService->setState(Tool::tsNONE);
69 }
70 
71 void ToolManagerWidget::initializeClickedSlot(bool checked)
72 {
73  Q_UNUSED(checked);
74  mTrackingService->setState(Tool::tsINITIALIZED);
75 }
76 
77 void ToolManagerWidget::uninitializeClickedSlot(bool checked)
78 {
79  Q_UNUSED(checked);
80  mTrackingService->setState(Tool::tsCONFIGURED);
81 }
82 
83 void ToolManagerWidget::startTrackingClickedSlot(bool checked)
84 {
85  Q_UNUSED(checked);
86  mTrackingService->setState(Tool::tsTRACKING);
87 }
88 
89 void ToolManagerWidget::stopTrackingClickedSlot(bool checked)
90 {
91  Q_UNUSED(checked);
92  mTrackingService->setState(Tool::tsINITIALIZED);
93 }
94 
95 void ToolManagerWidget::updateButtonStatusSlot()
96 {
97  Tool::State state = mTrackingService->getState();
98  mConfigureButton->setEnabled(state < Tool::tsCONFIGURED);
99  mDeConfigureButton->setEnabled(state >= Tool::tsCONFIGURED);
100 
101  mInitializeButton->setEnabled(state < Tool::tsINITIALIZED);
102  mUnInitializeButton->setEnabled(state >= Tool::tsINITIALIZED);
103 
104  mStartTrackingButton->setEnabled(state < Tool::tsTRACKING);
105  mStopTrackingButton->setEnabled(state >= Tool::tsTRACKING);
106 
107 }
108 
109 }
boost::shared_ptr< class TrackingService > TrackingServicePtr
ToolManagerWidget(TrackingServicePtr trackingService, QWidget *parent=NULL)
configured with basic info
Definition: cxTool.h:75
not available
Definition: cxTool.h:74
connected to hardware, if any, ready to use
Definition: cxTool.h:76
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
emitting tracking data
Definition: cxTool.h:77
Namespace for all CustusX production code.