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