NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxMeshGlyphsWidget.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #include "cxMeshGlyphsWidget.h"
12 
13 #include <QVBoxLayout>
14 #include "cxImage.h"
15 
16 #include "cxDoubleProperty.h"
20 #include "cxMeshHelpers.h"
21 #include "cxHelperWidgets.h"
22 #include "cxColorProperty.h"
23 #include "cxDataLocations.h"
24 #include "cxDataInterface.h"
25 #include "cxDataSelectWidget.h"
27 
28 #include "cxPatientModelService.h"
29 #include "cxLogger.h"
30 #include "cxProfile.h"
31 #include "cxVisServices.h"
33 
34 namespace cx
35 {
36 
37 MeshGlyphsWidget::MeshGlyphsWidget(SelectDataStringPropertyBasePtr meshSelector,
38  PatientModelServicePtr patientModelService,
39  ViewServicePtr viewService,
40  QWidget* parent) :
41  BaseWidget(parent, "mesh_glyphs_widget", "Glyphs"),
42  mPatientModelService(patientModelService),
43  mViewService(viewService),
44  mMeshSelector(meshSelector)
45 {
46  connect(mMeshSelector.get(), &Property::changed, this, &MeshGlyphsWidget::meshSelectedSlot);
47  this->addWidgets();
48  this->meshSelectedSlot();
49 }
50 
52 {
53 }
54 
56 {
57  if (mMesh == mMeshSelector->getData())
58  return;
59 
60  if(mMesh)
61  {
62  disconnect(mGlyphVisualizationCheckBox, SIGNAL(toggled(bool)), mMesh.get(), SLOT(setShowGlyph(bool)));
63  disconnect(mMesh.get(), SIGNAL(meshChanged()), this, SLOT(meshChangedSlot()));
64  }
65 
66  mMesh = boost::dynamic_pointer_cast<Mesh>(mMeshSelector->getData());
67 
68  mGlyphOrientationArrayAdapter->setData(mMesh);
69  mGlyphColorArrayAdapter->setData(mMesh);
70  mGlyphColorLUTAdapter->setData(mMesh);
71 
72  if (!mMesh)
73  {
74  return;
75  }
76 
77  mGlyphVisualizationCheckBox->setChecked(mMesh->showGlyph());
78  mGlyphVisualizationCheckBox->setEnabled(mMesh->hasGlyph());
79 
80  connect(mGlyphVisualizationCheckBox, SIGNAL(toggled(bool)), mMesh.get(), SLOT(setShowGlyph(bool)));
81 
82  connect(mMesh.get(), SIGNAL(meshChanged()), this, SLOT(meshChangedSlot()));
83 }
84 
86 {
87  if(!mMesh)
88  return;
89  mGlyphVisualizationCheckBox->setChecked(mMesh->showGlyph());
90  mGlyphVisualizationCheckBox->setEnabled(mMesh->hasGlyph());
91 }
92 
93 void MeshGlyphsWidget::addWidgets()
94 {
95  QVBoxLayout* toptopLayout = new QVBoxLayout(this);
96  QGridLayout* gridLayout = new QGridLayout;
97  gridLayout->setMargin(0);
98  toptopLayout->addLayout(gridLayout);
99 
100  mGlyphOrientationArrayAdapter = StringPropertyGlyphOrientationArray::New(mPatientModelService);
101  mGlyphColorArrayAdapter = StringPropertyGlyphColorArray::New(mPatientModelService);
102  mGlyphColorLUTAdapter = StringPropertyGlyphLUT::New(mPatientModelService);
103 
104  int row = 1;
105  mGlyphVisualizationCheckBox = new QCheckBox("Enable glyph visualization");
106  mGlyphVisualizationCheckBox->setToolTip("Enable glyph visualization");
107  gridLayout->addWidget(mGlyphVisualizationCheckBox, row++,0);
108  new LabeledComboBoxWidget(this, mGlyphOrientationArrayAdapter,gridLayout, row++);
109  new LabeledComboBoxWidget(this, mGlyphColorArrayAdapter,gridLayout, row++);
110  new LabeledComboBoxWidget(this, mGlyphColorLUTAdapter,gridLayout, row++);
111  toptopLayout->addStretch();
112 }
113 
114 
115 
116 }//end namespace cx
cx::LabeledComboBoxWidget
Composite widget for string selection.
Definition: cxLabeledComboBoxWidget.h:36
cxLogger.h
cxMeshGlyphsWidget.h
cx::MeshGlyphsWidget::meshSelectedSlot
void meshSelectedSlot()
Definition: cxMeshGlyphsWidget.cpp:55
cx::MeshGlyphsWidget::meshChangedSlot
void meshChangedSlot()
Definition: cxMeshGlyphsWidget.cpp:85
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::BaseWidget
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
cxImage.h
cx::Property::changed
void changed()
emit when the underlying data value is changed: The user interface will be updated.
cx::StringPropertyGlyphOrientationArray::New
static StringPropertyGlyphOrientationArrayPtr New(PatientModelServicePtr patientModelService)
Definition: cxDataInterface.h:308
cx::MeshGlyphsWidget::~MeshGlyphsWidget
virtual ~MeshGlyphsWidget()
Definition: cxMeshGlyphsWidget.cpp:51
cxLabeledComboBoxWidget.h
cxDoubleProperty.h
cxHelperWidgets.h
cxDataInterface.h
cxProfile.h
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::ViewServicePtr
boost::shared_ptr< class ViewService > ViewServicePtr
Definition: cxLogicManager.h:28
cxPatientModelService.h
cx::StringPropertyGlyphColorArray::New
static StringPropertyGlyphColorArrayPtr New(PatientModelServicePtr patientModelService)
Definition: cxDataInterface.h:337
cxRegistrationTransform.h
cxMeshHelpers.h
cxDataLocations.h
cxDataSelectWidget.h
cxSelectClippersForDataWidget.h
cxLabeledLineEditWidget.h
cxSelectDataStringProperty.h
cx::StringPropertyGlyphLUT::New
static StringPropertyGlyphLUTPtr New(PatientModelServicePtr patientModelService)
Definition: cxDataInterface.h:367
cxColorProperty.h
cx::SelectDataStringPropertyBasePtr
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
Definition: cxMeshGlyphsWidget.h:26
cxVisServices.h