CustusX  16.12
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 #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 2D Color",
90  "View/tool2DColor",
91  "Set color of tool in 2D");
92  SelectColorSettingButton* toolTipPointColor =
93  new SelectColorSettingButton("Tool Tip",
94  "View/toolTipPointColor",
95  "Set color of tool tip");
96  SelectColorSettingButton* toolOffsetPointColor =
97  new SelectColorSettingButton("Offset Point",
98  "View/toolOffsetPointColor",
99  "Set color of tool offset point");
100  SelectColorSettingButton* toolOffsetLineColor =
101  new SelectColorSettingButton("Offset Line",
102  "View/toolOffsetLineColor",
103  "Set color of tool offset line");
104  SelectColorSettingButton* toolCrossHairColor =
105  new SelectColorSettingButton("Cross hair",
106  "View/toolCrossHairColor",
107  "Set color of tool cross hair");
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("View/toolCrosshair").value<bool>();
119  mToolCrosshair = BoolProperty::initialize("Tool crosshair", "",
120  "Show a crosshair centered on tool for 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("View/toolCrosshair", 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 
450  PreferenceTab(parent),
451  mFilePreviewWidget(new FilePreviewWidget(this)),
452  mImagePreviewWidget(new ToolImagePreviewWidget(this))
453 {
454  this->setObjectName("preferences_tool_config_widget");
455  mToolConfigureGroupBox = new ToolConfigureGroupBox(this);
456  mToolFilterGroupBox = new ToolFilterGroupBox(this);
457  mToolFilterGroupBox->setTrackingSystemSelector(mToolConfigureGroupBox->getTrackingSystemSelector());
458 
459  connect(stateService().get(), &StateService::applicationStateChanged, this, &ToolConfigTab::applicationChangedSlot);
460 
461  connect(settings(), SIGNAL(valueChangedFor(QString)), this, SLOT(globalConfigurationFileChangedSlot(QString)));
462 
463  connect(mToolConfigureGroupBox, SIGNAL(toolSelected(QString)), mFilePreviewWidget, SLOT(previewFileSlot(QString)));
464  connect(mToolFilterGroupBox, SIGNAL(toolSelected(QString)), mFilePreviewWidget, SLOT(previewFileSlot(QString)));
465 
466  connect(mToolConfigureGroupBox, SIGNAL(toolSelected(QString)), mImagePreviewWidget, SLOT(previewFileSlot(QString)));
467  connect(mToolFilterGroupBox, SIGNAL(toolSelected(QString)), mImagePreviewWidget, SLOT(previewFileSlot(QString)));
468 
469  this->applicationChangedSlot();
470 }
471 
473 {}
474 
476 {
477  QGroupBox* filepreviewGroupBox = new QGroupBox(this);
478 // filepreviewGroupBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
479 // mFilePreviewWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
480 
481  filepreviewGroupBox->setTitle("Toolfile preview");
482  QHBoxLayout* filepreviewLayout = new QHBoxLayout();
483  filepreviewGroupBox->setLayout(filepreviewLayout);
484 // filepreviewLayout->setMargin(0);
485  filepreviewLayout->addWidget(mFilePreviewWidget);
486 
487  QGroupBox* imagepreviewGroupBox = new QGroupBox(this);
488  imagepreviewGroupBox->setTitle("Tool image preview");
489  QVBoxLayout* imagepreviewLayout = new QVBoxLayout();
490  imagepreviewGroupBox->setLayout(imagepreviewLayout);
491  imagepreviewLayout->setMargin(0);
492  imagepreviewLayout->addWidget(mImagePreviewWidget);
493 
494  //layout
495  QGridLayout* layout = new QGridLayout;
496  mTopLayout->addLayout(layout);
497 
498  layout->addWidget(mToolConfigureGroupBox, 0, 0, 1, 2);
499  layout->addWidget(mToolFilterGroupBox, 0, 2, 1, 2);
500  layout->addWidget(filepreviewGroupBox, 1, 0, 1, 3);
501  layout->addWidget(imagepreviewGroupBox, 1, 3, 1, 1);
502 // layout->setRowStretch(0, 1);
503 // layout->setRowStretch(2, 1);
504 
505  mToolConfigureGroupBox->setCurrentlySelectedCofiguration(profile()->getToolConfigFilePath());
506 }
507 
509 {
510  QString newConfigFile = mToolConfigureGroupBox->requestSaveConfigurationSlot();
511 
512  if(newConfigFile.isEmpty())
513  newConfigFile = mToolConfigureGroupBox->getCurrenctlySelectedConfiguration();
514 
515  // currentToolConfigFile
516  QFile configFile(newConfigFile);
517  QFileInfo info(configFile);
518  if(!configFile.exists())
519  return;
520 
521 // profile()->setToolConfigFilePath(info.fileName());
522  settings()->setValue("toolConfigFile", info.fileName());
523 }
524 
525 void ToolConfigTab::applicationChangedSlot()
526 {
527  mToolFilterGroupBox->setClinicalApplicationSlot(stateService()->getApplicationStateName());
528 }
529 
530 void ToolConfigTab::globalConfigurationFileChangedSlot(QString key)
531 {
532  if(key != "toolConfigFile")
533  return;
534 
535  mToolConfigureGroupBox->setCurrentlySelectedCofiguration(profile()->getToolConfigFilePath());
536 }
537 
538 //==============================================================================
539 // PreferencesDialog
540 //------------------------------------------------------------------------------
541 
543  QDialog(parent)
544 {
545  mActionGroup = new QActionGroup(this);
546  mActionGroup->setExclusive(true);
547  mToolBar = new QToolBar;
548  mToolBar->setOrientation(Qt::Vertical);
549  mTabWidget = new QStackedWidget;
550 
551  mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
552  VisServicesPtr services = VisServices::create(logicManager()->getPluginContext());
553 
554  this->addTab(new GeneralTab(viewService, patientModelService), tr("General"));
555  this->addTab(new PerformanceTab, tr("Performance"));
556  this->addTab(new AutomationTab, tr("Automation"));
557  this->addTab(new VisualizationTab(patientModelService), tr("Visualization"));
558  this->addTab(new VideoTab, tr("Video"));
559  this->addTab(new ToolConfigTab, tr("Tool Configuration"));
560  this->addTab(new OperatingTableTab(services), tr("Table"));
561  this->addTab(new DebugTab, tr("Debug"));
562 
563  QPushButton* applyButton = mButtonBox->button(QDialogButtonBox::Apply);
564 
565  connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
566  connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
567  connect(applyButton, SIGNAL(clicked()), this, SLOT(applySlot()));
568 
569  QVBoxLayout *mainLayout = new QVBoxLayout;
570  QHBoxLayout *tabLayout = new QHBoxLayout;
571  QFrame* frame = new QFrame;
572  frame->setLineWidth(3);
573  frame->setFrameShape(QFrame::Panel);
574  frame->setFrameShadow(QFrame::Sunken);
575  frame->setLayout(new QVBoxLayout);
576 
577  tabLayout->addWidget(mToolBar);
578  tabLayout->addWidget(frame);
579  frame->layout()->addWidget(mTabWidget);
580  mainLayout->addLayout(tabLayout);
581  mainLayout->addWidget(mButtonBox);
582  setLayout(mainLayout);
583 
584  mTabWidget->setCurrentIndex(0);
585 
586  mButtonBox->button(QDialogButtonBox::Ok)->setFocus();
587 }
588 
590 {}
591 
592 void PreferencesDialog::selectTabSlot()
593 {
594  QAction* action = dynamic_cast<QAction*>(sender());
595  if (!action)
596  return;
597  int val = action->data().toInt();
598  mTabWidget->setCurrentIndex(val);
599 }
600 
601 void PreferencesDialog::applySlot()
602 {
603  emit applied();
604 }
605 
606 void PreferencesDialog::addTab(PreferenceTab* widget, QString name)
607 {
608  widget->init();
609  connect(mButtonBox, SIGNAL(accepted()), widget, SLOT(saveParametersSlot()));
610  connect(this, SIGNAL(applied()), widget, SLOT(saveParametersSlot()));
611 
612  QAction* action = new QAction(name, mActionGroup);
613  action->setData(mTabWidget->count());
614  action->setCheckable(true);
615  if (!mTabWidget->count())
616  action->setChecked(true);
617  connect(action, SIGNAL(triggered()), this, SLOT(selectTabSlot()));
618  QToolButton* button = new QToolButton(this);
619 
620  button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
621 
622  button->setDefaultAction(action);
623  mToolBar->addWidget(button);
624 
625  mTabWidget->addWidget(widget);
626 }
627 
628 //==============================================================================
629 // UltrasoundTab
630 //------------------------------------------------------------------------------
631 DebugTab::DebugTab(QWidget *parent) :
632  PreferenceTab(parent),
633  mIGSTKDebugLoggingCheckBox(NULL),
634  mManualToolPhysicalPropertiesCheckBox(NULL),
635  mRenderSpeedLoggingCheckBox(NULL),
636  mMainLayout(NULL)
637 {
638  this->setObjectName("preferences_debug_widget");
639 }
640 
642 {
643  mIGSTKDebugLoggingCheckBox = new QCheckBox("IGSTK Debug Logging");
644  mIGSTKDebugLoggingCheckBox->setChecked(settings()->value("IGSTKDebugLogging", true).toBool());
645  mIGSTKDebugLoggingCheckBox->setToolTip("Enables a large amount of logging in IGSTK (need restart)");
646 
647  mManualToolPhysicalPropertiesCheckBox = new QCheckBox("Debug manual tool");
648  mManualToolPhysicalPropertiesCheckBox->setChecked(settings()->value("giveManualToolPhysicalProperties", true).toBool());
649  mManualToolPhysicalPropertiesCheckBox->setToolTip("give manual tool the properties of the first physical tool. \nUse to simulate f.ex. probes with manual tool. (need restart)");
650 
651  QPushButton* runDebugToolButton = new QPushButton("Run Debug Tool", this);
652  runDebugToolButton->setToolTip("Start a dummy tool that runs in a deterministic pattern inside the bounding box of the first found volume.");
653  connect(runDebugToolButton, SIGNAL(clicked()), this, SLOT(runDebugToolSlot()));
654 
655  mRenderSpeedLoggingCheckBox = new QCheckBox("Render Speed Logging");
656  mRenderSpeedLoggingCheckBox->setChecked(settings()->value("renderSpeedLogging", true).toBool());
657  mRenderSpeedLoggingCheckBox->setToolTip("Dump render speed statistics to the console");
658 
659  //Layout
660  mMainLayout = new QGridLayout;
661  int i=0;
662  mMainLayout->addWidget(mIGSTKDebugLoggingCheckBox, i++, 0);
664  mMainLayout->addWidget(runDebugToolButton, i++, 0);
665  mMainLayout->addWidget(mRenderSpeedLoggingCheckBox, i++, 0);
666 
667  mTopLayout->addLayout(mMainLayout);
668 }
669 
671 {
672  if (!patientService()->getDatas().size())
673  return;
674 
675  cx::ImagePtr image = patientService()->getDataOfType<Image>().begin()->second;
676  cx::DoubleBoundingBox3D bb_r = transform(image->get_rMd(), image->boundingBox());
677 
678  patientService()->setCenter(bb_r.center());
679 
680  cx::DummyToolPtr dummyTool(new cx::DummyTool());
681  dummyTool->setType(Tool::TOOL_POINTER);
682  dummyTool->setToolPositionMovement(dummyTool->createToolPositionMovementTranslationOnly(bb_r));
683  report(QString("Running debug tool inside box %1").arg(qstring_cast(bb_r)));
684  trackingService()->runDummyTool(dummyTool);
685 }
686 
688 {
689  settings()->setValue("IGSTKDebugLogging", mIGSTKDebugLoggingCheckBox->isChecked());
690  settings()->setValue("giveManualToolPhysicalProperties", mManualToolPhysicalPropertiesCheckBox->isChecked());
691  settings()->setValue("renderSpeedLogging", mRenderSpeedLoggingCheckBox->isChecked());
692 }
693 
694 }//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)
QCheckBox * mAutoShowNewDataCheckBox
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:62
QVBoxLayout * mTopLayout
void setCurrentlySelectedCofiguration(QString configAbsoluteFilePath)
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.
QCheckBox * mAutoSaveCheckBox
static VisServicesPtr create(ctkPluginContext *context)
QCheckBox * mAutoStartTrackingCheckBox
cxLogicManager_EXPORT StateServicePtr stateService()
Tab for general settings in the system.
Definition: cxGeneralTab.h:57
DoublePropertyPtr mAnnotationModelSize
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: cxSettings.cpp:87
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
DebugTab(QWidget *parent=0)
stFRAME_SEQUENTIAL
QCheckBox * mAutoLoadPatientCheckBox
BoolPropertyPtr mShowDataText
PreferencesDialog(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent=0)
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())
ToolConfigTab(QWidget *parent=0)
LogicManager * logicManager()
Manage tool configurationsA widget for creating/modifying tool configurations. The user can select co...
QCheckBox * mCompressCheckBox
Composite widget for scalar data manipulation.
cxLogicManager_EXPORT ViewServicePtr viewService()
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
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:107
QVBoxLayout * mMainLayout
BoolPropertyPtr mShowMetricNamesInCorner
Debug settings.
DoublePropertyPtr mAnyplaneViewOffset