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