Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkPropertyViewFactory.h"
00019
00020
00021 #include "QmitkBasePropertyView.h"
00022 #include "QmitkBoolPropertyView.h"
00023 #include "QmitkBoolPropertyEditor.h"
00024 #include "QmitkStringPropertyView.h"
00025 #include "QmitkStringPropertyEditor.h"
00026 #include "QmitkStringPropertyOnDemandEdit.h"
00027 #include "QmitkColorPropertyView.h"
00028 #include "QmitkColorPropertyEditor.h"
00029 #include "QmitkNumberPropertyView.h"
00030 #include "QmitkNumberPropertyEditor.h"
00031
00032 QmitkPropertyViewFactory* QmitkPropertyViewFactory::GetInstance()
00033 {
00034 static QmitkPropertyViewFactory instance;
00035 return &instance;
00036 }
00037
00038 QmitkPropertyViewFactory::QmitkPropertyViewFactory()
00039 {
00040 }
00041
00042 QmitkPropertyViewFactory::~QmitkPropertyViewFactory()
00043 {
00044 }
00045 QWidget* QmitkPropertyViewFactory::CreateView(const mitk::BaseProperty* property, unsigned int , QWidget* parent)
00046 {
00047 if ( const mitk::StringProperty* prop = dynamic_cast<const mitk::StringProperty*>(property) )
00048 {
00049
00050 return new QmitkStringPropertyView(prop, parent);
00051 }
00052 else if ( const mitk::ColorProperty* prop = dynamic_cast<const mitk::ColorProperty*>(property) )
00053 {
00054
00055 return new QmitkColorPropertyView(prop, parent);
00056 }
00057 else if ( const mitk::BoolProperty* prop = dynamic_cast<const mitk::BoolProperty*>(property) )
00058 {
00059
00060 return new QmitkBoolPropertyView(prop, parent);
00061 }
00062
00063
00064
00065
00066
00067
00068
00069 else if ( const mitk::IntProperty* prop = dynamic_cast<const mitk::IntProperty*>(property) )
00070 {
00071
00072 return new QmitkNumberPropertyView(prop, parent);
00073 }
00074 else if ( const mitk::FloatProperty* prop = dynamic_cast<const mitk::FloatProperty*>(property) )
00075 {
00076
00077 return new QmitkNumberPropertyView(prop, parent);
00078 }
00079 else if ( const mitk::DoubleProperty* prop = dynamic_cast<const mitk::DoubleProperty*>(property) )
00080 {
00081
00082 return new QmitkNumberPropertyView(prop, parent);
00083 }
00084 else if ( property != NULL )
00085 {
00086
00087 return new QmitkBasePropertyView(prop, parent);
00088 }
00089
00090 return NULL;
00091 }
00092
00093 QWidget* QmitkPropertyViewFactory::CreateEditor(mitk::BaseProperty* property, unsigned int type, QWidget* parent)
00094 {
00095 if (!property) return NULL;
00096
00097 if ( mitk::StringProperty* prop = dynamic_cast<mitk::StringProperty*>(property) )
00098 {
00099 switch (type)
00100 {
00101 case etON_DEMAND_EDIT:
00102
00103 return new QmitkStringPropertyOnDemandEdit(prop, parent);
00104 default:
00105
00106 return new QmitkStringPropertyEditor(prop, parent);
00107 }
00108 }
00109 else if ( mitk::ColorProperty* prop = dynamic_cast<mitk::ColorProperty*>(property) )
00110 {
00111
00112 return new QmitkColorPropertyEditor(prop, parent);
00113 }
00114 else if ( mitk::BoolProperty* prop = dynamic_cast<mitk::BoolProperty*>(property) )
00115 {
00116
00117 return new QmitkBoolPropertyEditor(prop, parent);
00118 }
00119
00120
00121
00122
00123
00124
00125
00126 else if ( mitk::IntProperty* prop = dynamic_cast<mitk::IntProperty*>(property) )
00127 {
00128
00129 return new QmitkNumberPropertyEditor(prop, parent);
00130 }
00131 else if ( mitk::FloatProperty* prop = dynamic_cast<mitk::FloatProperty*>(property) )
00132 {
00133
00134 QmitkNumberPropertyEditor* pe = new QmitkNumberPropertyEditor(prop, parent);
00135 pe->setDecimalPlaces(2);
00136 return pe;
00137 }
00138 else if ( mitk::DoubleProperty* prop = dynamic_cast<mitk::DoubleProperty*>(property) )
00139 {
00140
00141 QmitkNumberPropertyEditor* pe = new QmitkNumberPropertyEditor(prop, parent);
00142 pe->setDecimalPlaces(2);
00143 return pe;
00144 }
00145 else
00146 {
00147
00148 return NULL;
00149 }
00150 }
00151