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