CustusX  22.04-rc5
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
A mesh data set.
Definition: cxMesh.h:45
static StringPropertyGlyphLUTPtr New(PatientModelServicePtr patientModelService)
boost::shared_ptr< class ViewService > ViewServicePtr
Composite widget for string selection.
static StringPropertyGlyphColorArrayPtr New(PatientModelServicePtr patientModelService)
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
static StringPropertyGlyphOrientationArrayPtr New(PatientModelServicePtr patientModelService)
void changed()
emit when the underlying data value is changed: The user interface will be updated.
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
Namespace for all CustusX production code.