CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxPreferencesDialog.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 #include <QtWidgets>
33 
34 #include <QAction>
35 
36 #include <iostream>
37 #include <vtkRenderWindow.h>
38 #include <vtkRenderer.h>
39 #include "cxLogger.h"
40 #include "cxDoubleWidgets.h"
41 #include "cxEnumConverter.h"
42 #include "cxSettings.h"
43 #include "cxPreferencesDialog.h"
44 #include "cxDataLocations.h"
45 #include "cxTrackingService.h"
46 #include "cxStateService.h"
47 #include "cxFilePreviewWidget.h"
49 #include "cxToolConfigureWidget.h"
50 #include "cxToolFilterWidget.h"
51 #include "cxColorSelectButton.h"
52 #include "cxHelperWidgets.h"
53 #include "cxPatientModelService.h"
54 #include "cxDummyTool.h"
55 #include "cxImage.h"
56 #include "cxProfile.h"
57 
58 namespace cx
59 {
60 
61 VisualizationTab::VisualizationTab(PatientModelServicePtr patientModelService, QWidget *parent) :
62  PreferenceTab(parent), mStereoTypeActionGroup(NULL)
63 {
64  this->setObjectName("preferences_visualization_widget");
65  mPatientModelService = patientModelService;
66  mMainLayout = NULL;
67  mStereoTypeComboBox = NULL;
69 }
70 
72 {
73  double sphereRadius = settings()->value("View3D/sphereRadius").toDouble();
74  mSphereRadius = DoubleProperty::initialize("SphereRadius", "Sphere Radius", "Radius of sphere markers in the 3D scene.", sphereRadius, DoubleRange(0.1,10,0.1), 1, QDomNode());
75 
76  double labelSize = settings()->value("View3D/labelSize").toDouble();
77  mLabelSize = DoubleProperty::initialize("LabelSize", "Label Size", "Size of text labels in the 3D scene.", labelSize, DoubleRange(0.1,100,0.1), 1, QDomNode());
78 
79  ColorSelectButton* backgroundColorButton = new ColorSelectButton("Background Color");
80  backgroundColorButton->setColor(settings()->value("backgroundColor").value<QColor>());
81 
82  connect(backgroundColorButton, SIGNAL(colorChanged(QColor)), this, SLOT(setBackgroundColorSlot(QColor)));
83 
84  bool showDataText = settings()->value("View/showDataText").value<bool>();
85  mShowDataText = BoolProperty::initialize("Show Data Text", "",
86  "Show the name of each data set in the views.",
87  showDataText);
88  bool showLabels = settings()->value("View/showLabels").value<bool>();
89  mShowLabels = BoolProperty::initialize("Show Labels", "",
90  "Attach name labels to entities in the views.",
91  showLabels);
92 
93  bool showMetricNamesInCorner = settings()->value("View/showMetricNamesInCorner").value<bool>();
95  "Show the metric data in the upper right corner of the view instead of in the scene.",
96  showMetricNamesInCorner);
97 
98 
99  double annotationModelSize = settings()->value("View3D/annotationModelSize").toDouble();
100  mAnnotationModelSize = DoubleProperty::initialize("AnnotationModelSize", "Annotation Model Size", "Size (0..1) of the annotation model in the 3D scene.", annotationModelSize, DoubleRange(0.01,1,0.01), 2, QDomNode());
101  QStringList annotationModelRange;
102  foreach(QString path, DataLocations::getRootConfigPaths())
103  {
104  annotationModelRange << QDir(path+"/models/").entryList(QStringList()<<"*.stl");
105  }
106  annotationModelRange.prepend("<default>");
107  QString annotationModel = settings()->value("View3D/annotationModel").toString();
108  mAnnotationModel = StringProperty::initialize("AnnotationModel", "Annotation Model", "Name of annotation model in the 3D scene.", annotationModel, annotationModelRange, QDomNode());
109 
110  //Stereoscopic visualization (3D view)
111  QGroupBox* stereoGroupBox = new QGroupBox("Stereoscopic visualization");
112  mStereoTypeComboBox = new QComboBox();
113  connect(mStereoTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(stereoTypeChangedSlot(int)));
114  this->initStereoTypeComboBox();
115  double eyeAngle = settings()->value("View3D/eyeAngle").toDouble();
116  mEyeAngleAdapter = DoubleProperty::initialize("Eye angle (degrees)", "",
117  "Separation between eyes in degrees",
118  eyeAngle, DoubleRange(0, 25, 0.1), 1);
119  connect(mEyeAngleAdapter.get(), SIGNAL(valueWasSet()), this, SLOT(eyeAngleSlot()));
120 
121  double anyplaneViewOffset = settings()->value("Navigation/anyplaneViewOffset").toDouble();
122  mAnyplaneViewOffset = DoubleProperty::initialize("AnyplaneViewOffset",
123  "View Offset",
124  "Position of virtual tool tip in anyplane view, % from top.",
125  anyplaneViewOffset, DoubleRange(0.1,0.5,0.05), 2, QDomNode());
126  mAnyplaneViewOffset->setInternal2Display(100);
127 
128  bool followTooltip = settings()->value("Navigation/followTooltip").value<bool>();
129  mFollowTooltip = BoolProperty::initialize("Views Follow Tool", "",
130  "ACS Views follow the virtual tool tip",
131  followTooltip);
132  double followTooltipBoundary = settings()->value("Navigation/followTooltipBoundary").toDouble();
133  mFollowTooltipBoundary = DoubleProperty::initialize("FollowTooltipBoundary",
134  "Follow Tool Boundary",
135  "Boundary in ACS Views where follow tool tip is applied. % of view size",
136  followTooltipBoundary, DoubleRange(0.0,0.5,0.05), 2, QDomNode());
137  mFollowTooltipBoundary->setInternal2Display(100);
138 
139 
140  QStringList clinicalViews;
141  for (unsigned i=0; i<mdCOUNT; ++i)
142  clinicalViews << enum2string<CLINICAL_VIEW>(CLINICAL_VIEW(i));
143  mClinicalView = StringProperty::initialize("ClinicalView", "Clinical View",
144  "Type of clinical view",
145  enum2string<CLINICAL_VIEW>(mPatientModelService->getClinicalApplication()),
146  clinicalViews, QDomNode());
147 
148 
149  QVBoxLayout* stereoLayout = new QVBoxLayout();
150  stereoLayout->addWidget(mStereoTypeComboBox);
151  stereoLayout->addWidget(new SpinBoxAndSliderGroupWidget(this, mEyeAngleAdapter));
152  stereoGroupBox->setLayout(stereoLayout);
153 
154  //Layout
155  mMainLayout = new QGridLayout;
156  mMainLayout->addWidget(backgroundColorButton, 0, 0);
157  mMainLayout->addWidget(sscCreateDataWidget(this, mClinicalView));
158  mMainLayout->addWidget(new SpinBoxGroupWidget(this, mSphereRadius));
159  mMainLayout->addWidget(sscCreateDataWidget(this, mShowDataText));
160  mMainLayout->addWidget(sscCreateDataWidget(this, mShowLabels));
161  mMainLayout->addWidget(sscCreateDataWidget(this, mShowMetricNamesInCorner));
162  mMainLayout->addWidget(new SpinBoxGroupWidget(this, mLabelSize));
163  mMainLayout->addWidget(new SpinBoxGroupWidget(this, mAnnotationModelSize));
166  mMainLayout->addWidget(sscCreateDataWidget(this, mFollowTooltip));
168 
169  mMainLayout->addWidget(stereoGroupBox);
170 
171  QHBoxLayout* toptopLayout = new QHBoxLayout;
172  toptopLayout->addLayout(mMainLayout);
173  toptopLayout->addStretch();
174 
175  mTopLayout->addLayout(toptopLayout);
176 }
177 
179 {
181  return;
182  //Insert all actions into an action group
183  mStereoTypeActionGroup = new QActionGroup(this);
184 
185  QAction* stereoFrameSequentialAction = new QAction("Frame-sequential", mStereoTypeActionGroup);
186  QAction* stereoInterlacedAction = new QAction("Interlaced", mStereoTypeActionGroup);
187  QAction* stereoDresdenAction = new QAction("Dresden", mStereoTypeActionGroup);
188  QAction* stereoRedBlueAction = new QAction("Red/Blue", mStereoTypeActionGroup);
189  stereoFrameSequentialAction->setData(QVariant(stFRAME_SEQUENTIAL));
190  stereoInterlacedAction->setData(QVariant(stINTERLACED));
191  stereoDresdenAction->setData(QVariant(stDRESDEN));
192  stereoRedBlueAction->setData(QVariant(stRED_BLUE));
193 
194  connect(stereoFrameSequentialAction, SIGNAL(triggered()), this, SLOT(stereoFrameSequentialSlot()));
195  connect(stereoInterlacedAction, SIGNAL(triggered()), this, SLOT(stereoInterlacedSlot()));
196  connect(stereoDresdenAction, SIGNAL(triggered()), this, SLOT(stereoDresdenSlot()));
197  connect(stereoRedBlueAction, SIGNAL(triggered()), this, SLOT(stereoRedBlueSlot()));
198 
199  mStereoTypeComboBox->blockSignals(true);
200  mStereoTypeComboBox->insertItem(stFRAME_SEQUENTIAL, stereoFrameSequentialAction->text(), stereoFrameSequentialAction->data());
201  mStereoTypeComboBox->insertItem(stINTERLACED, stereoInterlacedAction->text(), stereoInterlacedAction->data());
202  mStereoTypeComboBox->insertItem(stDRESDEN, stereoDresdenAction->text(), stereoDresdenAction->data());
203  mStereoTypeComboBox->insertItem(stRED_BLUE, stereoRedBlueAction->text(), stereoRedBlueAction->data());
204  mStereoTypeComboBox->blockSignals(false);
205 
206  int stereoType = settings()->value("View3D/stereoType").toInt();
207  mStereoTypeComboBox->setCurrentIndex(stereoType);
208 }
209 void VisualizationTab::stereoTypeChangedSlot(int index)
210 {
211  QList<QAction*> actions = mStereoTypeActionGroup->actions();
212  if (index<0 || index>=actions.size())
213  return;
214  actions[index]->trigger();
215 }
216 void VisualizationTab::stereoFrameSequentialSlot()
217 {
218  settings()->setValue("View3D/stereoType", stFRAME_SEQUENTIAL);
219 }
220 void VisualizationTab::stereoInterlacedSlot()
221 {
222  settings()->setValue("View3D/stereoType", stINTERLACED);
223 }
224 void VisualizationTab::stereoDresdenSlot()
225 {
226  settings()->setValue("View3D/stereoType", stDRESDEN);
227 }
228 void VisualizationTab::stereoRedBlueSlot()
229 {
230  settings()->setValue("View3D/stereoType", stRED_BLUE);
231 }
232 
233 void VisualizationTab::eyeAngleSlot()
234 {
235  settings()->setValue("View3D/eyeAngle", mEyeAngleAdapter->getValue());
236 }
237 
239 {
240  mPatientModelService->setClinicalApplication(string2enum<CLINICAL_VIEW>(mClinicalView->getValue()));
241  settings()->setValue("View3D/sphereRadius", mSphereRadius->getValue());
242  settings()->setValue("View/showDataText", mShowDataText->getValue());
243  settings()->setValue("View/showLabels", mShowLabels->getValue());
244  settings()->setValue("View/showMetricNamesInCorner", mShowMetricNamesInCorner->getValue());
245  settings()->setValue("View3D/labelSize", mLabelSize->getValue());
246  settings()->setValue("View3D/annotationModelSize", mAnnotationModelSize->getValue());
247  settings()->setValue("View3D/annotationModel", mAnnotationModel->getValue());
248  settings()->setValue("Navigation/anyplaneViewOffset", mAnyplaneViewOffset->getValue());
249  settings()->setValue("Navigation/followTooltip", mFollowTooltip->getValue());
250  settings()->setValue("Navigation/followTooltipBoundary", mFollowTooltipBoundary->getValue());
251 }
252 
253 void VisualizationTab::setBackgroundColorSlot(QColor color)
254 {
255  settings()->setValue("backgroundColor", color);
256 }
257 
258 //==============================================================================
259 // AutomationTab
260 //------------------------------------------------------------------------------
262  PreferenceTab(parent)
263 {
264  this->setObjectName("preferences_automation_widget");
269  mAutoSaveCheckBox = NULL;
272  mMainLayout = NULL;
273 }
274 
276 {
277  bool autoStartTracking = settings()->value("Automation/autoStartTracking").toBool();
278  mAutoStartTrackingCheckBox = new QCheckBox("Auto Start Tracking");
279  mAutoStartTrackingCheckBox->setChecked(autoStartTracking);
280 
281  bool autoStartStreaming = settings()->value("Automation/autoStartStreaming").toBool();
282  mAutoStartStreamingCheckBox = new QCheckBox("Auto Start Streaming");
283  mAutoStartStreamingCheckBox->setChecked(autoStartStreaming);
284 
285  bool autoReconstruct = settings()->value("Automation/autoReconstruct").toBool();
286  mAutoReconstructCheckBox = new QCheckBox("Auto Reconstruct");
287  mAutoReconstructCheckBox->setChecked(autoReconstruct);
288 
289  bool autoSelectActiveTool = settings()->value("Automation/autoSelectActiveTool").toBool();
290  mAutoSelectActiveToolCheckBox = new QCheckBox("Auto Select Active Tool");
291  mAutoSelectActiveToolCheckBox->setToolTip(""
292  "Automatically select an active tool when a tool becomes visible");
293  mAutoSelectActiveToolCheckBox->setChecked(autoSelectActiveTool);
294 
295  bool autoSave = settings()->value("Automation/autoSave").toBool();
296  mAutoSaveCheckBox = new QCheckBox("Auto Save");
297  mAutoSaveCheckBox->setToolTip(""
298  "Save patient after major events,\n"
299  "such as workflow step change, registration, reconstruction.");
300  mAutoSaveCheckBox->setChecked(autoSave);
301 
302  bool autoShow = settings()->value("Automation/autoShowNewData").toBool();
303  mAutoShowNewDataCheckBox = new QCheckBox("Auto Show New Data");
304  mAutoShowNewDataCheckBox->setToolTip(""
305  "Show new data in the first view.\n"
306  "Occors after load data and reconstruct.");
307  mAutoShowNewDataCheckBox->setChecked(autoShow);
308 
309  bool autoLoadPatient = settings()->value("Automation/autoLoadRecentPatient").toBool();
310  mAutoLoadPatientCheckBox = new QCheckBox("Auto Load Recent Patient");
311  mAutoLoadPatientCheckBox->setToolTip("Load the last saved patient if within a chosen number of hours.");
312  mAutoLoadPatientCheckBox->setChecked(autoLoadPatient);
313 
314  double autoLoadPatientWithinHours = settings()->value("Automation/autoLoadRecentPatientWithinHours").toDouble();
315  mAutoLoadPatientWithinHours = DoubleProperty::initialize("Auto load within hours", "Auto load within hours", "Load the last patient if within this number of hours (and auto load is enabled)", autoLoadPatientWithinHours, DoubleRange(0.1,1000,0.1), 1, QDomNode());
316 
317 
318  //Layout
319  mMainLayout = new QVBoxLayout;
324  mMainLayout->addWidget(mAutoSaveCheckBox);
328 
329  mTopLayout->addLayout(mMainLayout);
330 
331 }
332 
334 {
335  settings()->setValue("Automation/autoStartTracking", mAutoStartTrackingCheckBox->isChecked());
336  settings()->setValue("Automation/autoStartStreaming", mAutoStartStreamingCheckBox->isChecked());
337  settings()->setValue("Automation/autoReconstruct", mAutoReconstructCheckBox->isChecked());
338  settings()->setValue("Automation/autoSelectActiveTool", mAutoSelectActiveToolCheckBox->isChecked());
339  settings()->setValue("Automation/autoSave", mAutoSaveCheckBox->isChecked());
340  settings()->setValue("Automation/autoShowNewData", mAutoShowNewDataCheckBox->isChecked());
341  settings()->setValue("Automation/autoLoadRecentPatient", mAutoLoadPatientCheckBox->isChecked());
342  settings()->setValue("Automation/autoLoadRecentPatientWithinHours", mAutoLoadPatientWithinHours->getValue());
343 }
344 
345 //==============================================================================
346 // UltrasoundTab
347 //------------------------------------------------------------------------------
348 VideoTab::VideoTab(QWidget *parent) :
349  PreferenceTab(parent)
350 {
351  this->setObjectName("preferences_video_widget");
353  mMainLayout = NULL;
354  m24bitRadioButton = NULL;
355  m8bitRadioButton = NULL;
356  mCompressCheckBox = NULL;
357 
358 }
359 
361 {
362  QVBoxLayout* toplayout = new QVBoxLayout;
363  QHBoxLayout* acqNameLayout = new QHBoxLayout;
364  toplayout->addLayout(acqNameLayout);
365 
366  acqNameLayout->addWidget(new QLabel("Name prefix"));
367  mAcquisitionNameLineEdit = new QLineEdit(settings()->value("Ultrasound/acquisitionName").toString());
368  mAcquisitionNameLineEdit->setToolTip("Prefix to name for grabbed video.");
369  acqNameLayout->addWidget(mAcquisitionNameLineEdit);
370 
371  bool bw = settings()->value("Ultrasound/8bitAcquisitionData").toBool();
372 
373  m24bitRadioButton = new QRadioButton("Save acquisition as 24bit", this);
374  m24bitRadioButton->setChecked(!bw);
375  m24bitRadioButton->setToolTip("Convert color video to 24 bit color. If the video already is 8 bit grayscale it will not be converted to 24 bit");
376  m8bitRadioButton = new QRadioButton("Save acquisition as 8bit", this);
377  m8bitRadioButton->setChecked(bw);
378  m8bitRadioButton->setToolTip("Convert acquired video to 8 bit grayscale");
379 
380  mCompressCheckBox = new QCheckBox("Compress acquisition data");
381  mCompressCheckBox->setChecked(settings()->value("Ultrasound/CompressAcquisition", true).toBool());
382  mCompressCheckBox->setToolTip("Store the US Acquisition data as compressed MHD");
383 
384  toplayout->addSpacing(5);
385  toplayout->addWidget(m24bitRadioButton);
386  toplayout->addWidget(m8bitRadioButton);
387  toplayout->addWidget(mCompressCheckBox);
388 
389  mTopLayout->addLayout(toplayout);
390 
391 }
392 
394 {
395  settings()->setValue("Ultrasound/acquisitionName", mAcquisitionNameLineEdit->text());
396  settings()->setValue("Ultrasound/8bitAcquisitionData", m8bitRadioButton->isChecked());
397  settings()->setValue("Ultrasound/CompressAcquisition", mCompressCheckBox->isChecked());
398 }
399 
400 //==============================================================================
401 // ToolConfigTab
402 //------------------------------------------------------------------------------
403 
405  PreferenceTab(parent),
406  mFilePreviewWidget(new FilePreviewWidget(this)),
407  mImagePreviewWidget(new ToolImagePreviewWidget(this))
408 {
409  this->setObjectName("preferences_tool_config_widget");
410  mToolConfigureGroupBox = new ToolConfigureGroupBox(this);
411  mToolFilterGroupBox = new ToolFilterGroupBox(this);
412  mToolFilterGroupBox->setTrackingSystemSelector(mToolConfigureGroupBox->getTrackingSystemSelector());
413 
414  connect(stateService().get(), &StateService::applicationStateChanged, this, &ToolConfigTab::applicationChangedSlot);
415 
416  connect(settings(), SIGNAL(valueChangedFor(QString)), this, SLOT(globalConfigurationFileChangedSlot(QString)));
417 
418  connect(mToolConfigureGroupBox, SIGNAL(toolSelected(QString)), mFilePreviewWidget, SLOT(previewFileSlot(QString)));
419  connect(mToolFilterGroupBox, SIGNAL(toolSelected(QString)), mFilePreviewWidget, SLOT(previewFileSlot(QString)));
420 
421  connect(mToolConfigureGroupBox, SIGNAL(toolSelected(QString)), mImagePreviewWidget, SLOT(previewFileSlot(QString)));
422  connect(mToolFilterGroupBox, SIGNAL(toolSelected(QString)), mImagePreviewWidget, SLOT(previewFileSlot(QString)));
423 
424  this->applicationChangedSlot();
425 }
426 
428 {}
429 
431 {
432  QGroupBox* filepreviewGroupBox = new QGroupBox(this);
433 // filepreviewGroupBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
434 // mFilePreviewWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
435 
436  filepreviewGroupBox->setTitle("Toolfile preview");
437  QHBoxLayout* filepreviewLayout = new QHBoxLayout();
438  filepreviewGroupBox->setLayout(filepreviewLayout);
439 // filepreviewLayout->setMargin(0);
440  filepreviewLayout->addWidget(mFilePreviewWidget);
441 
442  QGroupBox* imagepreviewGroupBox = new QGroupBox(this);
443  imagepreviewGroupBox->setTitle("Tool image preview");
444  QVBoxLayout* imagepreviewLayout = new QVBoxLayout();
445  imagepreviewGroupBox->setLayout(imagepreviewLayout);
446  imagepreviewLayout->setMargin(0);
447  imagepreviewLayout->addWidget(mImagePreviewWidget);
448 
449  //layout
450  QGridLayout* layout = new QGridLayout;
451  mTopLayout->addLayout(layout);
452 
453  layout->addWidget(mToolConfigureGroupBox, 0, 0, 1, 2);
454  layout->addWidget(mToolFilterGroupBox, 0, 2, 1, 2);
455  layout->addWidget(filepreviewGroupBox, 1, 0, 1, 3);
456  layout->addWidget(imagepreviewGroupBox, 1, 3, 1, 1);
457 // layout->setRowStretch(0, 1);
458 // layout->setRowStretch(2, 1);
459 
460  mToolConfigureGroupBox->setCurrentlySelectedCofiguration(profile()->getToolConfigFilePath());
461 }
462 
464 {
465  QString newConfigFile = mToolConfigureGroupBox->requestSaveConfigurationSlot();
466 
467  if(newConfigFile.isEmpty())
468  newConfigFile = mToolConfigureGroupBox->getCurrenctlySelectedConfiguration();
469 
470  // currentToolConfigFile
471  QFile configFile(newConfigFile);
472  QFileInfo info(configFile);
473  if(!configFile.exists())
474  return;
475 
476 // profile()->setToolConfigFilePath(info.fileName());
477  settings()->setValue("toolConfigFile", info.fileName());
478 }
479 
480 void ToolConfigTab::applicationChangedSlot()
481 {
482  mToolFilterGroupBox->setClinicalApplicationSlot(stateService()->getApplicationStateName());
483 }
484 
485 void ToolConfigTab::globalConfigurationFileChangedSlot(QString key)
486 {
487  if(key != "toolConfigFile")
488  return;
489 
490  mToolConfigureGroupBox->setCurrentlySelectedCofiguration(profile()->getToolConfigFilePath());
491 }
492 
493 //==============================================================================
494 // PreferencesDialog
495 //------------------------------------------------------------------------------
496 
497 PreferencesDialog::PreferencesDialog(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget *parent) :
498  QDialog(parent)
499 {
500  mActionGroup = new QActionGroup(this);
501  mActionGroup->setExclusive(true);
502  mToolBar = new QToolBar;
503  mToolBar->setOrientation(Qt::Vertical);
504  mTabWidget = new QStackedWidget;
505 
506  mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
507 
508  this->addTab(new GeneralTab(visualizationService, patientModelService), tr("General"));
509  this->addTab(new PerformanceTab, tr("Performance"));
510  this->addTab(new AutomationTab, tr("Automation"));
511  this->addTab(new VisualizationTab(patientModelService), tr("Visualization"));
512  this->addTab(new VideoTab, tr("Video"));
513  this->addTab(new ToolConfigTab, tr("Tool Configuration"));
514  this->addTab(new DebugTab, tr("Debug"));
515 
516  QPushButton* applyButton = mButtonBox->button(QDialogButtonBox::Apply);
517 
518  connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
519  connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
520  connect(applyButton, SIGNAL(clicked()), this, SLOT(applySlot()));
521 
522  QVBoxLayout *mainLayout = new QVBoxLayout;
523  QHBoxLayout *tabLayout = new QHBoxLayout;
524  QFrame* frame = new QFrame;
525  frame->setLineWidth(3);
526  frame->setFrameShape(QFrame::Panel);
527  frame->setFrameShadow(QFrame::Sunken);
528  frame->setLayout(new QVBoxLayout);
529 
530  tabLayout->addWidget(mToolBar);
531  tabLayout->addWidget(frame);
532  frame->layout()->addWidget(mTabWidget);
533  mainLayout->addLayout(tabLayout);
534  mainLayout->addWidget(mButtonBox);
535  setLayout(mainLayout);
536 
537  mTabWidget->setCurrentIndex(0);
538 
539  mButtonBox->button(QDialogButtonBox::Ok)->setFocus();
540 }
541 
543 {}
544 
545 void PreferencesDialog::selectTabSlot()
546 {
547  QAction* action = dynamic_cast<QAction*>(sender());
548  if (!action)
549  return;
550  int val = action->data().toInt();
551  mTabWidget->setCurrentIndex(val);
552 }
553 
554 void PreferencesDialog::applySlot()
555 {
556  emit applied();
557 }
558 
559 void PreferencesDialog::addTab(PreferenceTab* widget, QString name)
560 {
561  widget->init();
562  connect(mButtonBox, SIGNAL(accepted()), widget, SLOT(saveParametersSlot()));
563  connect(this, SIGNAL(applied()), widget, SLOT(saveParametersSlot()));
564 
565  QAction* action = new QAction(name, mActionGroup);
566  action->setData(mTabWidget->count());
567  action->setCheckable(true);
568  if (!mTabWidget->count())
569  action->setChecked(true);
570  connect(action, SIGNAL(triggered()), this, SLOT(selectTabSlot()));
571  QToolButton* button = new QToolButton(this);
572 
573  button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
574 
575  button->setDefaultAction(action);
576  mToolBar->addWidget(button);
577 
578  mTabWidget->addWidget(widget);
579 }
580 
581 //==============================================================================
582 // UltrasoundTab
583 //------------------------------------------------------------------------------
584 DebugTab::DebugTab(QWidget *parent) :
585  PreferenceTab(parent),
586  mIGSTKDebugLoggingCheckBox(NULL),
587  mManualToolPhysicalPropertiesCheckBox(NULL),
588  mRenderSpeedLoggingCheckBox(NULL),
589  mMainLayout(NULL)
590 {
591  this->setObjectName("preferences_debug_widget");
592 }
593 
595 {
596  mIGSTKDebugLoggingCheckBox = new QCheckBox("IGSTK Debug Logging");
597  mIGSTKDebugLoggingCheckBox->setChecked(settings()->value("IGSTKDebugLogging", true).toBool());
598  mIGSTKDebugLoggingCheckBox->setToolTip("Enables a large amount of logging in IGSTK (need restart)");
599 
600  mManualToolPhysicalPropertiesCheckBox = new QCheckBox("Debug manual tool");
601  mManualToolPhysicalPropertiesCheckBox->setChecked(settings()->value("giveManualToolPhysicalProperties", true).toBool());
602  mManualToolPhysicalPropertiesCheckBox->setToolTip("give manual tool the properties of the first physical tool. \nUse to simulate f.ex. probes with manual tool. (need restart)");
603 
604  QPushButton* runDebugToolButton = new QPushButton("Run Debug Tool", this);
605  runDebugToolButton->setToolTip("Start a dummy tool that runs in a deterministic pattern inside the bounding box of the first found volume.");
606  connect(runDebugToolButton, SIGNAL(clicked()), this, SLOT(runDebugToolSlot()));
607 
608  mRenderSpeedLoggingCheckBox = new QCheckBox("Render Speed Logging");
609  mRenderSpeedLoggingCheckBox->setChecked(settings()->value("renderSpeedLogging", true).toBool());
610  mRenderSpeedLoggingCheckBox->setToolTip("Dump render speed statistics to the console");
611 
612  //Layout
613  mMainLayout = new QGridLayout;
614  int i=0;
615  mMainLayout->addWidget(mIGSTKDebugLoggingCheckBox, i++, 0);
617  mMainLayout->addWidget(runDebugToolButton, i++, 0);
618  mMainLayout->addWidget(mRenderSpeedLoggingCheckBox, i++, 0);
619 
620  mTopLayout->addLayout(mMainLayout);
621 }
622 
624 {
625  if (!patientService()->getData().size())
626  return;
627 
628  cx::ImagePtr image = patientService()->getDataOfType<Image>().begin()->second;
629  cx::DoubleBoundingBox3D bb_r = transform(image->get_rMd(), image->boundingBox());
630 
631  patientService()->setCenter(bb_r.center());
632 
633  cx::DummyToolPtr dummyTool(new cx::DummyTool());
634  dummyTool->setType(Tool::TOOL_POINTER);
635  dummyTool->setToolPositionMovement(dummyTool->createToolPositionMovementTranslationOnly(bb_r));
636  report(QString("Running debug tool inside box %1").arg(qstring_cast(bb_r)));
637  trackingService()->runDummyTool(dummyTool);
638 }
639 
641 {
642  settings()->setValue("IGSTKDebugLogging", mIGSTKDebugLoggingCheckBox->isChecked());
643  settings()->setValue("giveManualToolPhysicalProperties", mManualToolPhysicalPropertiesCheckBox->isChecked());
644  settings()->setValue("renderSpeedLogging", mRenderSpeedLoggingCheckBox->isChecked());
645 }
646 
647 }//namespace cx
QString qstring_cast(const T &val)
DoublePropertyPtr mLabelSize
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:169
Convenience button for chosing color. Will open a color select dialog, and color the button itself in...
QCheckBox * mRenderSpeedLoggingCheckBox
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void setClinicalApplicationSlot(QString val)
QCheckBox * mManualToolPhysicalPropertiesCheckBox
Scalar * begin()
QGridLayout * mMainLayout
void applicationStateChanged()
AutomationTab(QWidget *parent=0)
QCheckBox * mAutoShowNewDataCheckBox
QVBoxLayout * mTopLayout
void setCurrentlySelectedCofiguration(QString configAbsoluteFilePath)
QRadioButton * m24bitRadioButton
VisualizationTab(PatientModelServicePtr patientModelService, QWidget *parent=0)
void addTab(PreferenceTab *widget, QString name)
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:53
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
Widget for easily filtering tools based on clinical application and tracking system.Used in conjunction with ToolConfigureGroupBox, it is possible to drag tools from ToolFilterGroupBox and drop them into configurations in ToolConfigureGroupBox.
Automatic execution of actions when applicable.
QCheckBox * mAutoSaveCheckBox
QCheckBox * mAutoStartTrackingCheckBox
cxLogicManager_EXPORT StateServicePtr stateService()
Tab for general settings in the system.
Definition: cxGeneralTab.h:57
DoublePropertyPtr mAnnotationModelSize
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:87
static QStringList getRootConfigPaths()
DoublePropertyPtr mFollowTooltipBoundary
virtual void saveParametersSlot()
Various parameters related to ultrasound acquisition and reconstruction.
DoublePropertyPtr mSphereRadius
DebugTab(QWidget *parent=0)
stFRAME_SEQUENTIAL
QCheckBox * mAutoLoadPatientCheckBox
BoolPropertyPtr mShowDataText
void setValue(const QString &key, const QVariant &value)
Definition: cxSettings.cpp:79
boost::shared_ptr< class DummyTool > DummyToolPtr
stINTERLACED
void setTrackingSystemSelector(StringPropertyBasePtr selector)
Composite widget for scalar data manipulation.
void setColor(QColor color)
Interface for selecting a tool configuration.
QLineEdit * mAcquisitionNameLineEdit
boost::shared_ptr< class VisualizationService > VisualizationServicePtr
Definition: cxRegServices.h:43
View a xml document.
QVBoxLayout * mMainLayout
QRadioButton * m8bitRadioButton
Widget for displaying a tools image.
DoublePropertyPtr mAutoLoadPatientWithinHours
StringPropertyPtr mClinicalView
A volumetric data set.
Definition: cxImage.h:66
PatientModelServicePtr mPatientModelService
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
QString requestSaveConfigurationSlot()
will save the currently selected configuration if its been edited
QCheckBox * mAutoStartStreamingCheckBox
QActionGroup * mStereoTypeActionGroup
VideoTab(QWidget *parent=0)
QDialogButtonBox * mButtonBox
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:42
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
virtual void init()=0
Implementation of a Tool used for testing.
Definition: cxDummyTool.h:170
Configure performance tab in preferences dialog.
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
ToolConfigTab(QWidget *parent=0)
Manage tool configurationsA widget for creating/modifying tool configurations. The user can select co...
QCheckBox * mCompressCheckBox
Composite widget for scalar data manipulation.
Vector3D center() const
void report(QString msg)
Definition: cxLogger.cpp:90
DoublePropertyPtr mEyeAngleAdapter
cxLogicManager_EXPORT PatientModelServicePtr patientService()
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
QWidget * sscCreateDataWidget(QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
QString getCurrenctlySelectedConfiguration() const
StringPropertyBasePtr getTrackingSystemSelector()
QCheckBox * mIGSTKDebugLoggingCheckBox
stDRESDEN
PreferencesDialog(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget *parent=0)
BoolPropertyPtr mShowLabels
cxLogicManager_EXPORT TrackingServicePtr trackingService()
StringPropertyPtr mAnnotationModel
QCheckBox * mAutoSelectActiveToolCheckBox
QCheckBox * mAutoReconstructCheckBox
BoolPropertyPtr mFollowTooltip
QStackedWidget * mTabWidget
Navigation pointer. Pointing functionality such as tool offset.
Definition: cxTool.h:92
QVBoxLayout * mMainLayout
BoolPropertyPtr mShowMetricNamesInCorner
Debug settings.
DoublePropertyPtr mAnyplaneViewOffset