18 #include "QmitkMaterialEditor.h"
25 #include <qcolordialog.h>
26 #include <qinputdialog.h>
27 #include <qmessagebox.h>
29 #include <QWidgetAction>
30 #include <qmenudata.h>
34 mitk::PropertyList *list, QObject *parent,
bool disableBoolProperties,
bool fillMenuImmediatelty,
const char *name)
35 : QObject(parent, name),
36 m_PopupMenu(new QMenu(name, dynamic_cast<QWidget *>(parent))),
38 m_MaterialEditor(NULL),
40 m_VisibleMenuAction(0),
42 m_MaterialMenuAction(0),
43 m_OpacityMenuAction(0),
44 m_AcceptOnHide(false),
45 m_DisableBoolProperties(disableBoolProperties)
49 std::cerr <<
"In " __FILE__
", l." << __LINE__
50 <<
": popup menu without parent. This tends to crash (click 'Choose color' in the material editor)."
54 if (fillMenuImmediatelty)
65 QPixmap pixmap(20, 20);
66 QPainter painter(&pixmap);
67 painter.setPen(Qt::NoPen);
68 painter.fillRect(QRect(0, 0, 20, 20), color);
82 QColor currentColor((
int)(col.GetRed() * 255), (
int)(col.GetGreen() * 255), (
int)(col.GetBlue() * 255));
85 normalFont.setBold(
true);
108 dynamic_cast<mitk::FloatProperty *>(
m_PropertyList->GetProperty(
"opacity")))
111 QMenu *opacityPopup =
m_PopupMenu->addMenu(
"Opacity");
118 QWidgetAction *opacityMenuAction =
new QWidgetAction(opacityPopup);
119 opacityMenuAction->setDefaultWidget(npe);
160 boldFont.setBold(
true);
163 for (mitk::PropertyList::PropertyMap::const_iterator propertyIter = map->begin(); propertyIter != map->end();
166 std::string name = propertyIter->first;
167 if (name ==
"visible")
171 dynamic_cast<mitk::BoolProperty *>(propertyIter->second.first.GetPointer()))
176 int newID =
m_PopupMenu->insertItem(QString(
"%1").arg(name.c_str()));
177 m_PopupMenu->setItemChecked(newID, boolProperty->GetValue());
190 for (mitk::PropertyList::PropertyMap::const_iterator propertyIter = map->begin(); propertyIter != map->end();
193 std::string name = propertyIter->first;
194 if (!dynamic_cast<mitk::BoolProperty *>(propertyIter->second.first.GetPointer()))
196 std::string value(
"no value");
200 value = bp->GetValueAsString();
202 m_InfoPopup->insertItem(QString(
"%1: %2").arg(name.c_str()).arg(value.c_str()));
212 if (mitk::MaterialProperty *materialProperty =
213 dynamic_cast<mitk::MaterialProperty *>(
m_PropertyList->GetProperty(
"material")))
218 m_MaterialEditor =
new QmitkMaterialEditor(
m_PopupMenu);
219 m_MaterialEditor->setInline(
true);
220 m_MaterialEditor->Initialize(materialProperty);
221 QWidgetAction *materialEditorMenuItem =
new QWidgetAction(materialPopup);
222 materialEditorMenuItem->setDefaultWidget(m_MaterialEditor);
223 materialPopup->addAction(materialEditorMenuItem);
224 connect(m_MaterialEditor,
225 SIGNAL(ChangesAccepted(QmitkMaterialEditor *)),
241 delete m_MaterialEditor;
255 QString newName = QInputDialog::getText(tr(
"Change object name"),
256 QString(tr(
"Enter a new name for \"%1\"")).arg(nameProperty->
GetValue()),
261 if (ok && !newName.isEmpty())
264 nameProperty->
SetValue(newName.ascii());
265 nameProperty->Modified();
272 tr(
"Change object name"),
273 tr(
"Do you really want to assign an empty name to '%1'?").arg(nameProperty->
GetValue()),
275 QMessageBox::No) == QMessageBox::Yes)
278 nameProperty->
SetValue(newName.ascii());
279 nameProperty->Modified();
293 visibleProperty->Modified();
305 QColor result = QColorDialog::getColor(
306 QColor((
int)(col.GetRed() * 255), (
int)(col.GetGreen() * 255), (
int)(col.GetBlue() * 255)));
307 if (result.isValid())
309 col.SetRed(result.red() / 255.0);
310 col.SetGreen(result.green() / 255.0);
311 col.SetBlue(result.blue() / 255.0);
313 colorProperty->Modified();
335 boolProperty->Modified();
388 mitk::MaterialProperty *material =
dynamic_cast<mitk::MaterialProperty *
>(
m_PropertyList->GetProperty(
"material"));
392 material->SetDataNode(NULL);
393 m_OriginalMaterial->SetDataNode(NULL);
394 if (!(*material == *m_OriginalMaterial))
398 material->SetDataNode(node);
void SetColor(const mitk::Color &color)
Key-value list holding instances of BaseProperty.
virtual const char * 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.
virtual T GetValue() const
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.