CustusX  15.3.4-beta
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  mPatientModelService = patientModelService;
65  mMainLayout = NULL;
66  mStereoTypeComboBox = NULL;
68 }
69 
71 {
72  double sphereRadius = settings()->value("View3D/sphereRadius").toDouble();
73  mSphereRadius = DoubleProperty::initialize("SphereRadius", "Sphere Radius", "Radius of sphere markers in the 3D scene.", sphereRadius, DoubleRange(0.1,10,0.1), 1, QDomNode());
74 
75  double labelSize = settings()->value("View3D/labelSize").toDouble();
76  mLabelSize = DoubleProperty::initialize("LabelSize", "Label Size", "Size of text labels in the 3D scene.", labelSize, DoubleRange(0.1,100,0.1), 1, QDomNode());
77 
78  ColorSelectButton* backgroundColorButton = new ColorSelectButton("Background Color");
79  backgroundColorButton->setColor(settings()->value("backgroundColor").value<QColor>());
80 
81  connect(backgroundColorButton, SIGNAL(colorChanged(QColor)), this, SLOT(setBackgroundColorSlot(QColor)));
82 
83  bool showDataText = settings()->value("View/showDataText").value<bool>();
84  mShowDataText = BoolProperty::initialize("Show Data Text", "",
85  "Show the name of each data set in the views.",
86  showDataText);
87  bool showLabels = settings()->value("View/showLabels").value<bool>();
88  mShowLabels = BoolProperty::initialize("Show Labels", "",
89  "Attach name labels to entities in the views.",
90  showLabels);
91 
92  bool showMetricNamesInCorner = settings()->value("View/showMetricNamesInCorner").value<bool>();
94  "Show the metric data in the upper right corner of the view instead of in the scene.",
95  showMetricNamesInCorner);
96 
97 
98  double annotationModelSize = settings()->value("View3D/annotationModelSize").toDouble();
99  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());
100  QStringList annotationModelRange;
101  foreach(QString path, DataLocations::getRootConfigPaths())
102  {
103  annotationModelRange << QDir(path+"/models/").entryList(QStringList()<<"*.stl");
104  }
105  annotationModelRange.prepend("<default>");
106  QString annotationModel = settings()->value("View3D/annotationModel").toString();
107  mAnnotationModel = StringProperty::initialize("AnnotationModel", "Annotation Model", "Name of annotation model in the 3D scene.", annotationModel, annotationModelRange, QDomNode());
108 
109  //Stereoscopic visualization (3D view)
110  QGroupBox* stereoGroupBox = new QGroupBox("Stereoscopic visualization");
111  mStereoTypeComboBox = new QComboBox();
112  connect(mStereoTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(stereoTypeChangedSlot(int)));
113  this->initStereoTypeComboBox();
114  double eyeAngle = settings()->value("View3D/eyeAngle").toDouble();
115  mEyeAngleAdapter = DoubleProperty::initialize("Eye angle (degrees)", "",
116  "Separation between eyes in degrees",
117  eyeAngle, DoubleRange(0, 25, 0.1), 1);
118  connect(mEyeAngleAdapter.get(), SIGNAL(valueWasSet()), this, SLOT(eyeAngleSlot()));
119 
120  double anyplaneViewOffset = settings()->value("Navigation/anyplaneViewOffset").toDouble();
121  mAnyplaneViewOffset = DoubleProperty::initialize("AnyplaneViewOffset",
122  "View Offset",
123  "Position of virtual tool tip in anyplane view, % from top.",
124  anyplaneViewOffset, DoubleRange(0.1,0.5,0.05), 2, QDomNode());
125  mAnyplaneViewOffset->setInternal2Display(100);
126 
127  bool followTooltip = settings()->value("Navigation/followTooltip").value<bool>();
128  mFollowTooltip = BoolProperty::initialize("Views Follow Tool", "",
129  "ACS Views follow the virtual tool tip",
130  followTooltip);
131  double followTooltipBoundary = settings()->value("Navigation/followTooltipBoundary").toDouble();
132  mFollowTooltipBoundary = DoubleProperty::initialize("FollowTooltipBoundary",
133  "Follow Tool Boundary",
134  "Boundary in ACS Views where follow tool tip is applied. % of view size",
135  followTooltipBoundary, DoubleRange(0.0,0.5,0.05), 2, QDomNode());
136  mFollowTooltipBoundary->setInternal2Display(100);
137 
138 
139  QStringList clinicalViews;
140  for (unsigned i=0; i<mdCOUNT; ++i)
141  clinicalViews << enum2string<CLINICAL_VIEW>(CLINICAL_VIEW(i));
142  mClinicalView = StringProperty::initialize("ClinicalView", "Clinical View",
143  "Type of clinical view",
144  enum2string<CLINICAL_VIEW>(mPatientModelService->getClinicalApplication()),
145  clinicalViews, QDomNode());
146 
147 
148  QVBoxLayout* stereoLayout = new QVBoxLayout();
149  stereoLayout->addWidget(mStereoTypeComboBox);
150  stereoLayout->addWidget(new SpinBoxAndSliderGroupWidget(this, mEyeAngleAdapter));
151  stereoGroupBox->setLayout(stereoLayout);
152 
153  //Layout
154  mMainLayout = new QGridLayout;
155  mMainLayout->addWidget(backgroundColorButton, 0, 0);
156  mMainLayout->addWidget(sscCreateDataWidget(this, mClinicalView));
157  mMainLayout->addWidget(new SpinBoxGroupWidget(this, mSphereRadius));
158  mMainLayout->addWidget(sscCreateDataWidget(this, mShowDataText));
159  mMainLayout->addWidget(sscCreateDataWidget(this, mShowLabels));
160  mMainLayout->addWidget(sscCreateDataWidget(this, mShowMetricNamesInCorner));
161  mMainLayout->addWidget(new SpinBoxGroupWidget(this, mLabelSize));
162  mMainLayout->addWidget(new SpinBoxGroupWidget(this, mAnnotationModelSize));
165  mMainLayout->addWidget(sscCreateDataWidget(this, mFollowTooltip));
167 
168  mMainLayout->addWidget(stereoGroupBox);
169 
170  QHBoxLayout* toptopLayout = new QHBoxLayout;
171  toptopLayout->addLayout(mMainLayout);
172  toptopLayout->addStretch();
173 
174  mTopLayout->addLayout(toptopLayout);
175 }
176 
178 {
180  return;
181  //Insert all actions into an action group
182  mStereoTypeActionGroup = new QActionGroup(this);
183 
184  QAction* stereoFrameSequentialAction = new QAction("Frame-sequential", mStereoTypeActionGroup);
185  QAction* stereoInterlacedAction = new QAction("Interlaced", mStereoTypeActionGroup);
186  QAction* stereoDresdenAction = new QAction("Dresden", mStereoTypeActionGroup);
187  QAction* stereoRedBlueAction = new QAction("Red/Blue", mStereoTypeActionGroup);
188  stereoFrameSequentialAction->setData(QVariant(stFRAME_SEQUENTIAL));
189  stereoInterlacedAction->setData(QVariant(stINTERLACED));
190  stereoDresdenAction->setData(QVariant(stDRESDEN));
191  stereoRedBlueAction->setData(QVariant(stRED_BLUE));
192 
193  connect(stereoFrameSequentialAction, SIGNAL(triggered()), this, SLOT(stereoFrameSequentialSlot()));
194  connect(stereoInterlacedAction, SIGNAL(triggered()), this, SLOT(stereoInterlacedSlot()));
195  connect(stereoDresdenAction, SIGNAL(triggered()), this, SLOT(stereoDresdenSlot()));
196  connect(stereoRedBlueAction, SIGNAL(triggered()), this, SLOT(stereoRedBlueSlot()));
197 
198  mStereoTypeComboBox->blockSignals(true);
199  mStereoTypeComboBox->insertItem(stFRAME_SEQUENTIAL, stereoFrameSequentialAction->text(), stereoFrameSequentialAction->data());
200  mStereoTypeComboBox->insertItem(stINTERLACED, stereoInterlacedAction->text(), stereoInterlacedAction->data());
201  mStereoTypeComboBox->insertItem(stDRESDEN, stereoDresdenAction->text(), stereoDresdenAction->data());
202  mStereoTypeComboBox->insertItem(stRED_BLUE, stereoRedBlueAction->text(), stereoRedBlueAction->data());
203  mStereoTypeComboBox->blockSignals(false);
204 
205  int stereoType = settings()->value("View3D/stereoType").toInt();
206  mStereoTypeComboBox->setCurrentIndex(stereoType);
207 }
208 void VisualizationTab::stereoTypeChangedSlot(int index)
209 {
210  QList<QAction*> actions = mStereoTypeActionGroup->actions();
211  if (index<0 || index>=actions.size())
212  return;
213  actions[index]->trigger();
214 }
215 void VisualizationTab::stereoFrameSequentialSlot()
216 {
217  settings()->setValue("View3D/stereoType", stFRAME_SEQUENTIAL);
218 }
219 void VisualizationTab::stereoInterlacedSlot()
220 {
221  settings()->setValue("View3D/stereoType", stINTERLACED);
222 }
223 void VisualizationTab::stereoDresdenSlot()
224 {
225  settings()->setValue("View3D/stereoType", stDRESDEN);
226 }
227 void VisualizationTab::stereoRedBlueSlot()
228 {
229  settings()->setValue("View3D/stereoType", stRED_BLUE);
230 }
231 
232 void VisualizationTab::eyeAngleSlot()
233 {
234  settings()->setValue("View3D/eyeAngle", mEyeAngleAdapter->getValue());
235 }
236 
238 {
239  mPatientModelService->setClinicalApplication(string2enum<CLINICAL_VIEW>(mClinicalView->getValue()));
240  settings()->setValue("View3D/sphereRadius", mSphereRadius->getValue());
241  settings()->setValue("View/showDataText", mShowDataText->getValue());
242  settings()->setValue("View/showLabels", mShowLabels->getValue());
243  settings()->setValue("View/showMetricNamesInCorner", mShowMetricNamesInCorner->getValue());
244  settings()->setValue("View3D/labelSize", mLabelSize->getValue());
245  settings()->setValue("View3D/annotationModelSize", mAnnotationModelSize->getValue());
246  settings()->setValue("View3D/annotationModel", mAnnotationModel->getValue());
247  settings()->setValue("Navigation/anyplaneViewOffset", mAnyplaneViewOffset->getValue());
248  settings()->setValue("Navigation/followTooltip", mFollowTooltip->getValue());
249  settings()->setValue("Navigation/followTooltipBoundary", mFollowTooltipBoundary->getValue());
250 }
251 
252 void VisualizationTab::setBackgroundColorSlot(QColor color)
253 {
254  settings()->setValue("backgroundColor", color);
255 }
256 
257 //==============================================================================
258 // AutomationTab
259 //------------------------------------------------------------------------------
261  PreferenceTab(parent)
262 {
267  mAutoSaveCheckBox = NULL;
270  mMainLayout = NULL;
271 }
272 
274 {
275  bool autoStartTracking = settings()->value("Automation/autoStartTracking").toBool();
276  mAutoStartTrackingCheckBox = new QCheckBox("Auto Start Tracking");
277  mAutoStartTrackingCheckBox->setChecked(autoStartTracking);
278 
279  bool autoStartStreaming = settings()->value("Automation/autoStartStreaming").toBool();
280  mAutoStartStreamingCheckBox = new QCheckBox("Auto Start Streaming");
281  mAutoStartStreamingCheckBox->setChecked(autoStartStreaming);
282 
283  bool autoReconstruct = settings()->value("Automation/autoReconstruct").toBool();
284  mAutoReconstructCheckBox = new QCheckBox("Auto Reconstruct");
285  mAutoReconstructCheckBox->setChecked(autoReconstruct);
286 
287  bool autoSelectActiveTool = settings()->value("Automation/autoSelectActiveTool").toBool();
288  mAutoSelectActiveToolCheckBox = new QCheckBox("Auto Select Active Tool");
289  mAutoSelectActiveToolCheckBox->setToolTip(""
290  "Automatically select an active tool when a tool becomes visible");
291  mAutoSelectActiveToolCheckBox->setChecked(autoSelectActiveTool);
292 
293  bool autoSave = settings()->value("Automation/autoSave").toBool();
294  mAutoSaveCheckBox = new QCheckBox("Auto Save");
295  mAutoSaveCheckBox->setToolTip(""
296  "Save patient after major events,\n"
297  "such as workflow step change, registration, reconstruction.");
298  mAutoSaveCheckBox->setChecked(autoSave);
299 
300  bool autoShow = settings()->value("Automation/autoShowNewData").toBool();
301  mAutoShowNewDataCheckBox = new QCheckBox("Auto Show New Data");
302  mAutoShowNewDataCheckBox->setToolTip(""
303  "Show new data in the first view.\n"
304  "Occors after load data and reconstruct.");
305  mAutoShowNewDataCheckBox->setChecked(autoShow);
306 
307  bool autoLoadPatient = settings()->value("Automation/autoLoadRecentPatient").toBool();
308  mAutoLoadPatientCheckBox = new QCheckBox("Auto Load Recent Patient");
309  mAutoLoadPatientCheckBox->setToolTip("Load the last saved patient if within a chosen number of hours.");
310  mAutoLoadPatientCheckBox->setChecked(autoLoadPatient);
311 
312  double autoLoadPatientWithinHours = settings()->value("Automation/autoLoadRecentPatientWithinHours").toDouble();
313  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());
314 
315 
316  //Layout
317  mMainLayout = new QVBoxLayout;
322  mMainLayout->addWidget(mAutoSaveCheckBox);
326 
327  mTopLayout->addLayout(mMainLayout);
328 
329 }
330 
332 {
333  settings()->setValue("Automation/autoStartTracking", mAutoStartTrackingCheckBox->isChecked());
334  settings()->setValue("Automation/autoStartStreaming", mAutoStartStreamingCheckBox->isChecked());
335  settings()->setValue("Automation/autoReconstruct", mAutoReconstructCheckBox->isChecked());
336  settings()->setValue("Automation/autoSelectActiveTool", mAutoSelectActiveToolCheckBox->isChecked());
337  settings()->setValue("Automation/autoSave", mAutoSaveCheckBox->isChecked());
338  settings()->setValue("Automation/autoShowNewData", mAutoShowNewDataCheckBox->isChecked());
339  settings()->setValue("Automation/autoLoadRecentPatient", mAutoLoadPatientCheckBox->isChecked());
340  settings()->setValue("Automation/autoLoadRecentPatientWithinHours", mAutoLoadPatientWithinHours->getValue());
341 }
342 
343 //==============================================================================
344 // UltrasoundTab
345 //------------------------------------------------------------------------------
346 VideoTab::VideoTab(QWidget *parent) :
347  PreferenceTab(parent)
348 {
350  mMainLayout = NULL;
351  m24bitRadioButton = NULL;
352  m8bitRadioButton = NULL;
353  mCompressCheckBox = NULL;
354 }
355 
357 {
358  QVBoxLayout* toplayout = new QVBoxLayout;
359  QHBoxLayout* acqNameLayout = new QHBoxLayout;
360  toplayout->addLayout(acqNameLayout);
361 
362  acqNameLayout->addWidget(new QLabel("Description"));
363  mAcquisitionNameLineEdit = new QLineEdit(settings()->value("Ultrasound/acquisitionName").toString());
364  acqNameLayout->addWidget(mAcquisitionNameLineEdit);
365 
366  bool bw = settings()->value("Ultrasound/8bitAcquisitionData").toBool();
367 
368  m24bitRadioButton = new QRadioButton("Save acquisition as 24bit", this);
369  m24bitRadioButton->setChecked(!bw);
370  m8bitRadioButton = new QRadioButton("Save acquisition as 8bit", this);
371  m8bitRadioButton->setChecked(bw);
372 
373  mCompressCheckBox = new QCheckBox("Compress acquisition data");
374  mCompressCheckBox->setChecked(settings()->value("Ultrasound/CompressAcquisition", true).toBool());
375  mCompressCheckBox->setToolTip("Store the US Acquisition data as compressed MHD");
376 
377  toplayout->addSpacing(5);
378  toplayout->addWidget(m24bitRadioButton);
379  toplayout->addWidget(m8bitRadioButton);
380  toplayout->addWidget(mCompressCheckBox);
381 
382  mTopLayout->addLayout(toplayout);
383 
384 }
385 
387 {
388  settings()->setValue("Ultrasound/acquisitionName", mAcquisitionNameLineEdit->text());
389  settings()->setValue("Ultrasound/8bitAcquisitionData", m8bitRadioButton->isChecked());
390  settings()->setValue("Ultrasound/CompressAcquisition", mCompressCheckBox->isChecked());
391 }
392 
393 //==============================================================================
394 // ToolConfigTab
395 //------------------------------------------------------------------------------
396 
398  PreferenceTab(parent),
399  mFilePreviewWidget(new FilePreviewWidget(this)),
400  mImagePreviewWidget(new ToolImagePreviewWidget(this))
401 {
402  mToolConfigureGroupBox = new ToolConfigureGroupBox(this);
403  mToolFilterGroupBox = new ToolFilterGroupBox(this);
404  mToolFilterGroupBox->setTrackingSystemSelector(mToolConfigureGroupBox->getTrackingSystemSelector());
405 
406  connect(stateService().get(), &StateService::applicationStateChanged, this, &ToolConfigTab::applicationChangedSlot);
407 
408  connect(settings(), SIGNAL(valueChangedFor(QString)), this, SLOT(globalConfigurationFileChangedSlot(QString)));
409 
410  connect(mToolConfigureGroupBox, SIGNAL(toolSelected(QString)), mFilePreviewWidget, SLOT(previewFileSlot(QString)));
411  connect(mToolFilterGroupBox, SIGNAL(toolSelected(QString)), mFilePreviewWidget, SLOT(previewFileSlot(QString)));
412 
413  connect(mToolConfigureGroupBox, SIGNAL(toolSelected(QString)), mImagePreviewWidget, SLOT(previewFileSlot(QString)));
414  connect(mToolFilterGroupBox, SIGNAL(toolSelected(QString)), mImagePreviewWidget, SLOT(previewFileSlot(QString)));
415 
416  this->applicationChangedSlot();
417 }
418 
420 {}
421 
423 {
424  QGroupBox* filepreviewGroupBox = new QGroupBox(this);
425 // filepreviewGroupBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
426 // mFilePreviewWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
427 
428  filepreviewGroupBox->setTitle("Toolfile preview");
429  QHBoxLayout* filepreviewLayout = new QHBoxLayout();
430  filepreviewGroupBox->setLayout(filepreviewLayout);
431 // filepreviewLayout->setMargin(0);
432  filepreviewLayout->addWidget(mFilePreviewWidget);
433 
434  QGroupBox* imagepreviewGroupBox = new QGroupBox(this);
435  imagepreviewGroupBox->setTitle("Tool image preview");
436  QVBoxLayout* imagepreviewLayout = new QVBoxLayout();
437  imagepreviewGroupBox->setLayout(imagepreviewLayout);
438  imagepreviewLayout->setMargin(0);
439  imagepreviewLayout->addWidget(mImagePreviewWidget);
440 
441  //layout
442  QGridLayout* layout = new QGridLayout;
443  mTopLayout->addLayout(layout);
444 
445  layout->addWidget(mToolConfigureGroupBox, 0, 0, 1, 2);
446  layout->addWidget(mToolFilterGroupBox, 0, 2, 1, 2);
447  layout->addWidget(filepreviewGroupBox, 1, 0, 1, 3);
448  layout->addWidget(imagepreviewGroupBox, 1, 3, 1, 1);
449 // layout->setRowStretch(0, 1);
450 // layout->setRowStretch(2, 1);
451 
452  mToolConfigureGroupBox->setCurrentlySelectedCofiguration(profile()->getToolConfigFilePath());
453 }
454 
456 {
457  QString newConfigFile = mToolConfigureGroupBox->requestSaveConfigurationSlot();
458 
459  if(newConfigFile.isEmpty())
460  newConfigFile = mToolConfigureGroupBox->getCurrenctlySelectedConfiguration();
461 
462  // currentToolConfigFile
463  QFile configFile(newConfigFile);
464  QFileInfo info(configFile);
465  if(!configFile.exists())
466  return;
467 
468 // profile()->setToolConfigFilePath(info.fileName());
469  settings()->setValue("toolConfigFile", info.fileName());
470 }
471 
472 void ToolConfigTab::applicationChangedSlot()
473 {
474  mToolFilterGroupBox->setClinicalApplicationSlot(stateService()->getApplicationStateName());
475 }
476 
477 void ToolConfigTab::globalConfigurationFileChangedSlot(QString key)
478 {
479  if(key != "toolConfigFile")
480  return;
481 
482  mToolConfigureGroupBox->setCurrentlySelectedCofiguration(profile()->getToolConfigFilePath());
483 }
484 
485 //==============================================================================
486 // PreferencesDialog
487 //------------------------------------------------------------------------------
488 
489 PreferencesDialog::PreferencesDialog(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget *parent) :
490  QDialog(parent)
491 {
492  mActionGroup = new QActionGroup(this);
493  mActionGroup->setExclusive(true);
494  mToolBar = new QToolBar;
495  mToolBar->setOrientation(Qt::Vertical);
496  mTabWidget = new QStackedWidget;
497 
498  mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
499 
500  this->addTab(new GeneralTab(visualizationService, patientModelService), tr("General"));
501  this->addTab(new PerformanceTab, tr("Performance"));
502  this->addTab(new AutomationTab, tr("Automation"));
503  this->addTab(new VisualizationTab(patientModelService), tr("Visualization"));
504  this->addTab(new VideoTab, tr("Video"));
505  this->addTab(new ToolConfigTab, tr("Tool Configuration"));
506  this->addTab(new DebugTab, tr("Debug"));
507 
508  QPushButton* applyButton = mButtonBox->button(QDialogButtonBox::Apply);
509 
510  connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
511  connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
512  connect(applyButton, SIGNAL(clicked()), this, SLOT(applySlot()));
513 
514  QVBoxLayout *mainLayout = new QVBoxLayout;
515  QHBoxLayout *tabLayout = new QHBoxLayout;
516  QFrame* frame = new QFrame;
517  frame->setLineWidth(3);
518  frame->setFrameShape(QFrame::Panel);
519  frame->setFrameShadow(QFrame::Sunken);
520  frame->setLayout(new QVBoxLayout);
521 
522  tabLayout->addWidget(mToolBar);
523  tabLayout->addWidget(frame);
524  frame->layout()->addWidget(mTabWidget);
525  mainLayout->addLayout(tabLayout);
526  mainLayout->addWidget(mButtonBox);
527  setLayout(mainLayout);
528 
529  mTabWidget->setCurrentIndex(0);
530 
531  mButtonBox->button(QDialogButtonBox::Ok)->setFocus();
532 }
533 
535 {}
536 
537 void PreferencesDialog::selectTabSlot()
538 {
539  QAction* action = dynamic_cast<QAction*>(sender());
540  if (!action)
541  return;
542  int val = action->data().toInt();
543  mTabWidget->setCurrentIndex(val);
544 }
545 
546 void PreferencesDialog::applySlot()
547 {
548  emit applied();
549 }
550 
551 void PreferencesDialog::addTab(PreferenceTab* widget, QString name)
552 {
553  widget->init();
554  connect(mButtonBox, SIGNAL(accepted()), widget, SLOT(saveParametersSlot()));
555  connect(this, SIGNAL(applied()), widget, SLOT(saveParametersSlot()));
556 
557  QAction* action = new QAction(name, mActionGroup);
558  action->setData(mTabWidget->count());
559  action->setCheckable(true);
560  if (!mTabWidget->count())
561  action->setChecked(true);
562  connect(action, SIGNAL(triggered()), this, SLOT(selectTabSlot()));
563  QToolButton* button = new QToolButton(this);
564 
565  button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
566 
567  button->setDefaultAction(action);
568  mToolBar->addWidget(button);
569 
570  mTabWidget->addWidget(widget);
571 }
572 
573 //==============================================================================
574 // UltrasoundTab
575 //------------------------------------------------------------------------------
576 DebugTab::DebugTab(QWidget *parent) :
577  PreferenceTab(parent),
578  mIGSTKDebugLoggingCheckBox(NULL),
579  mManualToolPhysicalPropertiesCheckBox(NULL),
580  mRenderSpeedLoggingCheckBox(NULL),
581  mMainLayout(NULL)
582 {
583 }
584 
586 {
587  mIGSTKDebugLoggingCheckBox = new QCheckBox("IGSTK Debug Logging");
588  mIGSTKDebugLoggingCheckBox->setChecked(settings()->value("IGSTKDebugLogging", true).toBool());
589  mIGSTKDebugLoggingCheckBox->setToolTip("Enables a large amount of logging in IGSTK (need restart)");
590 
591  mManualToolPhysicalPropertiesCheckBox = new QCheckBox("Debug manual tool");
592  mManualToolPhysicalPropertiesCheckBox->setChecked(settings()->value("giveManualToolPhysicalProperties", true).toBool());
593  mManualToolPhysicalPropertiesCheckBox->setToolTip("give manual tool the properties of the first physical tool. \nUse to simulate f.ex. probes with manual tool. (need restart)");
594 
595  QPushButton* runDebugToolButton = new QPushButton("Run Debug Tool", this);
596  runDebugToolButton->setToolTip("Start a dummy tool that runs in a deterministic pattern inside the bounding box of the first found volume.");
597  connect(runDebugToolButton, SIGNAL(clicked()), this, SLOT(runDebugToolSlot()));
598 
599  mRenderSpeedLoggingCheckBox = new QCheckBox("Render Speed Logging");
600  mRenderSpeedLoggingCheckBox->setChecked(settings()->value("renderSpeedLogging", true).toBool());
601  mRenderSpeedLoggingCheckBox->setToolTip("Dump render speed statistics to the console");
602 
603  //Layout
604  mMainLayout = new QGridLayout;
605  int i=0;
606  mMainLayout->addWidget(mIGSTKDebugLoggingCheckBox, i++, 0);
608  mMainLayout->addWidget(runDebugToolButton, i++, 0);
609  mMainLayout->addWidget(mRenderSpeedLoggingCheckBox, i++, 0);
610 
611  mTopLayout->addLayout(mMainLayout);
612 }
613 
615 {
616  if (!patientService()->getData().size())
617  return;
618 
619  cx::ImagePtr image = patientService()->getDataOfType<Image>().begin()->second;
620  cx::DoubleBoundingBox3D bb_r = transform(image->get_rMd(), image->boundingBox());
621 
622  patientService()->setCenter(bb_r.center());
623 
624  cx::DummyToolPtr dummyTool(new cx::DummyTool());
625  dummyTool->setType(Tool::TOOL_POINTER);
626  dummyTool->setToolPositionMovement(dummyTool->createToolPositionMovementTranslationOnly(bb_r));
627  report(QString("Running debug tool inside box %1").arg(qstring_cast(bb_r)));
628  trackingService()->runDummyTool(dummyTool);
629 }
630 
632 {
633  settings()->setValue("IGSTKDebugLogging", mIGSTKDebugLoggingCheckBox->isChecked());
634  settings()->setValue("giveManualToolPhysicalProperties", mManualToolPhysicalPropertiesCheckBox->isChecked());
635  settings()->setValue("renderSpeedLogging", mRenderSpeedLoggingCheckBox->isChecked());
636 }
637 
638 }//namespace cx
QString qstring_cast(const T &val)
DoublePropertyPtr mLabelSize
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:142
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:99
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:91
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:64
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