14 #include "QmitkMaterialEditor.h" 21 #include <qcolordialog.h> 22 #include <qinputdialog.h> 23 #include <qmessagebox.h> 25 #include <QWidgetAction> 26 #include <qmenudata.h> 30 mitk::PropertyList *list, QObject *parent,
bool disableBoolProperties,
bool fillMenuImmediatelty,
const char *name)
31 : QObject(parent, name),
32 m_PopupMenu(new QMenu(name, dynamic_cast<QWidget *>(parent))),
34 m_MaterialEditor(nullptr),
36 m_VisibleMenuAction(0),
38 m_MaterialMenuAction(0),
39 m_OpacityMenuAction(0),
40 m_AcceptOnHide(false),
41 m_DisableBoolProperties(disableBoolProperties)
45 std::cerr <<
"In " __FILE__
", l." << __LINE__
46 <<
": popup menu without parent. This tends to crash (click 'Choose color' in the material editor)." 50 if (fillMenuImmediatelty)
61 QPixmap pixmap(20, 20);
62 QPainter painter(&pixmap);
63 painter.setPen(Qt::NoPen);
64 painter.fillRect(QRect(0, 0, 20, 20), color);
78 QColor currentColor((
int)(col.GetRed() * 255), (
int)(col.GetGreen() * 255), (
int)(col.GetBlue() * 255));
81 normalFont.setBold(
true);
104 dynamic_cast<mitk::FloatProperty *>(
m_PropertyList->GetProperty(
"opacity")))
107 QMenu *opacityPopup =
m_PopupMenu->addMenu(
"Opacity");
114 QWidgetAction *opacityMenuAction =
new QWidgetAction(opacityPopup);
115 opacityMenuAction->setDefaultWidget(npe);
156 boldFont.setBold(
true);
159 for (mitk::PropertyList::PropertyMap::const_iterator propertyIter = map->begin(); propertyIter != map->end();
162 std::string name = propertyIter->first;
163 if (name ==
"visible")
167 dynamic_cast<mitk::BoolProperty *>(propertyIter->second.first.GetPointer()))
172 int newID =
m_PopupMenu->insertItem(QString(
"%1").arg(name.c_str()));
173 m_PopupMenu->setItemChecked(newID, boolProperty->GetValue());
186 for (mitk::PropertyList::PropertyMap::const_iterator propertyIter = map->begin(); propertyIter != map->end();
189 std::string name = propertyIter->first;
190 if (!dynamic_cast<mitk::BoolProperty *>(propertyIter->second.first.GetPointer()))
192 std::string value(
"no value");
196 value = bp->GetValueAsString();
198 m_InfoPopup->insertItem(QString(
"%1: %2").arg(name.c_str()).arg(value.c_str()));
208 if (mitk::MaterialProperty *materialProperty =
209 dynamic_cast<mitk::MaterialProperty *>(
m_PropertyList->GetProperty(
"material")))
211 m_OriginalMaterial = mitk::MaterialProperty::New(*materialProperty);
214 m_MaterialEditor =
new QmitkMaterialEditor(
m_PopupMenu);
215 m_MaterialEditor->setInline(
true);
216 m_MaterialEditor->Initialize(materialProperty);
217 QWidgetAction *materialEditorMenuItem =
new QWidgetAction(materialPopup);
218 materialEditorMenuItem->setDefaultWidget(m_MaterialEditor);
219 materialPopup->addAction(materialEditorMenuItem);
220 connect(m_MaterialEditor,
221 SIGNAL(ChangesAccepted(QmitkMaterialEditor *)),
237 delete m_MaterialEditor;
251 QString newName = QInputDialog::getText(tr(
"Change object name"),
252 QString(tr(
"Enter a new name for \"%1\"")).arg(nameProperty->
GetValue()),
257 if (ok && !newName.isEmpty())
260 nameProperty->
SetValue(newName.ascii());
261 nameProperty->Modified();
268 tr(
"Change object name"),
269 tr(
"Do you really want to assign an empty name to '%1'?").arg(nameProperty->
GetValue()),
271 QMessageBox::No) == QMessageBox::Yes)
274 nameProperty->
SetValue(newName.ascii());
275 nameProperty->Modified();
289 visibleProperty->Modified();
301 QColor result = QColorDialog::getColor(
302 QColor((
int)(col.GetRed() * 255), (
int)(col.GetGreen() * 255), (
int)(col.GetBlue() * 255)));
303 if (result.isValid())
305 col.SetRed(result.red() / 255.0);
306 col.SetGreen(result.green() / 255.0);
307 col.SetBlue(result.blue() / 255.0);
309 colorProperty->Modified();
331 boolProperty->Modified();
384 mitk::MaterialProperty *material =
dynamic_cast<mitk::MaterialProperty *
>(
m_PropertyList->GetProperty(
"material"));
388 material->SetDataNode(
nullptr);
389 m_OriginalMaterial->SetDataNode(
nullptr);
390 if (!(*material == *m_OriginalMaterial))
394 material->SetDataNode(node);
virtual const char * GetValue() const
void SetColor(const mitk::Color &color)
Key-value list holding instances of BaseProperty.
virtual T GetValue() const
The ColorProperty class RGB color property.
std::map< std::string, BaseProperty::Pointer > PropertyMap
static RenderingManager * GetInstance()
const mitk::Color & GetColor() const
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
virtual void SetValue(const char *_arg)
void setShowPercent(bool)
virtual void SetValue(T _arg)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.