Fraxinus  17.12-rc2
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) 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 "cxMeshGlyphsWidget.h"
33 
34 #include <QVBoxLayout>
35 #include "cxImage.h"
36 
37 #include "cxDoubleProperty.h"
41 #include "cxMeshHelpers.h"
42 #include "cxHelperWidgets.h"
43 #include "cxColorProperty.h"
44 #include "cxDataLocations.h"
45 #include "cxDataInterface.h"
46 #include "cxDataSelectWidget.h"
48 
49 #include "cxPatientModelService.h"
50 #include "cxLogger.h"
51 #include "cxProfile.h"
52 #include "cxVisServices.h"
54 
55 namespace cx
56 {
57 
58 MeshGlyphsWidget::MeshGlyphsWidget(SelectDataStringPropertyBasePtr meshSelector,
59  PatientModelServicePtr patientModelService,
60  ViewServicePtr viewService,
61  QWidget* parent) :
62  BaseWidget(parent, "mesh_glyphs_widget", "Glyphs"),
63  mPatientModelService(patientModelService),
64  mViewService(viewService),
65  mMeshSelector(meshSelector)
66 {
67  connect(mMeshSelector.get(), &Property::changed, this, &MeshGlyphsWidget::meshSelectedSlot);
68  this->addWidgets();
69  this->meshSelectedSlot();
70 }
71 
73 {
74 }
75 
77 {
78  if (mMesh == mMeshSelector->getData())
79  return;
80 
81  if(mMesh)
82  {
83  disconnect(mGlyphVisualizationCheckBox, SIGNAL(toggled(bool)), mMesh.get(), SLOT(setShowGlyph(bool)));
84  disconnect(mMesh.get(), SIGNAL(meshChanged()), this, SLOT(meshChangedSlot()));
85  }
86 
87  mMesh = boost::dynamic_pointer_cast<Mesh>(mMeshSelector->getData());
88 
89  mGlyphOrientationArrayAdapter->setData(mMesh);
90  mGlyphColorArrayAdapter->setData(mMesh);
91  mGlyphColorLUTAdapter->setData(mMesh);
92 
93  if (!mMesh)
94  {
95  return;
96  }
97 
98  mGlyphVisualizationCheckBox->setChecked(mMesh->showGlyph());
99  mGlyphVisualizationCheckBox->setEnabled(mMesh->hasGlyph());
100 
101  connect(mGlyphVisualizationCheckBox, SIGNAL(toggled(bool)), mMesh.get(), SLOT(setShowGlyph(bool)));
102 
103  connect(mMesh.get(), SIGNAL(meshChanged()), this, SLOT(meshChangedSlot()));
104 }
105 
107 {
108  if(!mMesh)
109  return;
110  mGlyphVisualizationCheckBox->setChecked(mMesh->showGlyph());
111  mGlyphVisualizationCheckBox->setEnabled(mMesh->hasGlyph());
112 }
113 
114 void MeshGlyphsWidget::addWidgets()
115 {
116  QVBoxLayout* toptopLayout = new QVBoxLayout(this);
117  QGridLayout* gridLayout = new QGridLayout;
118  gridLayout->setMargin(0);
119  toptopLayout->addLayout(gridLayout);
120 
121  mGlyphOrientationArrayAdapter = StringPropertyGlyphOrientationArray::New(mPatientModelService);
122  mGlyphColorArrayAdapter = StringPropertyGlyphColorArray::New(mPatientModelService);
123  mGlyphColorLUTAdapter = StringPropertyGlyphLUT::New(mPatientModelService);
124 
125  int row = 1;
126  mGlyphVisualizationCheckBox = new QCheckBox("Enable glyph visualization");
127  mGlyphVisualizationCheckBox->setToolTip("Enable glyph visualization");
128  gridLayout->addWidget(mGlyphVisualizationCheckBox, row++,0);
129  new LabeledComboBoxWidget(this, mGlyphOrientationArrayAdapter,gridLayout, row++);
130  new LabeledComboBoxWidget(this, mGlyphColorArrayAdapter,gridLayout, row++);
131  new LabeledComboBoxWidget(this, mGlyphColorLUTAdapter,gridLayout, row++);
132  toptopLayout->addStretch();
133 }
134 
135 
136 
137 }//end namespace cx
A mesh data set.
Definition: cxMesh.h:66
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:109
Namespace for all CustusX production code.