34 #include <QTreeWidget>
35 #include <QTreeWidgetItem>
36 #include <QStringList>
37 #include <QVBoxLayout>
38 #include <QHeaderView>
64 mViewService(viewService),
65 mPatientModelService(patientModelService)
69 void MetricBase::colorSelected()
76 QString retval = this->
getData()->getValueAsString();
85 "Set color of metric",
86 this->
getData()->getColor(), QDomNode());
87 QHBoxLayout* line =
new QHBoxLayout;
91 layout->addLayout(line);
92 connect(
mColorSelector.get(), SIGNAL(valueWasSet()),
this, SLOT(colorSelected()));
102 mInternalUpdate =
false;
107 mArguments = arguments;
108 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SLOT(dataChangedSlot()));
115 mPSelector.resize(mArguments->getCount());
116 for (
unsigned i=0; i<mPSelector.size(); ++i)
119 QString(
"p%1").arg(i),
120 mArguments->getDescription(i),
121 mArguments->get(i) ? mArguments->get(i)->getUid() :
"",
126 connect(mPSelector[i].
get(), SIGNAL(valueWasSet()),
this, SLOT(pointSelected()));
129 this->dataChangedSlot();
132 void MetricReferenceArgumentListGui::getAvailableArgumentMetrics(QStringList* uid, std::map<QString,QString>* namemap)
135 for (std::map<QString, DataPtr>::iterator iter=data.begin(); iter!=data.end(); ++iter)
137 if (mArguments->validArgument(iter->second))
140 (*namemap)[iter->first] = iter->second->getName();
148 for (
unsigned i=0; i<mArguments->getCount(); ++i)
149 data << (mArguments->get(i) ? mArguments->get(i)->getName() : QString(
"*"));
150 return data.join(
"-");
153 void MetricReferenceArgumentListGui::pointSelected()
157 for (
unsigned i=0; i<mPSelector.size(); ++i)
160 if (mArguments->validArgument(data))
161 mArguments->set(i, data);
163 reportWarning(QString(
"Failed to set data [%1] in metric, invalid argument.").arg(data?data->getName():
"NULL"));
167 void MetricReferenceArgumentListGui::dataChangedSlot()
176 mInternalUpdate =
true;
179 std::map<QString,QString> names;
180 this->getAvailableArgumentMetrics(&range, &names);
182 for (
unsigned i=0; i<mPSelector.size(); ++i)
184 if (!mArguments->get(i))
186 mPSelector[i]->setValue(mArguments->get(i)->getUid());
187 mPSelector[i]->setDisplayNames(names);
188 mPSelector[i]->setValueRange(range);
191 mInternalUpdate =
false;
204 mInternalUpdate =
false;
216 QWidget* widget =
new QWidget;
217 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
218 QHBoxLayout* hLayout =
new QHBoxLayout;
219 hLayout->setMargin(0);
220 topLayout->setMargin(0);
221 topLayout->addLayout(hLayout);
223 mSpaceSelector = this->createSpaceSelector();
226 mCoordinate = this->createCoordinateSelector();
229 QWidget* sampleButton = this->createSampleButton(widget);
230 hLayout->addWidget(sampleButton);
233 topLayout->addStretch();
244 "Select coordinate system to store position in.");
245 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(spaceSelected()));
255 "Coordinate values.",
257 DoubleRange(-1000,1000,1),
261 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(coordinateChanged()));
265 QWidget* PointMetricWrapper::createSampleButton(QWidget* parent)
const
267 QAction* sampleAction =
new QAction(
"Sample", parent);
268 QString sampleTip(
"Set the position equal to the current tool tip position.");
269 sampleAction->setStatusTip(sampleTip);
270 sampleAction->setWhatsThis(sampleTip);
271 sampleAction->setToolTip(sampleTip);
272 connect(sampleAction, SIGNAL(triggered()),
this, SLOT(moveToToolPosition()));
275 sampleButton->setDefaultAction(sampleAction);
291 Vector3D p = mData->getCoordinate();
293 if (mData->getSpace().mId==
csREF)
296 return mData->getSpace().toString() +
" " + coord;
299 void PointMetricWrapper::moveToToolPosition()
302 mData->setCoordinate(p);
305 void PointMetricWrapper::spaceSelected()
309 CoordinateSystem space = mSpaceSelector->getValue();
310 if (!space.isValid())
312 mData->setSpace(space);
315 void PointMetricWrapper::coordinateChanged()
319 mData->setCoordinate(mCoordinate->getValue());
328 mInternalUpdate =
true;
329 mSpaceSelector->setValue(mData->getSpace());
330 mCoordinate->setValue(mData->getCoordinate());
331 mInternalUpdate =
false;
343 mInternalUpdate =
false;
344 connect(mData.get(), SIGNAL(transformChanged()),
this, SLOT(dataChangedSlot()));
345 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
346 connect(
mPatientModelService.get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
351 disconnect(
mPatientModelService.get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
356 QWidget* widget =
new QWidget;
357 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
358 QHBoxLayout* hLayout =
new QHBoxLayout;
359 hLayout->setMargin(0);
360 topLayout->setMargin(0);
361 topLayout->addLayout(hLayout);
365 topLayout->addStretch();
367 this->dataChangedSlot();
387 void PlaneMetricWrapper::dataChangedSlot()
390 mInternalUpdate =
false;
407 mInternalUpdate =
false;
408 connect(mData.get(), SIGNAL(transformChanged()),
this, SLOT(dataChangedSlot()));
409 connect(patientModelService.get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
414 QWidget* widget =
new QWidget;
415 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
416 QHBoxLayout* hLayout =
new QHBoxLayout;
417 hLayout->setMargin(0);
418 topLayout->setMargin(0);
419 topLayout->addLayout(hLayout);
423 topLayout->addStretch();
425 this->dataChangedSlot();
444 void DistanceMetricWrapper::dataChangedSlot()
447 mInternalUpdate =
false;
465 mInternalUpdate =
false;
466 connect(mData.get(), SIGNAL(transformChanged()),
this, SLOT(dataChangedSlot()));
467 connect(
mPatientModelService.get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
472 disconnect(
mPatientModelService.get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
477 QWidget* widget =
new QWidget;
478 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
479 QHBoxLayout* hLayout =
new QHBoxLayout;
480 hLayout->setMargin(0);
481 topLayout->setMargin(0);
482 topLayout->addLayout(hLayout);
486 mUseSimpleVisualization = this->createUseSimpleVisualizationSelector();
490 topLayout->addStretch();
492 this->dataChangedSlot();
510 void AngleMetricWrapper::dataChangedSlot()
512 mInternalUpdate =
true;
513 mUseSimpleVisualization->setValue(mData->getUseSimpleVisualization());
514 mInternalUpdate =
false;
517 void AngleMetricWrapper::guiChanged()
521 mData->setUseSimpleVisualization(mUseSimpleVisualization->getValue());
524 BoolPropertyPtr AngleMetricWrapper::createUseSimpleVisualizationSelector()
const
528 "Simple Visualization",
529 mData->getUseSimpleVisualization());
531 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
549 mInternalUpdate =
false;
550 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
555 QWidget* widget =
new QWidget;
556 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
557 QHBoxLayout* hLayout =
new QHBoxLayout;
558 hLayout->setMargin(0);
559 topLayout->setMargin(0);
560 topLayout->addLayout(hLayout);
564 mRadius = this->createRadiusSelector();
566 mThickness = this->createThicknessSelector();
568 mFlat = this->createFlatSelector();
570 mHeight = this->createHeightSelector();
574 topLayout->addStretch();
576 this->dataChangedSlot();
600 mInternalUpdate =
true;
601 mRadius->setValue(mData->getRadius());
602 mThickness->setValue(mData->getThickness());
603 mHeight->setValue(mData->getHeight());
604 mFlat->setValue(mData->getFlat());
605 mInternalUpdate =
false;
608 void DonutMetricWrapper::dataChangedSlot()
619 void DonutMetricWrapper::guiChanged()
623 mInternalUpdate =
true;
624 mData->setRadius(mRadius->getValue());
625 mData->setThickness(mThickness->getValue());
626 mData->setHeight(mHeight->getValue());
627 mData->setFlat(mFlat->getValue());
628 mInternalUpdate =
false;
639 DoubleRange(0, 50, 1),
643 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
653 mData->getThickness(),
654 DoubleRange(0.05, 1, 0.05),
658 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
667 "Disc height, NA to torus",
669 DoubleRange(0.0, 100, 1),
673 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
682 "Flat disk or torus",
686 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
699 mInternalUpdate =
false;
700 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
705 QWidget* widget =
new QWidget;
706 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
707 QHBoxLayout* hLayout =
new QHBoxLayout;
708 hLayout->setMargin(0);
709 topLayout->setMargin(0);
710 topLayout->addLayout(hLayout);
714 mRadius = this->createRadiusSelector();
718 topLayout->addStretch();
720 this->dataChangedSlot();
738 void SphereMetricWrapper::dataChangedSlot()
746 mInternalUpdate =
true;
747 mRadius->setValue(mData->getRadius());
748 mInternalUpdate =
false;
751 void SphereMetricWrapper::guiChanged()
755 mData->setRadius(mRadius->getValue());
765 DoubleRange(0, 50, 0.5),
769 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
virtual QString getArguments() const
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void setArguments(MetricReferenceArgumentListPtr arguments)
virtual QString getArguments() const
MetricReferenceArgumentListGui()
virtual DataMetricPtr getData() const
virtual DataMetricPtr getData() const
boost::shared_ptr< class DonutMetric > DonutMetricPtr
boost::shared_ptr< DataMetric > DataMetricPtr
void addColorWidget(QVBoxLayout *layout)
static SpacePropertyPtr initialize(const QString &uid, QString name, QString help, Space value=Space(), std::vector< Space > range=std::vector< Space >(), QDomNode root=QDomNode())
QString getAsString() const
virtual ~PlaneMetricWrapper()
SphereMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, SphereMetricPtr data)
virtual QString getType() const
QString prettyFormat(Vector3D val, int decimals, int fieldWidth)
boost::shared_ptr< class SpaceProperty > SpacePropertyPtr
PlaneMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, PlaneMetricPtr data)
csREF
the data reference space (r) using LPS (left-posterior-superior) coordinates.
boost::shared_ptr< class SphereMetric > SphereMetricPtr
virtual DataMetricPtr getData() const =0
virtual DataMetricPtr getData() const
virtual QString getArguments() const
virtual QWidget * createWidget()
boost::shared_ptr< class AngleMetric > AngleMetricPtr
ViewServicePtr mViewService
virtual QString getArguments() const
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
ColorPropertyPtr mColorSelector
virtual QString getArguments() const
boost::shared_ptr< class PlaneMetric > PlaneMetricPtr
boost::shared_ptr< class Data > DataPtr
PatientModelServicePtr mPatientModelService
virtual QString getType() const
virtual QWidget * createWidget()
virtual QString getType() const
void reportWarning(QString msg)
static Vector3DPropertyPtr initialize(const QString &uid, QString name, QString help, Vector3D value, DoubleRange range, int decimals, QDomNode root=QDomNode())
virtual QString getType() const
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
virtual QWidget * createWidget()
void addWidgets(QBoxLayout *layout)
boost::shared_ptr< class MetricReferenceArgumentList > MetricReferenceArgumentListPtr
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
virtual DataMetricPtr getData() const
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
virtual QString getType() const
DonutMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, DonutMetricPtr data)
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
virtual QWidget * createWidget()
MetricBase(ViewServicePtr viewService, PatientModelServicePtr patientModelService)
cxLogicManager_EXPORT ViewServicePtr viewService()
boost::shared_ptr< class Vector3DProperty > Vector3DPropertyPtr
virtual DataMetricPtr getData() const
cxLogicManager_EXPORT PatientModelServicePtr patientService()
virtual ~PointMetricWrapper()
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
virtual QString getType() const
AngleMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, AngleMetricPtr data)
virtual QWidget * createWidget()
static ColorPropertyPtr initialize(const QString &uid, QString name, QString help, QColor value, QDomNode root=QDomNode())
virtual QString getArguments() const
virtual ~AngleMetricWrapper()
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
virtual QString getValue() const
virtual QWidget * createWidget()
DistanceMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, DistanceMetricPtr data)
PointMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, PointMetricPtr data)
virtual DataMetricPtr getData() const
boost::shared_ptr< class PointMetric > PointMetricPtr