CustusX  22.04-rc5
An IGT application
cxMeshPropertiesWidget.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 "cxMeshPropertiesWidget.h"
12 
13 #include <QVBoxLayout>
14 #include <QLabel>
15 #include "cxHelperWidgets.h"
18 
19 namespace cx
20 {
21 
22 MeshPropertiesWidget::MeshPropertiesWidget(SelectDataStringPropertyBasePtr meshSelector,
23  PatientModelServicePtr patientModelService,
24  ViewServicePtr viewService,
25  QWidget* parent) :
26  BaseWidget(parent, "mesh_properties_widget", "Properties"),
27  mPatientModelService(patientModelService),
28  mViewService(viewService),
29  mMeshSelector(meshSelector)
30 {
31  QVBoxLayout* layout = new QVBoxLayout(this);
32  layout->setMargin(0);
33 
34  mPropertiesWidget = new ReplacableContentWidget(this);
35  layout->addWidget(mPropertiesWidget);
36  layout->addStretch();
37 
38  this->clearUI();
39 
40  connect(mMeshSelector.get(), &Property::changed, this, &MeshPropertiesWidget::meshSelectedSlot);
41  this->setModified();
42 }
43 
45 {
46 }
47 
49 {
50  this->setupUI();
51 }
52 
54 {
55  if (mMesh == mMeshSelector->getData())
56  return;
57 
58  // clear gui, ready for next modified
59  this->clearUI();
60 
61  mMesh = boost::dynamic_pointer_cast<Mesh>(mMeshSelector->getData());
62  this->setModified();
63 }
64 
65 void MeshPropertiesWidget::clearUI()
66 {
67  mPropertiesWidget->setWidgetDeleteOld(new QLabel("no\nmesh\nselected"));
68  this->setModified();
69 }
70 
72 {
73  if (!mMesh)
74  return;
75 
76  QWidget* widget = new QWidget;
77  QGridLayout* layout = new QGridLayout(widget);
78  layout->setMargin(0);
79  mPropertiesWidget->setWidgetDeleteOld(widget);
80 
81  std::vector<PropertyPtr> properties = mMesh->getProperties().mProperties;
82  for (unsigned i=0; i<properties.size(); ++i)
83  {
84  createDataWidget(mViewService, mPatientModelService, this, properties[i], layout, i);
85  }
86 }
87 
88 }//end namespace cx
A mesh data set.
Definition: cxMesh.h:45
boost::shared_ptr< class ViewService > ViewServicePtr
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void setWidgetDeleteOld(QWidget *widget)
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.